use super::{TableProperty, TableRow}; use crate::documents::BuildXML; use crate::xml_builder::*; #[derive(Debug, Clone)] pub struct Table { property: TableProperty, rows: Vec, } impl Table { pub fn new(rows: Vec) -> Table { let property = TableProperty::new(); Self { property, rows } } } impl BuildXML for Table { fn build(&self) -> Vec { let b = XMLBuilder::new() .open_table() .add_child(&self.property) .add_children(&self.rows); b.close().build() } } #[cfg(test)] mod tests { use super::*; #[cfg(test)] use pretty_assertions::assert_eq; use std::str; #[test] fn test_row() { let b = Table::new(vec![TableRow::new(vec![])]).build(); assert_eq!( str::from_utf8(&b).unwrap(), r#" "# ); } }