From 7e32f7b85d7b20633a71fee0771ade6d1030c6dc Mon Sep 17 00:00:00 2001 From: relrelb Date: Sat, 5 Feb 2022 15:59:35 +0200 Subject: [PATCH] xml: Remove `tests.rs` These are already covered by the SWF tests. --- core/src/xml.rs | 3 -- core/src/xml/tests.rs | 119 ------------------------------------------ 2 files changed, 122 deletions(-) delete mode 100644 core/src/xml/tests.rs diff --git a/core/src/xml.rs b/core/src/xml.rs index 3814c3f1e..b7874b67a 100644 --- a/core/src/xml.rs +++ b/core/src/xml.rs @@ -5,9 +5,6 @@ mod error; mod iterators; mod tree; -#[cfg(test)] -mod tests; - pub use document::XmlDocument; pub use error::Error; pub use error::ParseError; diff --git a/core/src/xml/tests.rs b/core/src/xml/tests.rs deleted file mode 100644 index b496ef91a..000000000 --- a/core/src/xml/tests.rs +++ /dev/null @@ -1,119 +0,0 @@ -//! XML tests - -use crate::string::WStr; -use crate::xml; -use crate::xml::XmlDocument; -use gc_arena::rootless_arena; - -/// Tests very basic parsing of a single-element document. -#[test] -fn parse_single_element() { - rootless_arena(|mc| { - let mut xml = XmlDocument::new(mc); - xml.replace_with_str(mc, WStr::from_units(b""), true, false) - .expect("Parsed document"); - let mut roots = xml.as_node().children(); - - let root = roots.next().expect("Parsed document should have a root"); - assert_eq!(root.node_type(), xml::ELEMENT_NODE); - assert_eq!(root.tag_name(), Some("test".into())); - - let mut root_children = root.children(); - assert!(root_children.next().is_none()); - - assert!(roots.next().is_none()); - }) -} - -/// Tests double-ended traversal of child nodes via DoubleEndedIterator. -#[test] -fn double_ended_children() { - rootless_arena(|mc| { - let mut xml = XmlDocument::new(mc); - xml.replace_with_str( - mc, - WStr::from_units( - b"", - ), - true, - false, - ) - .expect("Parsed document"); - - let mut roots = xml.as_node().children(); - - let root = roots.next().expect("Should have first root"); - assert_eq!(root.node_type(), xml::ELEMENT_NODE); - assert_eq!(root.tag_name(), Some("test".into())); - - let root = roots.next_back().expect("Should have last root"); - assert_eq!(root.node_type(), xml::ELEMENT_NODE); - assert_eq!(root.tag_name(), Some("test5".into())); - - let root = roots.next().expect("Should have next root"); - assert_eq!(root.node_type(), xml::ELEMENT_NODE); - assert_eq!(root.tag_name(), Some("test2".into())); - - let root = roots.next_back().expect("Should have second-to-last root"); - assert_eq!(root.node_type(), xml::ELEMENT_NODE); - assert_eq!(root.tag_name(), Some("test4".into())); - - let root = roots.next().expect("Should have next root"); - assert_eq!(root.node_type(), xml::ELEMENT_NODE); - assert_eq!(root.tag_name(), Some("test3".into())); - - assert!(roots.next().is_none()); - assert!(roots.next_back().is_none()); - }) -} - -/// Tests round-trip XML writing behavior. -#[test] -fn round_trip_tostring() { - let test_string = b"This is a text node"; - - rootless_arena(|mc| { - let mut xml = XmlDocument::new(mc); - xml.replace_with_str(mc, WStr::from_units(test_string), true, false) - .expect("Parsed document"); - - let result = xml.as_node().into_string().expect("Successful toString"); - - assert_eq!("This is a text node", result); - }) -} - -/// Tests ignoring whitespace nodes. -#[test] -fn ignore_white() { - rootless_arena(|mc| { - let mut xml = XmlDocument::new(mc); - xml.replace_with_str( - mc, - WStr::from_units(b" foo "), - true, - true, - ) - .expect("Parsed document"); - - let mut root = xml.as_node().children(); - - let mut node = root.next().expect("Should have root"); - assert_eq!(node.node_type(), xml::ELEMENT_NODE); - assert_eq!(node.tag_name(), Some("test".into())); - - node = node.children().next().expect("Should have children"); - assert_eq!(node.node_type(), xml::ELEMENT_NODE); - assert_eq!(node.tag_name(), Some("test2".into())); - - node = node.children().next().expect("Should have children"); - assert_eq!(node.node_type(), xml::ELEMENT_NODE); - assert_eq!(node.tag_name(), Some("test3".into())); - - node = node.children().next().expect("Should have text"); - assert_eq!(node.node_type(), xml::TEXT_NODE); - assert_eq!(node.node_value(), Some(" foo ".into())); - - assert!(root.next().is_none()); - }) -}