mirror of
https://github.com/G2-Games/lbee-utils.git
synced 2025-04-19 07:12:55 -05:00
Added round-trip testing
This commit is contained in:
parent
e9963afa4d
commit
d972dc0161
5 changed files with 268 additions and 0 deletions
51
cz/tests/round_trip.rs
Normal file
51
cz/tests/round_trip.rs
Normal file
|
@ -0,0 +1,51 @@
|
|||
use std::io::Cursor;
|
||||
|
||||
use cz::{common::CzVersion, DynamicCz};
|
||||
|
||||
const KODIM03: (u16, u16, &[u8]) = (128, 128, include_bytes!("test_images/kodim03.rgba"));
|
||||
const KODIM23: (u16, u16, &[u8]) = (225, 225, include_bytes!("test_images/kodim23.rgba"));
|
||||
const SQPTEXT: (u16, u16, &[u8]) = (2048, 810, include_bytes!("test_images/sqp_text.rgba"));
|
||||
const DPFLOGO: (u16, u16, &[u8]) = (1123, 639, include_bytes!("test_images/dpf_logo.rgba"));
|
||||
|
||||
type TestImage = (u16, u16, &'static [u8]);
|
||||
const TEST_IMAGES: &[TestImage] = &[KODIM03, KODIM23, SQPTEXT, DPFLOGO];
|
||||
|
||||
#[test]
|
||||
fn cz0_round_trip() {
|
||||
for image in TEST_IMAGES {
|
||||
let original_cz = DynamicCz::from_raw(
|
||||
CzVersion::CZ0,
|
||||
image.0,
|
||||
image.1,
|
||||
image.2.to_vec()
|
||||
);
|
||||
|
||||
let mut cz_bytes = Vec::new();
|
||||
original_cz.encode(&mut cz_bytes).unwrap();
|
||||
|
||||
let mut cz_bytes = Cursor::new(cz_bytes);
|
||||
let decoded_cz = DynamicCz::decode(&mut cz_bytes).unwrap();
|
||||
|
||||
assert_eq!(original_cz.as_raw(), decoded_cz.as_raw());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cz1_round_trip() {
|
||||
for image in TEST_IMAGES {
|
||||
let original_cz = DynamicCz::from_raw(
|
||||
CzVersion::CZ1,
|
||||
image.0,
|
||||
image.1,
|
||||
image.2.to_vec()
|
||||
);
|
||||
|
||||
let mut cz_bytes = Vec::new();
|
||||
original_cz.encode(&mut cz_bytes).unwrap();
|
||||
|
||||
let mut cz_bytes = Cursor::new(cz_bytes);
|
||||
let decoded_cz = DynamicCz::decode(&mut cz_bytes).unwrap();
|
||||
|
||||
assert_eq!(original_cz.as_raw(), decoded_cz.as_raw());
|
||||
}
|
||||
}
|
BIN
cz/tests/test_images/dpf_logo.rgba
Normal file
BIN
cz/tests/test_images/dpf_logo.rgba
Normal file
Binary file not shown.
216
cz/tests/test_images/kodim03.rgba
Normal file
216
cz/tests/test_images/kodim03.rgba
Normal file
File diff suppressed because one or more lines are too long
1
cz/tests/test_images/kodim23.rgba
Normal file
1
cz/tests/test_images/kodim23.rgba
Normal file
File diff suppressed because one or more lines are too long
BIN
cz/tests/test_images/sqp_text.rgba
Normal file
BIN
cz/tests/test_images/sqp_text.rgba
Normal file
Binary file not shown.
Loading…
Reference in a new issue