caco 0.5.33

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

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

fn quake() -> QuakeWad {
    QuakeWad::load(&mut File::open("wads-for-tests/gfx.wad").unwrap()).unwrap()
}

#[test]
fn qk_lmp_amt() {
    let qk = quake();
    assert_eq!(qk.clump_amt(), 163);
}

#[test]
fn qk_num1() {
    let qk = quake();
    assert_eq!(qk.nth_clump(2).name, "NUM_2");
}

#[test]
fn qk_num1_reverse() {
    let qk = quake();
    assert_eq!(qk.which_clumps("NUM_2")[0], 2);
}

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

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

    assert_eq!(qk_reload.nth_clump(0), qk.nth_clump(0));
}