Skip to content
This repository was archived by the owner on May 30, 2022. It is now read-only.

Commit cffbdde

Browse files
committed
Add negative trivial tests
We should ensure, that incorrect input do not deserializing into object. That could influence untagged enums because thy rely on deserialization failures when selects right variant failures (38): trivial::struct_::cdata::byte_buf trivial::struct_::cdata::char_ trivial::struct_::cdata::f32_ trivial::struct_::cdata::f64_ trivial::struct_::cdata::false_ trivial::struct_::cdata::i128_ trivial::struct_::cdata::i16_ trivial::struct_::cdata::i32_ trivial::struct_::cdata::i64_ trivial::struct_::cdata::i8_ trivial::struct_::cdata::isize_ trivial::struct_::cdata::string trivial::struct_::cdata::true_ trivial::struct_::cdata::u128_ trivial::struct_::cdata::u16_ trivial::struct_::cdata::u32_ trivial::struct_::cdata::u64_ trivial::struct_::cdata::u8_ trivial::struct_::cdata::usize_ trivial::struct_::text::byte_buf trivial::struct_::text::char_ trivial::struct_::text::f32_ trivial::struct_::text::f64_ trivial::struct_::text::false_ trivial::struct_::text::i128_ trivial::struct_::text::i16_ trivial::struct_::text::i32_ trivial::struct_::text::i64_ trivial::struct_::text::i8_ trivial::struct_::text::isize_ trivial::struct_::text::string trivial::struct_::text::true_ trivial::struct_::text::u128_ trivial::struct_::text::u16_ trivial::struct_::text::u32_ trivial::struct_::text::u64_ trivial::struct_::text::u8_ trivial::struct_::text::usize_
1 parent ae5f2fc commit cffbdde

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

Changelog.md

+5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@
2626
|`DeError::EndOfAttributes`|Renamed to `DeError::KeyNotFound`
2727
|`DeError::ExpectedStart`|Added
2828

29+
### New Tests
30+
31+
- [#9]: Added tests for incorrect nested tags in input
32+
2933
[#8]: https://github.com/Mingun/fast-xml/pull/8
34+
[#9]: https://github.com/Mingun/fast-xml/pull/9
3035

3136
## 0.23.0 -- 2022-05-08
3237

tests/serde-de.rs

+9
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,15 @@ mod trivial {
316316
let item: Trivial<$type> = from_str($value).unwrap();
317317

318318
assert_eq!(item, Trivial { value: $expected });
319+
320+
match from_str::<Trivial<$type>>(&format!("<outer>{}</outer>", $value)) {
321+
// Expected unexpected start element `<root>`
322+
Err(DeError::UnexpectedStart(tag)) => assert_eq!(tag, b"root"),
323+
x => panic!(
324+
r#"Expected `Err(DeError::UnexpectedStart("root"))`, but got `{:?}`"#,
325+
x
326+
),
327+
}
319328
}
320329
};
321330
}

0 commit comments

Comments
 (0)