2024-11-03 11:44:03 -08:00
|
|
|
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'];
|
|
|
|
|
|
2024-11-03 12:49:23 -08:00
|
|
|
let result = read_string(&mut buffer.as_ref()).unwrap();
|
|
|
|
|
|
|
|
|
|
assert_eq!(result, "Foo");
|
2024-11-03 11:44:03 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
|
fn it_writes_strings() {
|
|
|
|
|
let mut buffer = Cursor::new(Vec::new());
|
|
|
|
|
|
|
|
|
|
write_string(&mut buffer, "Foo").unwrap();
|
|
|
|
|
|
2024-11-03 12:49:23 -08:00
|
|
|
assert_eq!(buffer.into_inner(), [0x0, 0x3, b'F', b'o', b'o']);
|
2024-11-03 11:44:03 -08:00
|
|
|
}
|