1
0
Fork 0
mirror of https://codeberg.org/icewind/bitbuffer.git synced 2026-06-04 00:54:07 +02:00

rountrip tests

This commit is contained in:
Robin Appelman 2021-07-12 20:19:36 +02:00
commit f704ee9f9a
4 changed files with 117 additions and 10 deletions

View file

@ -150,3 +150,19 @@ fn test_write_string_le_unaligned() {
// 0 padded
assert_eq!(false, read.read_bool().unwrap());
}
#[test]
fn test_write_signed() {
let mut stream = BitWriteStream::new(LittleEndian);
stream.write_bool(true).unwrap();
stream.write_int(-17i32, 32).unwrap();
stream.write_int(-9i32, 8).unwrap();
let data = stream.finish();
let mut read = BitReadStream::from(BitReadBuffer::new(&data, LittleEndian));
assert_eq!(true, read.read_bool().unwrap());
assert_eq!(-17i32, read.read_int(32).unwrap());
assert_eq!(-9i32, read.read_int(8).unwrap());
}