diff options
Diffstat (limited to 'lvc/src/bin/test.rs')
-rw-r--r-- | lvc/src/bin/test.rs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/lvc/src/bin/test.rs b/lvc/src/bin/test.rs new file mode 100644 index 0000000..0f630d3 --- /dev/null +++ b/lvc/src/bin/test.rs @@ -0,0 +1,46 @@ +#[cfg(test)] +mod test { + + use lvc::huff::{read_huffman, write_huffman, BitIO}; + use std::io::Cursor; + + #[test] + fn test_bitio() { + let mut buf = Vec::<u8>::new(); + + { + let mut b = BitIO::new(Cursor::new(&mut buf)); + b.wbit(true).unwrap(); + b.wbit(true).unwrap(); + b.wbit(true).unwrap(); + b.wbit(true).unwrap(); + b.wbit(false).unwrap(); + b.wbit(true).unwrap(); + b.wbit(true).unwrap(); + b.wbit(true).unwrap(); + b.wbit(true).unwrap(); + b.flush().unwrap(); + } + { + let mut b = BitIO::new(Cursor::new(&mut buf)); + for _ in 0..9 { + eprintln!("{:?}", b.rbit().unwrap()) + } + } + } + + #[test] + fn test_huff() { + let a = vec![1; 10000]; + let mut b = vec![]; + + let mut buf = Vec::<u8>::new(); + write_huffman(&a, &mut Cursor::new(&mut buf)).unwrap(); + eprintln!("out {buf:x?}"); + read_huffman(&mut Cursor::new(&mut buf), &mut b).unwrap(); + + assert_eq!(a, b) + } +} + +fn main() {} |