mirror of
https://codeberg.org/icewind/bitbuffer.git
synced 2026-06-04 00:54:07 +02:00
'assert' check bounds when reading, fix issue with missing null termination for strings
This commit is contained in:
parent
e56f636905
commit
00e4efec86
3 changed files with 59 additions and 7 deletions
|
|
@ -253,6 +253,30 @@ fn test_read_str_be() {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_read_str_no_null_termination_le() {
|
||||
let bytes = vec![
|
||||
0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64,
|
||||
];
|
||||
let buffer = BitBuffer::new(bytes, LittleEndian);
|
||||
assert_eq!(
|
||||
buffer.read_string(0, None).unwrap(),
|
||||
"Hello world".to_owned()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_read_str_no_null_termination_be() {
|
||||
let bytes = vec![
|
||||
0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f, 0x72, 0x6c, 0x64,
|
||||
];
|
||||
let buffer = BitBuffer::new(bytes, BigEndian);
|
||||
assert_eq!(
|
||||
buffer.read_string(0, None).unwrap(),
|
||||
"Hello world".to_owned()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_read_str_le() {
|
||||
let bytes = vec![
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue