From 2d18d295b8933b4a83bdbd819c8ece218566e999 Mon Sep 17 00:00:00 2001 From: Marrub Date: Mon, 4 Mar 2019 09:10:38 -0500 Subject: [PATCH] reorganize tests --- tests/clut.rs | 12 ------------ tests/epnt.rs | 14 ------------- tests/machdr.rs | 14 ------------- tests/map.rs | 52 +++++++++++++++++++++++++++++++++++++++++++++++++ tests/minf.rs | 18 ----------------- tests/misc.rs | 23 ++++++++++++++++++++++ tests/term.rs | 27 ------------------------- 7 files changed, 75 insertions(+), 85 deletions(-) delete mode 100644 tests/clut.rs delete mode 100644 tests/epnt.rs delete mode 100644 tests/machdr.rs create mode 100644 tests/map.rs delete mode 100644 tests/minf.rs create mode 100644 tests/misc.rs delete mode 100644 tests/term.rs diff --git a/tests/clut.rs b/tests/clut.rs deleted file mode 100644 index f86942a..0000000 --- a/tests/clut.rs +++ /dev/null @@ -1,12 +0,0 @@ -use maraiah::{durandal::image::*, marathon::pict::get_clut}; - -#[test] -fn get_clut_must_process_this() -{ - assert_eq!(get_clut(INPUT).unwrap(), (OUTPUT.to_vec(), 2056)); -} - -const INPUT: &'static [u8] = include_bytes!("data/clut.in"); -const OUTPUT: [Color8; 256] = include!("data/clut.out"); - -// EOF diff --git a/tests/epnt.rs b/tests/epnt.rs deleted file mode 100644 index 60bb59b..0000000 --- a/tests/epnt.rs +++ /dev/null @@ -1,14 +0,0 @@ -use maraiah::{durandal::{bin, fixed::*}, - marathon::map}; - -#[test] -fn read_epnt_must_process_this() -{ - assert_eq!(bin::rd_array(INPUT, map::read_epnt).unwrap(), - OUTPUT.to_vec()); -} - -const INPUT: &'static [u8] = include_bytes!("data/epnt.in"); -const OUTPUT: [map::Point; 54] = include!("data/epnt.out"); - -// EOF diff --git a/tests/machdr.rs b/tests/machdr.rs deleted file mode 100644 index 4af5a0e..0000000 --- a/tests/machdr.rs +++ /dev/null @@ -1,14 +0,0 @@ -use maraiah::marathon::machdr::*; - -// TODO: missing test data for applesingle - -#[test] -fn macbin_must_process_this() -{ - assert_eq!(check_macbin(INPUT_MACBIN), Some(128)); - assert_eq!(try_mac_header(INPUT_MACBIN), 128); -} - -const INPUT_MACBIN: &'static [u8] = include_bytes!("data/macbin.in"); - -// EOF diff --git a/tests/map.rs b/tests/map.rs new file mode 100644 index 0000000..9f7cd39 --- /dev/null +++ b/tests/map.rs @@ -0,0 +1,52 @@ +use maraiah::{durandal::{bin, fixed::*}, marathon::{map, trm}}; + +#[test] +fn read_term_must_process() +{ + const INPUT: &[u8] = include_bytes!("data/term.in"); + + let inp = bin::rd_array(INPUT, trm::read_term).unwrap(); + let out = include!("data/term.out"); + + // for better debug output, we iterate over each item + assert_eq!(inp.len(), out.len()); + + for (itrm, otrm) in inp.iter().zip(&out) { + assert_eq!(itrm.groups.len(), otrm.groups.len()); + for (igrp, ogrp) in itrm.groups.iter().zip(&otrm.groups) { + assert_eq!(igrp, ogrp); + } + + assert_eq!(itrm.faces.len(), otrm.faces.len()); + for (ifac, ofac) in itrm.faces.iter().zip(&otrm.faces) { + assert_eq!(ifac, ofac); + } + } +} + +#[test] +fn read_minf_must_process() +{ + const INPUT: &[u8] = include_bytes!("data/minf.in"); + + let out = map::Minf{env_code: 0, + physi_id: 1, + music_id: 1, + missi_flags: map::MsnFlags::Repair, + envir_flags: map::EnvFlags::empty(), + entry_flags: map::EntFlags::Solo | map::EntFlags::CoOp, + level_name: "Waterloo Waterpark".to_string()}; + + assert_eq!(map::read_minf(INPUT).unwrap(), out); +} + +#[test] +fn read_epnt_must_process() +{ + const INPUT: &[u8] = include_bytes!("data/epnt.in"); + const OUTPUT: [map::Point; 54] = include!("data/epnt.out"); + + assert_eq!(bin::rd_array(INPUT, map::read_epnt).unwrap(), OUTPUT.to_vec()); +} + +// EOF diff --git a/tests/minf.rs b/tests/minf.rs deleted file mode 100644 index c22347c..0000000 --- a/tests/minf.rs +++ /dev/null @@ -1,18 +0,0 @@ -use maraiah::marathon::map; - -#[test] -fn read_minf_must_process_map0() -{ - assert_eq!(map::read_minf(INPUT).unwrap(), - map::Minf{env_code: 0, - physi_id: 1, - music_id: 1, - missi_flags: map::MsnFlags::Repair, - envir_flags: map::EnvFlags::empty(), - entry_flags: map::EntFlags::Solo | map::EntFlags::CoOp, - level_name: "Waterloo Waterpark".to_string()}); -} - -const INPUT: &'static [u8] = include_bytes!("data/minf.in"); - -// EOF diff --git a/tests/misc.rs b/tests/misc.rs new file mode 100644 index 0000000..62944d4 --- /dev/null +++ b/tests/misc.rs @@ -0,0 +1,23 @@ +use maraiah::{durandal::image::Color8, marathon::{machdr, pict}}; + +#[test] +fn get_clut_must_process_this() +{ + 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] +fn macbin_must_process_this() +{ + const INPUT: &[u8] = include_bytes!("data/macbin.in"); + + assert_eq!(machdr::check_macbin(INPUT), Some(128)); + assert_eq!(machdr::try_mac_header(INPUT), 128); +} + +// TODO: missing test data for applesingle + +// EOF diff --git a/tests/term.rs b/tests/term.rs deleted file mode 100644 index 47e0516..0000000 --- a/tests/term.rs +++ /dev/null @@ -1,27 +0,0 @@ -use maraiah::{durandal::bin, marathon::trm}; - -#[test] -fn read_term_must_process_map0() -{ - let inp = bin::rd_array(INPUT, trm::read_term).unwrap(); - let out = include!("data/term.out"); - - // for better debug output, we iterate over each item - assert_eq!(inp.len(), out.len()); - - for (itrm, otrm) in inp.iter().zip(&out) { - assert_eq!(itrm.groups.len(), otrm.groups.len()); - for (igrp, ogrp) in itrm.groups.iter().zip(&otrm.groups) { - assert_eq!(igrp, ogrp); - } - - assert_eq!(itrm.faces.len(), otrm.faces.len()); - for (ifac, ofac) in itrm.faces.iter().zip(&otrm.faces) { - assert_eq!(ifac, ofac); - } - } -} - -const INPUT: &'static [u8] = include_bytes!("data/term.in"); - -// EOF