#[cfg(all(test, feature = "test-conformance-xml"))]
use std::fs;
#[cfg(all(test, feature = "test-conformance-xml"))]
use xrust::item::Node;
#[cfg(all(test, feature = "test-conformance-xml"))]
use xrust::parser::{ParseError, ParserStateBuilder, StaticStateBuilder, xml};
#[cfg(all(test, feature = "test-conformance-xml"))]
use xrust::trees::smite::RNode;
#[cfg(all(test, feature = "test-conformance-xml"))]
use xrust::validators::Schema;
#[cfg(all(test, feature = "test-conformance-xml"))]
use xrust::{Error, ErrorKind};
#[cfg(all(test, feature = "test-conformance-xml"))]
fn test_eduni_errata2e_invalid(xmldoc: &str) {
let ss = StaticStateBuilder::new()
.dtd_resolver(dtdfileresolve())
.namespace(|_: &_| Err(ParseError::MissingNameSpace))
.build();
let testxml = RNode::new_document();
let ps = ParserStateBuilder::new()
.doc(testxml)
.document_location("tests/conformance/xml/xmlconf/eduni/errata-2e/".to_string())
.build();
let parseresult = xml::parse_with_state(xmldoc, ps, ss);
assert!(parseresult.is_ok());
let doc = parseresult.unwrap();
let validation = doc.validate(Schema::DTD);
assert!(validation.is_err());
}
#[cfg(all(test, feature = "test-conformance-xml"))]
pub fn dtdfileresolve() -> fn(Option<String>, String) -> Result<String, Error> {
move |locdir, uri| {
let u = match locdir {
None => uri,
Some(ld) => ld + uri.as_str(),
};
match fs::read_to_string(u) {
Err(_) => Err(Error::new(
ErrorKind::Unknown,
"Unable to read external DTD".to_string(),
)),
Ok(s) => Ok(s),
}
}
}
#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn rmte2e2a() {
test_eduni_errata2e_invalid(
fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E2a.xml")
.unwrap()
.as_str(),
);
}
#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn rmte2e2b() {
test_eduni_errata2e_invalid(
fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E2b.xml")
.unwrap()
.as_str(),
);
}
#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn rmte2e9b() {
test_eduni_errata2e_invalid(
fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E9b.xml")
.unwrap()
.as_str(),
);
}
#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn rmte2e14() {
test_eduni_errata2e_invalid(
fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E14.xml")
.unwrap()
.as_str(),
);
}
#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn rmte2e15a() {
test_eduni_errata2e_invalid(
fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15a.xml")
.unwrap()
.as_str(),
);
}
#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn rmte2e15b() {
test_eduni_errata2e_invalid(
fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15b.xml")
.unwrap()
.as_str(),
);
}
#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn rmte2e15c() {
test_eduni_errata2e_invalid(
fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15c.xml")
.unwrap()
.as_str(),
);
}
#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn rmte2e15d() {
test_eduni_errata2e_invalid(
fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15d.xml")
.unwrap()
.as_str(),
);
}
#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn rmte2e15g() {
test_eduni_errata2e_invalid(
fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15g.xml")
.unwrap()
.as_str(),
);
}
#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn rmte2e15h() {
test_eduni_errata2e_invalid(
fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E15h.xml")
.unwrap()
.as_str(),
);
}
#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn rmte2e20() {
test_eduni_errata2e_invalid(
fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-2e/E20.xml")
.unwrap()
.as_str(),
);
}