mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
Put the tests in element.rs into a module block.
This commit is contained in:
parent
956dff3ad4
commit
fac64400f1
1 changed files with 78 additions and 74 deletions
|
@ -926,8 +926,11 @@ impl ElementBuilder {
|
|||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[test]
|
||||
fn test_element_new() {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_element_new() {
|
||||
use std::iter::FromIterator;
|
||||
|
||||
let elem = Element::new( "name".to_owned()
|
||||
|
@ -940,10 +943,10 @@ fn test_element_new() {
|
|||
assert_eq!(elem.ns(), Some("namespace".to_owned()));
|
||||
assert_eq!(elem.attr("name"), Some("value"));
|
||||
assert_eq!(elem.attr("inexistent"), None);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_reader_simple() {
|
||||
#[test]
|
||||
fn test_from_reader_simple() {
|
||||
let xml = "<foo></foo>";
|
||||
let mut reader = EventReader::from_str(xml);
|
||||
let elem = Element::from_reader(&mut reader);
|
||||
|
@ -951,10 +954,10 @@ fn test_from_reader_simple() {
|
|||
let elem2 = Element::builder("foo").build();
|
||||
|
||||
assert_eq!(elem.unwrap(), elem2);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_reader_nested() {
|
||||
#[test]
|
||||
fn test_from_reader_nested() {
|
||||
let xml = "<foo><bar baz='qxx' /></foo>";
|
||||
let mut reader = EventReader::from_str(xml);
|
||||
let elem = Element::from_reader(&mut reader);
|
||||
|
@ -967,10 +970,10 @@ fn test_from_reader_nested() {
|
|||
.build();
|
||||
|
||||
assert_eq!(elem.unwrap(), elem2);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_from_reader_with_prefix() {
|
||||
#[test]
|
||||
fn test_from_reader_with_prefix() {
|
||||
let xml = "<foo><prefix:bar baz='qxx' /></foo>";
|
||||
let mut reader = EventReader::from_str(xml);
|
||||
let elem = Element::from_reader(&mut reader);
|
||||
|
@ -983,10 +986,10 @@ fn test_from_reader_with_prefix() {
|
|||
.build();
|
||||
|
||||
assert_eq!(elem.unwrap(), elem2);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_spectest_xml() { // From: https://gitlab.com/lumi/minidom-rs/issues/8
|
||||
#[test]
|
||||
fn parses_spectest_xml() { // From: https://gitlab.com/lumi/minidom-rs/issues/8
|
||||
let xml = r#"
|
||||
<rng:grammar xmlns:rng="http://relaxng.org/ns/structure/1.0">
|
||||
<rng:name xmlns:rng="http://relaxng.org/ns/structure/1.0"></rng:name>
|
||||
|
@ -994,12 +997,13 @@ fn parses_spectest_xml() { // From: https://gitlab.com/lumi/minidom-rs/issues/8
|
|||
"#;
|
||||
let mut reader = EventReader::from_str(xml);
|
||||
let _ = Element::from_reader(&mut reader).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn does_not_unescape_cdata() {
|
||||
#[test]
|
||||
fn does_not_unescape_cdata() {
|
||||
let xml = "<test><![CDATA['>blah<blah>]]></test>";
|
||||
let mut reader = EventReader::from_str(xml);
|
||||
let elem = Element::from_reader(&mut reader).unwrap();
|
||||
assert_eq!(elem.text(), "'>blah<blah>");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue