diff --git a/parsers/src/util/mod.rs b/parsers/src/util/mod.rs index 20591702..8b07cfbd 100644 --- a/parsers/src/util/mod.rs +++ b/parsers/src/util/mod.rs @@ -10,3 +10,5 @@ mod macros; #[cfg(test)] mod macro_tests; +#[cfg(test)] +mod xso_tests; diff --git a/parsers/src/util/xso_tests.rs b/parsers/src/util/xso_tests.rs new file mode 100644 index 00000000..e6de7f61 --- /dev/null +++ b/parsers/src/util/xso_tests.rs @@ -0,0 +1,28 @@ +// Copyright (c) 2024 Maxime “pep” Buquet +// +// 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\"hello world\"" + ); +}