mirror of
https://codeberg.org/icewind/vdf-reader.git
synced 2026-06-03 18:14:07 +02:00
serde error testing
This commit is contained in:
parent
85ad728ac8
commit
778696590a
5 changed files with 56 additions and 2 deletions
11
tests/errors/concrete.vmt
Normal file
11
tests/errors/concrete.vmt
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
"LightmappedGeneric"
|
||||||
|
{
|
||||||
|
"$baseTexture" "cp_mountainlab/concrete/concretefloor003"
|
||||||
|
"$bumpmap" "concrete/concretefloor007b_height-ssbump"
|
||||||
|
"$ssbump" "2"
|
||||||
|
"%keywords" "tf"
|
||||||
|
"$detail" "overlays/detail001"
|
||||||
|
"$detailscale" "1.9"
|
||||||
|
"$detailblendmode" "0"
|
||||||
|
"$detailblendfactor" "1"
|
||||||
|
}
|
||||||
4
tests/errors/novalue.vdf
Normal file
4
tests/errors/novalue.vdf
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
"Resource/specificPanel.res"
|
||||||
|
{
|
||||||
|
foo
|
||||||
|
}
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
use miette::{GraphicalReportHandler, GraphicalTheme};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::fs::read_to_string;
|
use std::fs::read_to_string;
|
||||||
|
|
@ -151,8 +152,17 @@ struct GameList {
|
||||||
#[test_case("tests/data/concrete.vmt")]
|
#[test_case("tests/data/concrete.vmt")]
|
||||||
#[test_case("tests/data/messy.vdf")]
|
#[test_case("tests/data/messy.vdf")]
|
||||||
#[test_case("tests/data/DialogConfigOverlay_1280x720.vdf")]
|
#[test_case("tests/data/DialogConfigOverlay_1280x720.vdf")]
|
||||||
|
#[test_case("tests/errors/concrete.vmt")]
|
||||||
|
#[test_case("tests/errors/novalue.vdf")]
|
||||||
fn test_serde(path: &str) {
|
fn test_serde(path: &str) {
|
||||||
let raw = read_to_string(path).unwrap();
|
let raw = read_to_string(path).unwrap();
|
||||||
let result: Expected = from_str(&raw).map_err(miette::Error::from).unwrap();
|
match from_str::<Expected>(&raw) {
|
||||||
insta::assert_ron_snapshot!(path, result);
|
Ok(result) => insta::assert_ron_snapshot!(path, result),
|
||||||
|
Err(e) => {
|
||||||
|
let handler = GraphicalReportHandler::new_themed(GraphicalTheme::unicode_nocolor());
|
||||||
|
let mut out = String::new();
|
||||||
|
handler.render_report(&mut out, &e).unwrap();
|
||||||
|
insta::assert_snapshot!(path, out)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
15
tests/snapshots/serde__tests__errors__concrete.vmt.snap
Normal file
15
tests/snapshots/serde__tests__errors__concrete.vmt.snap
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
source: tests/serde.rs
|
||||||
|
expression: out
|
||||||
|
---
|
||||||
|
vmt_parser::parse_serde
|
||||||
|
|
||||||
|
× Can't parse "2" as bool
|
||||||
|
╭─[4:1]
|
||||||
|
4 │ "$bumpmap" "concrete/concretefloor007b_height-ssbump"
|
||||||
|
5 │ "$ssbump" "2"
|
||||||
|
· ─┬─
|
||||||
|
· ╰── Expected a bool
|
||||||
|
6 │ "%keywords" "tf"
|
||||||
|
╰────
|
||||||
|
|
||||||
14
tests/snapshots/serde__tests__errors__novalue.vdf.snap
Normal file
14
tests/snapshots/serde__tests__errors__novalue.vdf.snap
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
---
|
||||||
|
source: tests/serde.rs
|
||||||
|
expression: out
|
||||||
|
---
|
||||||
|
vmt_reader::unexpected_token
|
||||||
|
|
||||||
|
× Unexpected token, found end of group expected one of item, quoted item, statement, quoted statement, start of group
|
||||||
|
╭─[3:1]
|
||||||
|
3 │ foo
|
||||||
|
4 │ }
|
||||||
|
· ┬
|
||||||
|
· ╰── Expected item, quoted item, statement, quoted statement, start of group
|
||||||
|
╰────
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue