parsers: add xso test module
Separate from the macro_tests module because it doesn't actually test macros, it uses it as a convenience. Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
parent
b1f4c5521d
commit
e493ffc6fb
2 changed files with 30 additions and 0 deletions
|
@ -10,3 +10,5 @@ mod macros;
|
|||
|
||||
#[cfg(test)]
|
||||
mod macro_tests;
|
||||
#[cfg(test)]
|
||||
mod xso_tests;
|
||||
|
|
28
parsers/src/util/xso_tests.rs
Normal file
28
parsers/src/util/xso_tests.rs
Normal file
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) 2024 Maxime “pep” Buquet <pep@bouah.net>
|
||||
//
|
||||
// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
use xso::{AsXml, FromXml, PrintRawXml};
|
||||
|
||||
static NS1: &str = "urn:example:ns1";
|
||||
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = NS1, name = "text")]
|
||||
struct TextString {
|
||||
#[xml(text)]
|
||||
text: String,
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn printrawxml() {
|
||||
let text = TextString {
|
||||
text: String::from("hello world"),
|
||||
};
|
||||
let display = format!("{}", PrintRawXml(&text));
|
||||
assert_eq!(
|
||||
display,
|
||||
"b\"<text xmlns='urn:example:ns1'>hello world</text>\""
|
||||
);
|
||||
}
|
Loading…
Reference in a new issue