1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-04 10:34:11 +02:00

some write progress

This commit is contained in:
Robin Appelman 2021-07-13 20:42:59 +02:00
commit 9a9bcdc9df
18 changed files with 286 additions and 90 deletions

View file

@ -12,3 +12,24 @@ pub use crate::demo::{
pub(crate) mod consthash;
pub mod demo;
mod nullhasher;
#[cfg(test)]
#[track_caller]
fn test_roundtrip_encode<
'a,
T: bitbuffer::BitRead<'a, bitbuffer::LittleEndian>
+ bitbuffer::BitWrite<bitbuffer::LittleEndian>
+ std::fmt::Debug
+ std::cmp::PartialEq,
>(
val: T,
) {
use bitbuffer::{BitReadBuffer, BitReadStream, BitWriteStream, LittleEndian};
let mut stream = BitWriteStream::new(LittleEndian);
val.write(&mut stream).unwrap();
let pos = stream.bit_len();
let mut read = BitReadStream::new(BitReadBuffer::new_owned(stream.finish(), LittleEndian));
assert_eq!(val, read.read().unwrap());
assert_eq!(pos, read.pos());
}