parsers: add xso test module
Some checks failed
Build / lint (push) Has been cancelled
Build / test-stable (push) Has been cancelled
Build / test-nightly (push) Has been cancelled

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:
Maxime “pep” Buquet 2024-11-21 20:41:56 +01:00
parent b1f4c5521d
commit e493ffc6fb
2 changed files with 30 additions and 0 deletions

View file

@ -10,3 +10,5 @@ mod macros;
#[cfg(test)]
mod macro_tests;
#[cfg(test)]
mod xso_tests;

View 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>\""
);
}