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

fix tempentities for protocol version 23

This commit is contained in:
Robin Appelman 2021-07-23 17:20:04 +02:00
commit 3055242fd9
10 changed files with 85 additions and 65 deletions

View file

@ -4,46 +4,44 @@ use test_case::test_case;
use tf_demo_parser::demo::parser::gamestateanalyser::{GameState, GameStateAnalyser};
use tf_demo_parser::{Demo, DemoParser, MatchState};
#[test_case("test_data/small.dem", "test_data/small.json"; "small.dem")]
#[test_case("test_data/gully.dem", "test_data/gully.json"; "gully.dem")]
#[test_case("test_data/comp.dem", "test_data/comp.json"; "comp.dem")]
#[test_case("test_data/malformed_cvar.dem", "test_data/malformed_cvar.json"; "malformed_cvar.dem")]
#[test_case("test_data/unicode-saytext.dem", "test_data/unicode-saytext.json"; "unicode-saytext.dem")]
#[test_case("test_data/nousers.dem", "test_data/nousers.json"; "nousers.dem")]
#[test_case("test_data/decal.dem", "test_data/decal.json"; "decal.dem")]
#[test_case("test_data/saytext2.dem", "test_data/saytext2.json"; "saytext2.dem")]
#[test_case("test_data/emptysaytext.dem", "test_data/emptysaytext.json"; "emptysaytext.dem")]
#[test_case("small.dem", "small.json"; "small.dem")]
#[test_case("gully.dem", "gully.json"; "gully.dem")]
#[test_case("comp.dem", "comp.json"; "comp.dem")]
#[test_case("malformed_cvar.dem", "malformed_cvar.json"; "malformed_cvar.dem")]
#[test_case("unicode-saytext.dem", "unicode-saytext.json"; "unicode-saytext.dem")]
#[test_case("nousers.dem", "nousers.json"; "nousers.dem")]
#[test_case("decal.dem", "decal.json"; "decal.dem")]
#[test_case("saytext2.dem", "saytext2.json"; "saytext2.dem")]
#[test_case("emptysaytext.dem", "emptysaytext.json"; "emptysaytext.dem")]
#[test_case("protocol23.dem", "protocol23.json"; "protocol23.dem")]
fn snapshot_test(input_file: &str, snapshot_file: &str) {
let file = fs::read(input_file).expect("Unable to read file");
let file = fs::read(format!("test_data/{}", input_file)).expect("Unable to read file");
let demo = Demo::new(&file);
let (_, state) = DemoParser::new(demo.get_stream()).parse().unwrap();
let expected: MatchState = serde_json::from_slice(
fs::read(snapshot_file)
fs::read(format!("test_data/{}", snapshot_file))
.expect("Unable to read file")
.as_slice(),
)
.unwrap();
pretty_assertions::assert_eq!(expected.start_tick, state.start_tick);
pretty_assertions::assert_eq!(expected.chat, state.chat);
pretty_assertions::assert_eq!(expected.deaths, state.deaths);
pretty_assertions::assert_eq!(expected.interval_per_tick, state.interval_per_tick);
pretty_assertions::assert_eq!(expected.rounds, state.rounds);
pretty_assertions::assert_eq!(expected.users, state.users);
pretty_assertions::assert_eq!(expected, state);
let (_, state) = DemoParser::new_all(demo.get_stream()).parse().unwrap();
pretty_assertions::assert_eq!(expected, state);
}
#[test_case("test_data/small.dem", "test_data/small_game_state.json"; "small.dem")]
#[test_case("test_data/gully.dem", "test_data/gully_game_state.json"; "gully.dem")]
#[test_case("small.dem", "small_game_state.json"; "small.dem")]
#[test_case("gully.dem", "gully_game_state.json"; "gully.dem")]
fn game_state_test(input_file: &str, snapshot_file: &str) {
let file = fs::read(input_file).expect("Unable to read file");
let file = fs::read(format!("test_data/{}", input_file)).expect("Unable to read file");
let demo = Demo::new(&file);
let (_, state) = DemoParser::new_with_analyser(demo.get_stream(), GameStateAnalyser::new())
.parse()
.unwrap();
let expected: GameState = serde_json::from_slice(
fs::read(snapshot_file)
fs::read(format!("test_data/{}", snapshot_file))
.expect("Unable to read file")
.as_slice(),
)