Skip to content

Commit

Permalink
Add tests to make sure syntax errors are not suppressed.
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmave126 authored and jonasbb committed Jul 12, 2024
1 parent 97543d0 commit 17dec11
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions serde_with/tests/hashbrown_0_14.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@ fn test_map_skip_error_hashmap() {
}
}"#,
);
check_error_deserialization::<S>(
r#"{"tag":"type", "values":{"0": 1,}}"#,
expect!["trailing comma at line 1 column 33"],
);
is_equal(
S {
tag: "round-trip".into(),
Expand Down
4 changes: 4 additions & 0 deletions serde_with/tests/indexmap_1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ fn test_map_skip_error_indexmap() {
}
}"#,
);
check_error_deserialization::<S>(
r#"{"tag":"type", "values":{"0": 1,}}"#,
expect!["trailing comma at line 1 column 33"],
);
is_equal(
S {
tag: "round-trip".into(),
Expand Down
4 changes: 4 additions & 0 deletions serde_with/tests/indexmap_2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ fn test_map_skip_error_indexmap() {
}
}"#,
);
check_error_deserialization::<S>(
r#"{"tag":"type", "values":{"0": 1,}}"#,
expect!["trailing comma at line 1 column 33"],
);
is_equal(
S {
tag: "round-trip".into(),
Expand Down
12 changes: 12 additions & 0 deletions serde_with/tests/serde_as/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,10 @@ fn test_vec_skip_error() {
},
r#"{"tag":"type","values":[0, "str", 1, [10, 11], -2, {}, 300]}"#,
);
check_error_deserialization::<S>(
r#"{"tag":"type", "values":[0, "str", 1, , 300]}"#,
expect!["expected value at line 1 column 39"],
);
is_equal(
S {
tag: "round-trip".into(),
Expand Down Expand Up @@ -618,6 +622,10 @@ fn test_map_skip_error_btreemap() {
}
}"#,
);
check_error_deserialization::<S>(
r#"{"tag":"type", "values":{"0": 1,}}"#,
expect!["trailing comma at line 1 column 33"],
);
is_equal(
S {
tag: "round-trip".into(),
Expand Down Expand Up @@ -706,6 +714,10 @@ fn test_map_skip_error_hashmap() {
}
}"#,
);
check_error_deserialization::<S>(
r#"{"tag":"type", "values":{"0": 1,}}"#,
expect!["trailing comma at line 1 column 33"],
);
is_equal(
S {
tag: "round-trip".into(),
Expand Down

0 comments on commit 17dec11

Please sign in to comment.