xso-proc: provide FromXml::xml_name_matcher on derived impls
That way, derived implementations can also make use of the performance benefits.
This commit is contained in:
parent
126588b47d
commit
59af49c691
5 changed files with 166 additions and 3 deletions
|
|
@ -94,6 +94,14 @@ fn empty_roundtrip() {
|
|||
roundtrip_full::<Empty>("<foo xmlns='urn:example:ns1'/>");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_xml_name_matcher_is_specific() {
|
||||
assert_eq!(
|
||||
Empty::xml_name_matcher(),
|
||||
xso::fromxml::XmlNameMatcher::Specific(NS1, "foo")
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn empty_name_mismatch() {
|
||||
#[allow(unused_imports)]
|
||||
|
|
@ -717,6 +725,14 @@ enum NameSwitchedEnum {
|
|||
},
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn name_switched_enum_matcher_is_in_namespace() {
|
||||
assert_eq!(
|
||||
NameSwitchedEnum::xml_name_matcher(),
|
||||
xso::fromxml::XmlNameMatcher::InNamespace(NS1)
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn name_switched_enum_positive_variant_1() {
|
||||
#[allow(unused_imports)]
|
||||
|
|
@ -1844,6 +1860,14 @@ enum DynamicEnum {
|
|||
},
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dynamic_enum_matcher_is_any() {
|
||||
assert_eq!(
|
||||
DynamicEnum::xml_name_matcher(),
|
||||
xso::fromxml::XmlNameMatcher::Any
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dynamic_enum_roundtrip_a() {
|
||||
#[allow(unused_imports)]
|
||||
|
|
@ -1903,6 +1927,27 @@ fn fallible_parse_positive_err() {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml()]
|
||||
enum DynamicEnumWithSharedNamespace {
|
||||
#[xml(transparent)]
|
||||
A(RequiredAttribute),
|
||||
|
||||
#[xml(namespace = NS1, name = "b")]
|
||||
B {
|
||||
#[xml(text)]
|
||||
contents: String,
|
||||
},
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dynamic_enum_with_shared_namespace_matcher_is_in_namespace() {
|
||||
assert_eq!(
|
||||
DynamicEnumWithSharedNamespace::xml_name_matcher(),
|
||||
xso::fromxml::XmlNameMatcher::InNamespace(NS1)
|
||||
);
|
||||
}
|
||||
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = NS1, name = "parent")]
|
||||
struct ExtractTupleToCollection {
|
||||
|
|
|
|||
Loading…
Reference in a new issue