Skip to content

Commit

Permalink
add test for a simple frame encode/decode cycle
Browse files Browse the repository at this point in the history
  • Loading branch information
KillingSpark committed Oct 15, 2024
1 parent 5f0bd79 commit a4558e8
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/encoding/frame_encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,10 @@ impl<'input> FrameCompressor<'input> {

#[cfg(test)]
mod tests {
use alloc::vec;

use super::FrameCompressor;
use crate::frame::MAGIC_NUM;
use crate::{frame::MAGIC_NUM, FrameDecoder};
use alloc::vec::Vec;

#[test]
Expand All @@ -173,4 +175,18 @@ mod tests {
let mut output: Vec<u8> = Vec::new();
compressor.compress(&mut output);
}

#[test]
fn very_simple_compress() {
let mut mock_data = vec![0;1024];
mock_data.extend(vec![1;1024]);
let compressor = FrameCompressor::new(&mock_data, super::CompressionLevel::Fastest);
let mut output: Vec<u8> = Vec::new();
compressor.compress(&mut output);

let mut decoder = FrameDecoder::new();
let mut decoded = Vec::with_capacity(mock_data.len());
decoder.decode_all_to_vec(&output, &mut decoded).unwrap();
assert_eq!(mock_data, decoded);
}
}

0 comments on commit a4558e8

Please sign in to comment.