Reorganize and refactor, adding integration test for common library stuff

This commit is contained in:
Barry Pederson
2024-11-03 11:44:03 -08:00
parent 00743fbe9c
commit 5f4a0e0e88
9 changed files with 148 additions and 82 deletions
+24
View File
@@ -0,0 +1,24 @@
use common::io::{read_string, write_string};
use std::io::Cursor;
#[test]
fn it_reads_strings() {
let buffer = [0x0, 0x3, b'F', b'o', b'o'];
assert_eq!(
read_string(&mut buffer.as_ref()).unwrap(),
"Foo".to_string()
);
}
#[test]
fn it_writes_strings() {
let mut buffer = Cursor::new(Vec::new());
write_string(&mut buffer, "Foo").unwrap();
// Should have written exactly 5 bytes
assert_eq!(buffer.get_ref().len(), 5usize);
assert_eq!(&buffer.get_ref()[0..5], [0x0, 0x3, b'F', b'o', b'o']);
}