mirror of
https://codeberg.org/icewind/vdf-reader.git
synced 2026-06-03 18:14:07 +02:00
allow deserializing from Entry
This commit is contained in:
parent
6643822671
commit
ebb940847d
12 changed files with 973 additions and 8 deletions
|
|
@ -4,7 +4,7 @@ use std::collections::BTreeMap;
|
|||
use std::fs::read_to_string;
|
||||
use test_case::test_case;
|
||||
use vdf_reader::entry::Table;
|
||||
use vdf_reader::from_str;
|
||||
use vdf_reader::{from_entry, from_str};
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize)]
|
||||
enum Expected {
|
||||
|
|
@ -197,7 +197,9 @@ fn test_serde(path: &str) {
|
|||
fn test_serde_table(path: &str) {
|
||||
let raw = read_to_string(path).unwrap();
|
||||
match from_str::<Table>(&raw) {
|
||||
Ok(result) => insta::assert_ron_snapshot!(format!("table__{}", path), result),
|
||||
Ok(result) => {
|
||||
insta::assert_ron_snapshot!(format!("table__{}", path), result);
|
||||
}
|
||||
Err(e) => {
|
||||
let handler = GraphicalReportHandler::new_themed(GraphicalTheme::unicode_nocolor());
|
||||
let mut out = String::new();
|
||||
|
|
@ -206,3 +208,15 @@ fn test_serde_table(path: &str) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[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")]
|
||||
fn test_serde_from_table(path: &str) {
|
||||
let raw = read_to_string(path).unwrap();
|
||||
let result = Table::load_from_str(&raw).unwrap();
|
||||
|
||||
let material: Expected = from_entry(result.into()).expect("table to material");
|
||||
insta::assert_ron_snapshot!(format!("table_to_material__{}", path), material);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue