diff --git a/tests/reader-namespaces.rs b/tests/reader-namespaces.rs
index 4c4e5581..764b585a 100644
--- a/tests/reader-namespaces.rs
+++ b/tests/reader-namespaces.rs
@@ -238,6 +238,146 @@ mod default_namespace {
vec![(PrefixDeclaration::Default, Namespace(b"www1"))]
);
}
+
+ #[test]
+ fn shadowing_empty() {
+ let src = "";
+
+ let mut r = NsReader::from_str(src);
+
+ //
+ {
+ match r.read_resolved_event() {
+ Ok((ns, Start(e))) => {
+ assert_eq!(ns, Bound(Namespace(b"urn:example:o")));
+ assert_eq!(e.name(), QName(b"e"));
+ }
+ e => panic!("Expected Start event (), got {:?}", e),
+ }
+
+ let it = r.prefixes();
+ assert_eq!(it.size_hint(), (0, Some(1)));
+ assert_eq!(
+ it.collect::>(),
+ vec![(PrefixDeclaration::Default, Namespace(b"urn:example:o"))]
+ );
+ }
+
+ //
+ {
+ let e = match r.read_resolved_event() {
+ Ok((ns, Empty(e))) => {
+ assert_eq!(ns, Bound(Namespace(b"urn:example:i")));
+ assert_eq!(e.name(), QName(b"e"));
+ e
+ }
+ e => panic!("Expecting Empty event, got {:?}", e),
+ };
+
+ let mut attrs = e
+ .attributes()
+ .map(|ar| ar.expect("Expecting attribute parsing to succeed."))
+ // we don't care about xmlns attributes for this test
+ .filter(|kv| kv.key.as_namespace_binding().is_none())
+ .map(|Attribute { key: name, value }| {
+ let (opt_ns, local_name) = r.resolve_attribute(name);
+ (opt_ns, local_name.into_inner(), value)
+ });
+ // the attribute should _not_ have a namespace name. The default namespace does not
+ // apply to attributes.
+ assert_eq!(
+ attrs.next(),
+ Some((Unbound, &b"att1"[..], Cow::Borrowed(&b"a"[..])))
+ );
+ assert_eq!(attrs.next(), None);
+
+ let it = r.prefixes();
+ assert_eq!(it.size_hint(), (0, Some(2)));
+ assert_eq!(
+ it.collect::>(),
+ vec![(PrefixDeclaration::Default, Namespace(b"urn:example:i")),]
+ );
+ }
+
+ //
+ match r.read_resolved_event() {
+ Ok((ns, End(e))) => {
+ assert_eq!(ns, Bound(Namespace(b"urn:example:o")));
+ assert_eq!(e.name(), QName(b"e"));
+ }
+ e => panic!("Expected End event (), got {:?}", e),
+ }
+ let it = r.prefixes();
+ assert_eq!(it.size_hint(), (0, Some(1)));
+ assert_eq!(
+ it.collect::>(),
+ vec![(PrefixDeclaration::Default, Namespace(b"urn:example:o"))]
+ );
+ }
+
+ #[test]
+ fn shadowing_expanded() {
+ let src = "";
+
+ let mut r = NsReader::from_str(src);
+ r.config_mut().expand_empty_elements = true;
+
+ //
+ {
+ match r.read_resolved_event() {
+ Ok((ns, Start(e))) => {
+ assert_eq!(ns, Bound(Namespace(b"urn:example:o")));
+ assert_eq!(e.name(), QName(b"e"));
+ }
+ e => panic!("Expected Start event (), got {:?}", e),
+ }
+ }
+
+ //
+ {
+ let e = match r.read_resolved_event() {
+ Ok((ns, Start(e))) => {
+ assert_eq!(ns, Bound(Namespace(b"urn:example:i")));
+ assert_eq!(e.name(), QName(b"e"));
+ e
+ }
+ e => panic!("Expecting Start event (), got {:?}", e),
+ };
+ let mut attrs = e
+ .attributes()
+ .map(|ar| ar.expect("Expecting attribute parsing to succeed."))
+ // we don't care about xmlns attributes for this test
+ .filter(|kv| kv.key.as_namespace_binding().is_none())
+ .map(|Attribute { key: name, value }| {
+ let (opt_ns, local_name) = r.resolve_attribute(name);
+ (opt_ns, local_name.into_inner(), value)
+ });
+ // the attribute should _not_ have a namespace name. The default namespace does not
+ // apply to attributes.
+ assert_eq!(
+ attrs.next(),
+ Some((Unbound, &b"att1"[..], Cow::Borrowed(&b"a"[..])))
+ );
+ assert_eq!(attrs.next(), None);
+ }
+
+ // virtual
+ match r.read_resolved_event() {
+ Ok((ns, End(e))) => {
+ assert_eq!(ns, Bound(Namespace(b"urn:example:i")));
+ assert_eq!(e.name(), QName(b"e"));
+ }
+ e => panic!("Expected End event (), got {:?}", e),
+ }
+ //
+ match r.read_resolved_event() {
+ Ok((ns, End(e))) => {
+ assert_eq!(ns, Bound(Namespace(b"urn:example:o")));
+ assert_eq!(e.name(), QName(b"e"));
+ }
+ e => panic!("Expected End event (), got {:?}", e),
+ }
+ }
}
/// Single empty element with qualified attributes.
@@ -337,146 +477,6 @@ fn attributes_empty_ns_expanded() {
}
}
-#[test]
-fn default_ns_shadowing_empty() {
- let src = "";
-
- let mut r = NsReader::from_str(src);
-
- //
- {
- match r.read_resolved_event() {
- Ok((ns, Start(e))) => {
- assert_eq!(ns, Bound(Namespace(b"urn:example:o")));
- assert_eq!(e.name(), QName(b"e"));
- }
- e => panic!("Expected Start event (), got {:?}", e),
- }
-
- let it = r.prefixes();
- assert_eq!(it.size_hint(), (0, Some(1)));
- assert_eq!(
- it.collect::>(),
- vec![(PrefixDeclaration::Default, Namespace(b"urn:example:o"))]
- );
- }
-
- //
- {
- let e = match r.read_resolved_event() {
- Ok((ns, Empty(e))) => {
- assert_eq!(ns, Bound(Namespace(b"urn:example:i")));
- assert_eq!(e.name(), QName(b"e"));
- e
- }
- e => panic!("Expecting Empty event, got {:?}", e),
- };
-
- let mut attrs = e
- .attributes()
- .map(|ar| ar.expect("Expecting attribute parsing to succeed."))
- // we don't care about xmlns attributes for this test
- .filter(|kv| kv.key.as_namespace_binding().is_none())
- .map(|Attribute { key: name, value }| {
- let (opt_ns, local_name) = r.resolve_attribute(name);
- (opt_ns, local_name.into_inner(), value)
- });
- // the attribute should _not_ have a namespace name. The default namespace does not
- // apply to attributes.
- assert_eq!(
- attrs.next(),
- Some((Unbound, &b"att1"[..], Cow::Borrowed(&b"a"[..])))
- );
- assert_eq!(attrs.next(), None);
-
- let it = r.prefixes();
- assert_eq!(it.size_hint(), (0, Some(2)));
- assert_eq!(
- it.collect::>(),
- vec![(PrefixDeclaration::Default, Namespace(b"urn:example:i")),]
- );
- }
-
- //
- match r.read_resolved_event() {
- Ok((ns, End(e))) => {
- assert_eq!(ns, Bound(Namespace(b"urn:example:o")));
- assert_eq!(e.name(), QName(b"e"));
- }
- e => panic!("Expected End event (), got {:?}", e),
- }
- let it = r.prefixes();
- assert_eq!(it.size_hint(), (0, Some(1)));
- assert_eq!(
- it.collect::>(),
- vec![(PrefixDeclaration::Default, Namespace(b"urn:example:o"))]
- );
-}
-
-#[test]
-fn default_ns_shadowing_expanded() {
- let src = "";
-
- let mut r = NsReader::from_str(src);
- r.config_mut().expand_empty_elements = true;
-
- //
- {
- match r.read_resolved_event() {
- Ok((ns, Start(e))) => {
- assert_eq!(ns, Bound(Namespace(b"urn:example:o")));
- assert_eq!(e.name(), QName(b"e"));
- }
- e => panic!("Expected Start event (), got {:?}", e),
- }
- }
-
- //
- {
- let e = match r.read_resolved_event() {
- Ok((ns, Start(e))) => {
- assert_eq!(ns, Bound(Namespace(b"urn:example:i")));
- assert_eq!(e.name(), QName(b"e"));
- e
- }
- e => panic!("Expecting Start event (), got {:?}", e),
- };
- let mut attrs = e
- .attributes()
- .map(|ar| ar.expect("Expecting attribute parsing to succeed."))
- // we don't care about xmlns attributes for this test
- .filter(|kv| kv.key.as_namespace_binding().is_none())
- .map(|Attribute { key: name, value }| {
- let (opt_ns, local_name) = r.resolve_attribute(name);
- (opt_ns, local_name.into_inner(), value)
- });
- // the attribute should _not_ have a namespace name. The default namespace does not
- // apply to attributes.
- assert_eq!(
- attrs.next(),
- Some((Unbound, &b"att1"[..], Cow::Borrowed(&b"a"[..])))
- );
- assert_eq!(attrs.next(), None);
- }
-
- // virtual
- match r.read_resolved_event() {
- Ok((ns, End(e))) => {
- assert_eq!(ns, Bound(Namespace(b"urn:example:i")));
- assert_eq!(e.name(), QName(b"e"));
- }
- e => panic!("Expected End event (), got {:?}", e),
- }
- //
- match r.read_resolved_event() {
- Ok((ns, End(e))) => {
- assert_eq!(ns, Bound(Namespace(b"urn:example:o")));
- assert_eq!(e.name(), QName(b"e"));
- }
- e => panic!("Expected End event (), got {:?}", e),
- }
-}
-
/// Although the XML specification [recommends against] the use of names where
/// the local name portion begins with the letters "xml" (case insensitive),
/// it also specifies, that processors *MUST NOT* treat them as fatal errors.