Skip to content

Commit

Permalink
Add melter test
Browse files Browse the repository at this point in the history
  • Loading branch information
nickbabcock committed Feb 1, 2024
1 parent 94f8161 commit ed211cc
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ fn test_ironman_roundtrip() -> Result<(), Box<dyn Error>> {
.on_failed_resolve(hoi4save::FailedResolveStrategy::Error)
.melt(&EnvTokens)?;

let melted_data = utils::request("1.10-ironman_melted.zip");
assert!(
eq(melted_data.as_slice(), out.data()),
"unexpected melted data"
);

let file = Hoi4File::from_slice(out.data())?;
let parsed_file = file.parse()?;
let save: Hoi4Save = parsed_file.deserializer(&EnvTokens).deserialize()?;
Expand All @@ -100,3 +106,13 @@ fn test_ironman_roundtrip() -> Result<(), Box<dyn Error>> {
);
Ok(())
}

fn eq(a: &[u8], b: &[u8]) -> bool {
for (ai, bi) in a.iter().zip(b.iter()) {
if ai != bi {
return false;
}
}

a.len() == b.len()
}

0 comments on commit ed211cc

Please sign in to comment.