caco 0.5.33

library for dealing with doom [et al] wad files
Documentation
use std::fs::File;

use crate::{agnostic::*, wad::QuakePack};

// while this is technically fine, it copies the name of another function
// doesn't matter :p -nf
fn quake() -> QuakePack {
    QuakePack::load(&mut File::open("wads-for-tests/pak0.pak").unwrap()).unwrap()
}

// using pk to differentiate for now
#[test]
fn pk_lmp_amt() {
    let qk = quake();
    assert_eq!(qk.clump_amt(), 1071);
}

#[test]
fn pk_num1() {
    let qk = quake();
    assert_eq!(qk.nth_clump(1).name, "demo2.dem");
}

#[test]
fn pk_num1_reverse() {
    let qk = quake();
    assert_eq!(qk.which_clumps("demo2.dem")[0], 1);
}

#[test]
fn pk_nonexistant_lump() {
    let qk = quake();
    assert!(qk.clump_by_name("REALLYLONGNAME").is_none());
}

#[test]
fn pk_save_out() {
    let qk = quake();
    qk.save(&mut File::create("wads-for-tests/pak0-resaved.wad").unwrap()).unwrap();
    
    // attempt reopen (surely it'll break if it saves incorrectly?)
    // rlly good idea! -nyxf
    let qk_reload = QuakePack::load(&mut File::open("wads-for-tests/pak0-resaved.wad").unwrap()).unwrap();

    // changing this to a static search, equality operator isn't implemented yet?
    assert_eq!(qk_reload.nth_clump(0), qk.nth_clump(0));
}