Maraiah/tests/misc.rs

44 lines
927 B
Rust
Raw Normal View History

2019-03-04 06:10:38 -08:00
use maraiah::{durandal::image::Color8, marathon::{machdr, pict}};
2019-03-04 18:55:49 -08:00
include!("data/rand.rs");
2019-03-04 06:10:38 -08:00
#[test]
2019-03-04 18:55:49 -08:00
fn get_clut_must_process()
2019-03-04 06:10:38 -08:00
{
const INPUT: &[u8] = include_bytes!("data/clut.in");
const OUTPUT: [Color8; 256] = include!("data/clut.out");
assert_eq!(pict::get_clut(INPUT).unwrap(), (OUTPUT.to_vec(), 2056));
}
#[test]
2019-03-04 18:55:49 -08:00
fn get_clut_must_not_process()
{
for inp in &RANDOM {
assert!(pict::get_clut(inp).is_err());
}
}
#[test]
fn machdr_must_process()
2019-03-04 06:10:38 -08:00
{
const INPUT: &[u8] = include_bytes!("data/macbin.in");
assert_eq!(machdr::check_macbin(INPUT), Some(128));
assert_eq!(machdr::try_mac_header(INPUT), 128);
2019-03-04 18:55:49 -08:00
// TODO: missing test data for applesingle
2019-03-04 06:10:38 -08:00
}
2019-03-04 18:55:49 -08:00
#[test]
fn machdr_must_not_process()
{
for inp in &RANDOM {
assert_eq!(machdr::check_macbin(inp), None);
assert_eq!(machdr::check_apple_single(inp), None);
assert_eq!(machdr::try_mac_header(inp), 0);
}
}
2019-03-04 06:10:38 -08:00
// EOF