Reorganize and refactor, adding integration test for common library stuff
This commit is contained in:
@@ -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']);
|
||||
}
|
||||
Reference in New Issue
Block a user