added a size assertion to the basic example

This commit is contained in:
Ty Overby 2014-10-27 13:27:44 -07:00
parent ed96883a53
commit 00929f29dc
2 changed files with 4 additions and 0 deletions

View File

@ -37,6 +37,8 @@ fn main() {
}; };
let encoded: Vec<u8> = bincode::encode(&world).unwrap(); let encoded: Vec<u8> = bincode::encode(&world).unwrap();
// 8 bytes for the length of the vector, 4 bytes per float.
assert_eq!(encoded.len(), 8 + 4 * 4);
let decoded: World = bincode::decode(encoded).unwrap(); let decoded: World = bincode::decode(encoded).unwrap();
assert!(world == decoded); assert!(world == decoded);

View File

@ -18,6 +18,8 @@ fn main() {
}; };
let encoded: Vec<u8> = bincode::encode(&world).unwrap(); let encoded: Vec<u8> = bincode::encode(&world).unwrap();
// 8 bytes for the length of the vector, 4 bytes per float.
assert_eq!(encoded.len(), 8 + 4 * 4);
let decoded: World = bincode::decode(encoded).unwrap(); let decoded: World = bincode::decode(encoded).unwrap();
assert!(world == decoded); assert!(world == decoded);