1
0
Fork 0
mirror of https://codeberg.org/demostf/parser.git synced 2026-06-03 10:14:06 +02:00

add basic snapshot testing

This commit is contained in:
Robin Appelman 2019-03-17 19:20:50 +01:00
commit 052ff398cd
15 changed files with 134 additions and 25 deletions

30
tests/tests.rs Normal file
View file

@ -0,0 +1,30 @@
use std::fs;
use pretty_assertions::assert_eq;
use tf_demo_parser::{Demo, DemoParser, Stream, MatchState};
fn snapshot_test(input_file: &str, snapshot_file: &str) {
let file = fs::read(input_file).expect("Unable to read file");
let demo = Demo::new(file);
let stream: Stream = demo.get_stream();
let parser = DemoParser::new(stream);
let (_, state) = parser.parse_demo().unwrap();
let expected: MatchState = serde_json::from_slice(fs::read(snapshot_file).expect("Unable to read file").as_slice()).unwrap();
assert_eq!(expected, state);
}
#[test]
fn snapshot_test_small() {
snapshot_test("data/small.dem", "data/small.json");
}
#[test]
fn snapshot_test_gully() {
snapshot_test("data/gully.dem", "data/gully.json");
}
#[test]
fn snapshot_test_comp() {
snapshot_test("data/comp.dem", "data/comp.json");
}