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

bunch of write stuff

This commit is contained in:
Robin Appelman 2021-07-12 00:13:05 +02:00
commit 23ed7b0e4a
12 changed files with 840 additions and 116 deletions

View file

@ -118,6 +118,22 @@ fn test_write_float_be() {
fn test_write_string_le() {
let mut stream = BitWriteStream::new(LittleEndian);
stream.write_string("null terminated", None).unwrap();
stream.write_string("fixed length1", Some(16)).unwrap();
stream.write_string("fixed length2", Some(16)).unwrap();
let data = stream.finish();
let mut read = BitReadStream::from(BitReadBuffer::new(&data, LittleEndian));
assert_eq!("null terminated", read.read_string(None).unwrap());
assert_eq!("fixed length1", read.read_string(Some(16)).unwrap());
assert_eq!("fixed length2", read.read_string(Some(16)).unwrap());
}
#[test]
fn test_write_string_le_unaligned() {
let mut stream = BitWriteStream::new(LittleEndian);
stream.write_bool(true).unwrap();
stream.write_string("null terminated", None).unwrap();
stream.write_string("fixed length1", Some(16)).unwrap();