mirror of
https://github.com/eigenein/wotbreplay-parser.git
synced 2026-10-21 02:17:02 +02:00
Opt: move the test to README.md
This commit is contained in:
1 parent
5786253cd5
commit
96e63f81f4
2 files changed
+29
-20
No files matched your search
@@ -8,6 +8,35 @@ World of Tanks Blitz replay parser in Rust.
|
||||

|
||||
[](https://docs.rs/wotbreplay-parser)
|
||||
|
||||
## Quickstart
|
||||
|
||||
```rust
|
||||
use std::fs::File;
|
||||
|
||||
use anyhow::Result;
|
||||
use wotbreplay_parser::Replay;
|
||||
use wotbreplay_parser::models::TeamNumber;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let battle_results = Replay::open(File::open("tests/replays/battle_results_ok.wotbreplay")?)?
|
||||
.read_battle_results()?;
|
||||
|
||||
assert_eq!(battle_results.timestamp, 1670018359);
|
||||
assert_eq!(battle_results.players.len(), 14);
|
||||
|
||||
assert_eq!(battle_results.players[0].account_id, 520886428);
|
||||
assert_eq!(battle_results.players[0].info.nickname, "77mmmr");
|
||||
assert_eq!(battle_results.players[0].info.team_number(), TeamNumber::Two);
|
||||
assert_eq!(battle_results.players[0].info.platoon_id, None);
|
||||
|
||||
assert_eq!(battle_results.players[1].info.nickname, "SNAK_THE_RIPPER");
|
||||
assert_eq!(battle_results.players[1].info.team_number(), TeamNumber::One);
|
||||
assert_eq!(battle_results.players[1].info.platoon_id, Some(547466834));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
```
|
||||
|
||||
## Replay structure
|
||||
|
||||
`*.wotbreplay` is a ZIP-archive containing:
|
||||
|
||||
@@ -4,26 +4,6 @@ use anyhow::Result;
|
||||
use wotbreplay_parser::models::TeamNumber;
|
||||
use wotbreplay_parser::Replay;
|
||||
|
||||
#[test]
|
||||
fn battle_results_ok() -> Result<()> {
|
||||
let battle_results = Replay::open(File::open("tests/replays/battle_results_ok.wotbreplay")?)?
|
||||
.read_battle_results()?;
|
||||
|
||||
assert_eq!(battle_results.timestamp, 1670018359);
|
||||
assert_eq!(battle_results.players.len(), 14);
|
||||
|
||||
assert_eq!(battle_results.players[0].account_id, 520886428);
|
||||
assert_eq!(battle_results.players[0].info.nickname, "77mmmr");
|
||||
assert_eq!(battle_results.players[0].info.team_number(), TeamNumber::Two);
|
||||
assert_eq!(battle_results.players[0].info.platoon_id, None);
|
||||
|
||||
assert_eq!(battle_results.players[1].info.nickname, "SNAK_THE_RIPPER");
|
||||
assert_eq!(battle_results.players[1].info.team_number(), TeamNumber::One);
|
||||
assert_eq!(battle_results.players[1].info.platoon_id, Some(547466834));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn player_results_ok() -> Result<()> {
|
||||
let battle_results = Replay::open(File::open("tests/replays/player_results_ok.wotbreplay")?)?
|
||||
|
||||
Reference in new issue
Block a user