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

Merge pull request #6 from hussein-aitlahcen/master

fixup: decrement before indexing with `last_mut`
This commit is contained in:
Robin Appelman 2024-04-03 19:45:35 +02:00 committed by GitHub
commit 7422800014
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 20 additions and 3 deletions

View file

@ -227,3 +227,19 @@ fn test_write_to_slice() {
// 0 padded
assert!(!read.read_bool().unwrap());
}
#[test]
fn test_write_last_slice() {
let mut data = [0; 1];
{
let mut stream = BitWriteStream::from_slice(&mut data[..], LittleEndian);
stream.write_int::<u8>(0b1000, 4).unwrap();
stream.write_bool(true).unwrap();
}
let mut read = BitReadStream::from(BitReadBuffer::new(&data[..], LittleEndian));
assert_eq!(0b1000, read.read_int::<u8>(4).unwrap());
assert_eq!(true, read.read_bool().unwrap());
}