Simplify test code a bit, use Request::new() to simplfy constructing requests

This commit is contained in:
Barry Pederson
2024-11-03 12:49:23 -08:00
parent 4d70463e46
commit 60bc980e8d
4 changed files with 24 additions and 39 deletions
+4 -8
View File
@@ -5,10 +5,9 @@ use std::io::Cursor;
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()
);
let result = read_string(&mut buffer.as_ref()).unwrap();
assert_eq!(result, "Foo");
}
#[test]
@@ -17,8 +16,5 @@ fn it_writes_strings() {
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']);
assert_eq!(buffer.into_inner(), [0x0, 0x3, b'F', b'o', b'o']);
}