mirror of
https://codeberg.org/icewind/vdf-reader.git
synced 2026-06-03 10:04:08 +02:00
add support for deserializing a map with int keys as a sequence
This commit is contained in:
parent
1a37f7e866
commit
b928f85df6
14 changed files with 226 additions and 9 deletions
6
tests/data/maparray.vdf
Normal file
6
tests/data/maparray.vdf
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
"MapArray"
|
||||
{
|
||||
"0" "foo"
|
||||
"1" "bar"
|
||||
"2" "asd"
|
||||
}
|
||||
6
tests/errors/invalidmaparraykeys.vdf
Normal file
6
tests/errors/invalidmaparraykeys.vdf
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
"MapArray"
|
||||
{
|
||||
"0" "foo"
|
||||
"1" "bar"
|
||||
"3" "asd"
|
||||
}
|
||||
|
|
@ -69,6 +69,7 @@ enum Expected {
|
|||
EnumInMap {
|
||||
foo: EnumInMap,
|
||||
},
|
||||
MapArray(Vec<String>),
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
|
|
@ -211,6 +212,8 @@ struct GameList {
|
|||
#[test_case("tests/errors/concrete.vmt")]
|
||||
#[test_case("tests/errors/novalue.vdf")]
|
||||
#[test_case("tests/errors/serde_array_type.vdf")]
|
||||
#[test_case("tests/data/maparray.vdf")]
|
||||
#[test_case("tests/errors/invalidmaparraykeys.vdf")]
|
||||
fn test_serde(path: &str) {
|
||||
let raw = read_to_string(path).unwrap();
|
||||
match from_str::<Expected>(&raw) {
|
||||
|
|
@ -228,6 +231,7 @@ fn test_serde(path: &str) {
|
|||
#[test_case("tests/data/concrete.vmt")]
|
||||
#[test_case("tests/data/DialogConfigOverlay_1280x720.vdf")]
|
||||
#[test_case("tests/data/serde_array_type.vdf")]
|
||||
#[test_case("tests/data/maparray.vdf")]
|
||||
fn test_serde_table(path: &str) {
|
||||
let raw = read_to_string(path).unwrap();
|
||||
match from_str::<Table>(&raw) {
|
||||
|
|
@ -247,6 +251,7 @@ fn test_serde_table(path: &str) {
|
|||
#[test_case("tests/data/messy.vdf")]
|
||||
#[test_case("tests/data/DialogConfigOverlay_1280x720.vdf")]
|
||||
#[test_case("tests/data/serde_array_type.vdf")]
|
||||
#[test_case("tests/data/maparray.vdf")]
|
||||
fn test_serde_from_table(path: &str) {
|
||||
let raw = read_to_string(path).unwrap();
|
||||
let result = Table::load_from_str(&raw).unwrap();
|
||||
|
|
|
|||
11
tests/snapshots/serde__table__tests__data__maparray.vdf.snap
Normal file
11
tests/snapshots/serde__table__tests__data__maparray.vdf.snap
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
---
|
||||
source: tests/serde.rs
|
||||
expression: result
|
||||
---
|
||||
{
|
||||
"MapArray": {
|
||||
"0": "foo",
|
||||
"1": "bar",
|
||||
"2": "asd",
|
||||
},
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
source: tests/serde.rs
|
||||
expression: material
|
||||
---
|
||||
MapArray([
|
||||
"foo",
|
||||
"bar",
|
||||
"asd",
|
||||
])
|
||||
9
tests/snapshots/serde__tests__data__maparray.vdf.snap
Normal file
9
tests/snapshots/serde__tests__data__maparray.vdf.snap
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
---
|
||||
source: tests/serde.rs
|
||||
expression: result
|
||||
---
|
||||
MapArray([
|
||||
"foo",
|
||||
"bar",
|
||||
"asd",
|
||||
])
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
---
|
||||
source: tests/serde.rs
|
||||
expression: out
|
||||
---
|
||||
vmt_reader::unexpected_token
|
||||
|
||||
× Invalid array key 3, expected 2
|
||||
╭─[5:3]
|
||||
4 │ "1" "bar"
|
||||
5 │ "3" "asd"
|
||||
· ─┬─
|
||||
· ╰── Invalid array key 3, expected 2
|
||||
6 │ }
|
||||
╰────
|
||||
|
|
@ -4,11 +4,10 @@ expression: out
|
|||
---
|
||||
vmt_parser::unknown_variant
|
||||
|
||||
× Unknown variant "Resource" expected on of expected on of Types, LightmappedGeneric, Resource/specificPanel.res, UserConfigData, Sprite, EnumInMap
|
||||
× Unknown variant "Resource" expected on of expected on of Types, LightmappedGeneric, Resource/specificPanel.res, UserConfigData, Sprite, EnumInMap, MapArray
|
||||
╭─[1:1]
|
||||
1 │ "Resource"
|
||||
· ─────┬────
|
||||
· ╰── expected on of Types, LightmappedGeneric, Resource/specificPanel.res, UserConfigData, Sprite, EnumInMap
|
||||
· ╰── expected on of Types, LightmappedGeneric, Resource/specificPanel.res, UserConfigData, Sprite, EnumInMap, MapArray
|
||||
2 │ {
|
||||
╰────
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue