-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #657 from Mingun/reorganize-tests
Split serde-de tests into several files and add new serde-se tests
- Loading branch information
Showing
9 changed files
with
6,140 additions
and
5,639 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
//! Utility functions for integration tests | ||
|
||
use quick_xml::de::Deserializer; | ||
use quick_xml::DeError; | ||
use serde::Deserialize; | ||
|
||
/// Deserialize an instance of type T from a string of XML text. | ||
/// If deserialization was succeeded checks that all XML events was consumed | ||
pub fn from_str<'de, T>(source: &'de str) -> Result<T, DeError> | ||
where | ||
T: Deserialize<'de>, | ||
{ | ||
// Log XML that we try to deserialize to see it in the failed tests output | ||
dbg!(source); | ||
let mut de = Deserializer::from_str(source); | ||
let result = T::deserialize(&mut de); | ||
|
||
// If type was deserialized, the whole XML document should be consumed | ||
if let Ok(_) = result { | ||
match <()>::deserialize(&mut de) { | ||
Err(DeError::UnexpectedEof) => (), | ||
e => panic!("Expected end `UnexpectedEof`, but got {:?}", e), | ||
} | ||
} | ||
|
||
result | ||
} |
Oops, something went wrong.