ppt_rs/generator/table/
row.rs1use super::cell::TableCell;
4
5#[derive(Clone, Debug)]
7pub struct TableRow {
8 pub cells: Vec<TableCell>,
10 pub height: Option<u32>,
12}
13
14impl TableRow {
15 pub fn new(cells: Vec<TableCell>) -> Self {
17 TableRow {
18 cells,
19 height: None,
20 }
21 }
22
23 pub fn with_height(mut self, height: u32) -> Self {
25 self.height = Some(height);
26 self
27 }
28
29 pub fn cell_count(&self) -> usize {
31 self.cells.len()
32 }
33}
34
35#[cfg(test)]
36mod tests {
37 use super::*;
38
39 #[test]
40 fn test_row_new() {
41 let row = TableRow::new(vec![
42 TableCell::new("A"),
43 TableCell::new("B"),
44 ]);
45 assert_eq!(row.cell_count(), 2);
46 assert!(row.height.is_none());
47 }
48
49 #[test]
50 fn test_row_with_height() {
51 let row = TableRow::new(vec![TableCell::new("A")])
52 .with_height(500000);
53 assert_eq!(row.height, Some(500000));
54 }
55}