xso: reject duplicate children
This was an oversight. Even though we apparently don't have tests for this anywhere, it is what the old functional macros do.
This commit is contained in:
parent
7f5b6fec7f
commit
6440209f95
5 changed files with 92 additions and 1 deletions
|
|
@ -522,6 +522,19 @@ fn parent_positive() {
|
|||
assert_eq!(v.child.foo, "hello world!");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parent_negative_duplicate_child() {
|
||||
#[allow(unused_imports)]
|
||||
use std::{
|
||||
option::Option::{None, Some},
|
||||
result::Result::{Err, Ok},
|
||||
};
|
||||
match parse_str::<Parent>("<parent xmlns='urn:example:ns1'><attr foo='hello world!'/><attr foo='hello world!'/></parent>") {
|
||||
Err(::xso::error::FromElementError::Invalid(::xso::error::Error::Other(e))) if e.contains("must not have more than one") => (),
|
||||
other => panic!("unexpected result: {:?}", other),
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
||||
#[xml(namespace = NS1, name = "parent")]
|
||||
struct OptionalChild {
|
||||
|
|
|
|||
Loading…
Reference in a new issue