21 lines
440 B
Rust
21 lines
440 B
Rust
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'];
|
|
|
|
let result = read_string(&mut buffer.as_ref()).unwrap();
|
|
|
|
assert_eq!(result, "Foo");
|
|
}
|
|
|
|
#[test]
|
|
fn it_writes_strings() {
|
|
let mut buffer = Cursor::new(Vec::new());
|
|
|
|
write_string(&mut buffer, "Foo").unwrap();
|
|
|
|
assert_eq!(buffer.into_inner(), [0x0, 0x3, b'F', b'o', b'o']);
|
|
}
|