1
0
Fork 0
mirror of https://codeberg.org/icewind/bitbuffer.git synced 2026-06-03 16:44:06 +02:00

more string reading tests

This commit is contained in:
Robin Appelman 2019-03-07 20:03:32 +01:00
commit 0a5daeb62d

View file

@ -252,6 +252,41 @@ fn test_read_str_be() {
); );
} }
#[test]
fn test_read_str_le() {
let bytes = vec![
'h' as u8,
'e' as u8,
'l' as u8,
'l' as u8,
'o' as u8,
' ' as u8,
'w' as u8,
'o' as u8,
'r' as u8,
'l' as u8,
'd' as u8,
0,
'f' as u8,
'o' as u8,
'o' as u8,
0, 0, 0, 0, 0,
];
let buffer = BitBuffer::new(bytes, LittleEndian);
assert_eq!(
buffer.read_string(0, Some(3)).unwrap(),
"hel".to_owned()
);
assert_eq!(
buffer.read_string(0, Some(11)).unwrap(),
"hello world".to_owned()
);
assert_eq!(
buffer.read_string(0, None).unwrap(),
"hello world".to_owned()
);
}
#[test] #[test]
fn read_trait() { fn read_trait() {
let buffer = BitBuffer::new(BYTES.to_vec(), BigEndian); let buffer = BitBuffer::new(BYTES.to_vec(), BigEndian);