use maraiah::{durandal::bin, marathon::trm};

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

#[test]
fn read_term_must_process()
{
   const INPUT: &[u8] = include_bytes!("data/trm/term.in");

   let inp = bin::rd_array(INPUT, trm::read_term).unwrap();
   let out = include!("data/trm/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 trm_must_not_process()
{
   for inp in &RANDOM {
      assert!(bin::rd_array(inp, trm::read_group).is_err());
      assert!(bin::rd_array(inp, trm::read_term).is_err());
   }
}

#[test]
#[allow(unused_must_use)]
fn trm_must_not_panic()
{
   for inp in &RANDOM {
      bin::rd_array(inp, trm::read_face);
   }
}

// EOF
