Skip to content
Snippets Groups Projects
Verified Commit 8a0d5bce authored by João Magalhães's avatar João Magalhães :rocket:
Browse files

chore: new unit test

parent b837b79a
No related branches found
No related tags found
1 merge request!54Major improved of zippy format
Pipeline #4798 passed
......@@ -134,6 +134,10 @@ impl Zippy {
self.crc32 == crc32(&self.data)
}
pub fn crc32(&self) -> u32 {
self.crc32
}
pub fn data(&self) -> &[u8] {
&self.data
}
......@@ -151,7 +155,7 @@ pub fn decode_zippy(data: &[u8], options: Option<ZippyOptions>) -> Result<Vec<u8
mod tests {
use boytacean_common::error::Error;
use super::{decode_zippy, Zippy};
use super::{decode_zippy, Zippy, ZippyOptions};
#[test]
fn test_build_and_encode() {
......@@ -194,6 +198,26 @@ mod tests {
assert!(zippy.check_crc32());
}
#[test]
fn test_no_crc32_zippy() {
let data = vec![1, 2, 3, 4, 5];
let name = String::from("Test");
let description = String::from("Test description");
let zippy = Zippy::build(
&data,
name.clone(),
description.clone(),
Some(ZippyOptions::new(false)),
)
.unwrap();
let encoded = zippy.encode().unwrap();
let zippy = Zippy::decode(&encoded, None).unwrap();
assert!(!zippy.check_crc32());
assert_eq!(zippy.crc32(), 0xffffffff);
}
#[test]
fn test_decode_invalid() {
let decoded_data = decode_zippy(b"invalid", None);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment