mirror of
https://codeberg.org/icewind/vdf-reader.git
synced 2026-06-03 10:04:08 +02:00
boxed arrays
This commit is contained in:
parent
778696590a
commit
d54e44b51d
7 changed files with 143 additions and 6 deletions
5
tests/data/serde_array_type.vdf
Normal file
5
tests/data/serde_array_type.vdf
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"Types" {
|
||||
fixed_array "[1 2 3]"
|
||||
flex_array "[1.0 2.2]"
|
||||
tuple "[1 57]"
|
||||
}
|
||||
5
tests/errors/serde_array_type.vdf
Normal file
5
tests/errors/serde_array_type.vdf
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
"Types" {
|
||||
fixed_array "[1 2 3.1]"
|
||||
flex_array "[1.0 2.2]"
|
||||
tuple "[1 57]"
|
||||
}
|
||||
|
|
@ -7,6 +7,11 @@ use vdf_reader::from_str;
|
|||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
enum Expected {
|
||||
Types {
|
||||
fixed_array: [u8; 3],
|
||||
flex_array: Vec<f32>,
|
||||
tuple: (bool, u8),
|
||||
},
|
||||
LightmappedGeneric {
|
||||
#[serde(rename = "$baseTexture")]
|
||||
base_texture: String,
|
||||
|
|
@ -152,8 +157,10 @@ struct GameList {
|
|||
#[test_case("tests/data/concrete.vmt")]
|
||||
#[test_case("tests/data/messy.vdf")]
|
||||
#[test_case("tests/data/DialogConfigOverlay_1280x720.vdf")]
|
||||
#[test_case("tests/data/serde_array_type.vdf")]
|
||||
#[test_case("tests/errors/concrete.vmt")]
|
||||
#[test_case("tests/errors/novalue.vdf")]
|
||||
#[test_case("tests/errors/serde_array_type.vdf")]
|
||||
fn test_serde(path: &str) {
|
||||
let raw = read_to_string(path).unwrap();
|
||||
match from_str::<Expected>(&raw) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,12 @@
|
|||
---
|
||||
source: tests/serde.rs
|
||||
expression: result
|
||||
---
|
||||
Types(
|
||||
fixed_array: (1, 2, 3),
|
||||
flex_array: [
|
||||
1.0,
|
||||
2.2,
|
||||
],
|
||||
tuple: (true, 57),
|
||||
)
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
source: tests/serde.rs
|
||||
expression: out
|
||||
---
|
||||
vmt_parser::parse_serde
|
||||
|
||||
× Can't parse "3.1" as u8
|
||||
╭─[1:1]
|
||||
1 │ "Types" {
|
||||
2 │ fixed_array "[1 2 3.1]"
|
||||
· ─┬─
|
||||
· ╰── Expected a u8
|
||||
3 │ flex_array "[1.0 2.2]"
|
||||
╰────
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue