mirror of
https://codeberg.org/icewind/bitbuffer.git
synced 2026-06-03 08:34:07 +02:00
fix read_bytes in BE mode
This commit is contained in:
parent
5e7a68a57e
commit
ea2640655b
2 changed files with 26 additions and 4 deletions
|
|
@ -234,6 +234,20 @@ fn test_from() {
|
|||
let _: BitStream<LittleEndian> = BitStream::from(BYTES.to_vec());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_read_str_be() {
|
||||
let bytes = vec![
|
||||
0x48, 0x65, 0x6c, 0x6c,
|
||||
0x6f, 0x20, 0x77, 0x6f,
|
||||
0x72, 0x6c, 0x64, 0,
|
||||
0, 0, 0, 0
|
||||
];
|
||||
let buffer = BitBuffer::new(bytes, BigEndian);
|
||||
assert_eq!(buffer.read_string(0, Some(13)).unwrap(), "Hello world".to_owned());
|
||||
assert_eq!(buffer.read_string(0, Some(16)).unwrap(), "Hello world".to_owned());
|
||||
assert_eq!(buffer.read_string(0, None).unwrap(), "Hello world".to_owned());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn read_trait() {
|
||||
let buffer = BitBuffer::new(BYTES.to_vec(), BigEndian);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue