diff --git a/src/builder.rs b/src/builder.rs index 41dfd37..b189d50 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -169,7 +169,6 @@ impl Compressor { gain *= 8; } if gain > 0 { - // println!("pushing single: symbol = {symbol1:?} gain = {gain}"); pqueue.push(Candidate { symbol: symbol1, gain, @@ -186,13 +185,6 @@ impl Compressor { let new_symbol = symbol1.concat(symbol2); let gain = counters.count2(code1, code2) * new_symbol.len(); if gain > 0 { - // println!("pushing double: symbol = {new_symbol:?} gain = {gain}"); - // println!( - // "\tfirst-half gain = {} second-half gain = {}", - // counters.count1(code1), - // counters.count1(code2) - // ); - pqueue.push(Candidate { symbol: new_symbol, gain, @@ -272,13 +264,8 @@ impl Ord for Candidate { #[cfg(test)] mod test { - use crate::{Compressor, ESCAPE_CODE}; - #[test] - fn test_sadness() { - let compressor = Compressor::train_n("hello world", 1); - let _ = compressor.compress(&[1]); - } + use crate::{Compressor, ESCAPE_CODE}; #[test] fn test_builder() { diff --git a/tests/correctness.rs b/tests/correctness.rs index d557f06..5a68cb1 100644 --- a/tests/correctness.rs +++ b/tests/correctness.rs @@ -59,22 +59,17 @@ fn test_zeros() { #[test] fn test_large() { - let mut corpus = String::new(); - // TODO(aduffy): make this larger once table build performance is better. - while corpus.len() < 10 * 1_024 { - corpus.push_str(DECLARATION); - } + let corpus: Vec = DECLARATION.bytes().cycle().take(10_240).collect(); let trained = Compressor::train(&corpus); - let mut massive = String::new(); - while massive.len() < 16 * 1_024 * 1_024 { - massive.push_str(DECLARATION); - } - let compressed = trained.compress(massive.as_bytes()); - assert_eq!( - trained.decompressor().decompress(&compressed), - massive.as_bytes() - ); + let massive: Vec = DECLARATION + .bytes() + .cycle() + .take(16 * 1_024 * 1_024) + .collect(); + + let compressed = trained.compress(&massive); + assert_eq!(trained.decompressor().decompress(&compressed), massive); } #[test]