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:
parent
be50e68461
commit
0a5daeb62d
1 changed files with 35 additions and 0 deletions
|
|
@ -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);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue