use maraiah::{durandal::{bin, fixed::*}, marathon::map};

include!("data/rand.rs");

#[test]
fn read_minf_must_process()
{
   const INPUT: &[u8] = include_bytes!("data/map/minf.in");

   let out = map::Minf{texture_id: 0,
                       physics_id: 1,
                       skypict_id: 1,
                       miss_flags: map::MsnFlags::REPAIR,
                       envi_flags: map::EnvFlags::empty(),
                       entr_flags: map::EntFlags::SOLO | map::EntFlags::CO_OP,
                       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/map/epnt.in");
   const OUTPUT: [map::Point; 54] = include!("data/map/epnt.out");

   assert_eq!(bin::rd_array(INPUT, map::read_epnt).unwrap(), OUTPUT.to_vec());
}

#[test]
fn map_must_not_process()
{
   for inp in &RANDOM {
      assert!(map::read_minf(inp).is_err());
      assert!(map::read_old_minf(inp).is_err());
      assert!(bin::rd_array(inp, map::read_lins).is_err());
      assert!(bin::rd_array(inp, map::read_lite).is_err());
      assert!(bin::rd_array(inp, map::read_medi).is_err());
      assert!(bin::rd_array(inp, map::read_note).is_err());
      assert!(bin::rd_array(inp, map::read_objs).is_err());
      assert!(bin::rd_array(inp, map::read_plat).is_err());
      assert!(bin::rd_array(inp, map::read_poly).is_err());
      assert!(bin::rd_array(inp, map::read_sids).is_err());
      assert!(bin::rd_array(inp, map::read_old_lite).is_err());
      assert!(bin::rd_array(inp, map::read_old_poly).is_err());
      assert!(bin::rd_array(inp, map::read_old_sids).is_err());
   }
}

#[test]
#[allow(unused_must_use)]
fn map_must_not_panic()
{
   for inp in &RANDOM {
      bin::rd_array(inp, map::read_ambi);
      bin::rd_array(inp, map::read_bonk);
      bin::rd_array(inp, map::read_epnt);
      bin::rd_array(inp, map::read_iidx);
      bin::rd_array(inp, map::read_plac);
   }
}

// EOF
