mirror of
https://github.com/Noratrieb/haesli.git
synced 2026-01-16 20:55:03 +01:00
write some tests
This commit is contained in:
parent
5a99ae4cd2
commit
b63b2dee2a
7 changed files with 172 additions and 17 deletions
|
|
@ -74,14 +74,17 @@ pub fn timestamp<W: Write>(value: Timestamp, writer: &mut W) -> Result<(), Trans
|
|||
}
|
||||
|
||||
pub fn table<W: Write>(table: Table, writer: &mut W) -> Result<(), TransError> {
|
||||
let len = u32::try_from(table.len()).context("table too big")?;
|
||||
writer.write_all(&len.to_be_bytes())?;
|
||||
let mut table_buf = Vec::new();
|
||||
|
||||
for (field_name, value) in table {
|
||||
shortstr(field_name, writer)?;
|
||||
field_value(value, writer)?;
|
||||
shortstr(field_name, &mut table_buf)?;
|
||||
field_value(value, &mut table_buf)?;
|
||||
}
|
||||
|
||||
let len = u32::try_from(table_buf.len()).context("table too big")?;
|
||||
writer.write_all(&len.to_be_bytes())?;
|
||||
writer.write_all(&table_buf)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue