Skip to content

Commit

Permalink
add test showing field reordering is supported
Browse files Browse the repository at this point in the history
  • Loading branch information
knickish committed Dec 31, 2023
1 parent f8c40d2 commit 5db53c3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@ fn de() {
assert_eq!(test.c, None);
}

#[test]
fn de_reorder() {
#[derive(DeJson)]
pub struct Test {
pub a: f32,
pub b: f32,
c: Option<String>,
d: Option<String>,
}

let json = r#"{
"a": 1,
"d": "hello",
"b": 2.0,
}"#;

let test: Test = DeJson::deserialize_json(json).unwrap();
assert_eq!(test.a, 1.);
assert_eq!(test.b, 2.);
assert_eq!(test.d.unwrap(), "hello");
assert_eq!(test.c, None);
}

#[test]
fn de_options() {
#[derive(DeJson)]
Expand Down

0 comments on commit 5db53c3

Please sign in to comment.