mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
tests: add namespace inheritance tests
This commit is contained in:
parent
db3c4e43e3
commit
77bc215cba
1 changed files with 47 additions and 0 deletions
47
src/tests.rs
47
src/tests.rs
|
@ -149,3 +149,50 @@ fn wrongly_closed_elements_error() {
|
||||||
let elem1 = "<a><c><d/></c></a>".parse::<Element>();
|
let elem1 = "<a><c><d/></c></a>".parse::<Element>();
|
||||||
assert!(elem1.is_ok());
|
assert!(elem1.is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn namespace_simple() {
|
||||||
|
let elem: Element = "<message xmlns='jabber:client'/>".parse().unwrap();
|
||||||
|
assert_eq!(elem.name(), "message");
|
||||||
|
assert_eq!(elem.ns(), Some("jabber:client"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn namespace_prefixed() {
|
||||||
|
let elem: Element = "<stream:features xmlns:stream='http://etherx.jabber.org/streams'/>"
|
||||||
|
.parse().unwrap();
|
||||||
|
assert_eq!(elem.name(), "features");
|
||||||
|
assert_eq!(elem.ns(), Some("http://etherx.jabber.org/streams"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn namespace_inherited_simple() {
|
||||||
|
let elem: Element = "<stream xmlns='jabber:client'><message/></stream>".parse().unwrap();
|
||||||
|
assert_eq!(elem.name(), "stream");
|
||||||
|
assert_eq!(elem.ns(), Some("jabber:client"));
|
||||||
|
let child = elem.children().next().unwrap();
|
||||||
|
assert_eq!(child.name(), "message");
|
||||||
|
assert_eq!(child.ns(), Some("jabber:client"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn namespace_inherited_prefixed1() {
|
||||||
|
let elem: Element = "<stream:features xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client'><message/></stream>"
|
||||||
|
.parse().unwrap();
|
||||||
|
assert_eq!(elem.name(), "features");
|
||||||
|
assert_eq!(elem.ns(), Some("http://etherx.jabber.org/streams"));
|
||||||
|
let child = elem.children().next().unwrap();
|
||||||
|
assert_eq!(child.name(), "message");
|
||||||
|
assert_eq!(child.ns(), Some("jabber:client"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn namespace_inherited_prefixed2() {
|
||||||
|
let elem: Element = "<stream xmlns='http://etherx.jabber.org/streams' xmlns:jabber='jabber:client'><jabber:message/></stream>"
|
||||||
|
.parse().unwrap();
|
||||||
|
assert_eq!(elem.name(), "stream");
|
||||||
|
assert_eq!(elem.ns(), Some("http://etherx.jabber.org/streams"));
|
||||||
|
let child = elem.children().next().unwrap();
|
||||||
|
assert_eq!(child.name(), "message");
|
||||||
|
assert_eq!(child.ns(), Some("jabber:client"));
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue