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

finish api changes and rawpacketstream

This commit is contained in:
Robin Appelman 2019-12-22 16:50:31 +01:00
commit 2306fa5d17
7 changed files with 74 additions and 14 deletions

View file

@ -118,8 +118,9 @@ impl MessageHandler for EntityDumper {
fn entity_test(input_file: &str, snapshot_file: &str) {
let file = fs::read(input_file).expect("Unable to read file");
let demo = Demo::new(file);
let (_, entities) =
DemoParser::new_with_analyser(demo.get_stream(), EntityDumper::new()).unwrap();
let (_, entities) = DemoParser::new_with_analyser(demo.get_stream(), EntityDumper::new())
.parse()
.unwrap();
let json_file = File::open(snapshot_file).expect("Unable to read file");
let mut reader = BufReader::new(json_file);

View file

@ -46,6 +46,7 @@ fn flatten_test(input_file: &str, snapshot_file: &str) {
let demo = Demo::new(file);
let (_, send_tables) =
DemoParser::new_with_analyser(demo.get_stream(), SendPropAnalyser::new())
.parse()
.expect("Failed to parse");
let flat_props: HashMap<SendTableName, Vec<String>> = send_tables
.iter()

View file

@ -7,7 +7,7 @@ use tf_demo_parser::{Demo, DemoParser, MatchState, MessageType, MessageTypeAnaly
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 (_, state) = DemoParser::new(demo.get_stream()).unwrap();
let (_, state) = DemoParser::new(demo.get_stream()).parse().unwrap();
let expected: MatchState = serde_json::from_slice(
fs::read(snapshot_file)
@ -22,7 +22,9 @@ fn test_message_types(input_file: &str, snapshot_file: &str) {
let file = fs::read(input_file).expect("Unable to read file");
let demo = Demo::new(file);
let (_, message_types) =
DemoParser::new_with_analyser(demo.get_stream(), MessageTypeAnalyser::default()).unwrap();
DemoParser::new_with_analyser(demo.get_stream(), MessageTypeAnalyser::default())
.parse()
.unwrap();
let expected: Vec<MessageType> = serde_json::from_slice(
fs::read(snapshot_file)
@ -36,8 +38,9 @@ fn test_message_types(input_file: &str, snapshot_file: &str) {
fn game_state_test(input_file: &str, snapshot_file: &str) {
let file = fs::read(input_file).expect("Unable to read file");
let demo = Demo::new(file);
let (_, state) =
DemoParser::new_with_analyser(demo.get_stream(), GameStateAnalyser::new()).unwrap();
let (_, state) = DemoParser::new_with_analyser(demo.get_stream(), GameStateAnalyser::new())
.parse()
.unwrap();
let expected: GameState = serde_json::from_slice(
fs::read(snapshot_file)