/*

University of Edinburgh XML 1.0 4th edition errata test suite.

*/

#[cfg(all(test, feature = "test-conformance-xml"))]
use std::fs;
#[cfg(all(test, feature = "test-conformance-xml"))]
use chadpath::item::Node;
#[cfg(all(test, feature = "test-conformance-xml"))]
use chadpath::parser::{ParseError, xml};
#[cfg(all(test, feature = "test-conformance-xml"))]
use chadpath::trees::smite::RNode;

#[cfg(all(test, feature = "test-conformance-xml"))]
fn test_eduni_errata4e_error(xmldoc: &str) {
    let testxml = RNode::new_document();
    let parseresult = xml::parse(
        testxml,
        xmldoc,
        Some(|_: &_| Err(ParseError::MissingNameSpace)),
    );

    assert!(parseresult.is_err());
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn invalidbo7() {
    /*
        Test ID:invalid-bo-7
        Test URI:inclbomboom_be.xml
        Spec Sections:4.3.3
        Description:A byte order mark and a backwards one in general entity cause an illegal char. error (big-endian)
    */
    test_eduni_errata4e_error(
        fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/inclbomboom_be.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn invalidbo8() {
    /*
        Test ID:invalid-bo-8
        Test URI:inclbomboom_le.xml
        Spec Sections:4.3.3
        Description:A byte order mark and a backwards one in general entity cause an illegal char. error (little-endian)
    */
    test_eduni_errata4e_error(
        fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/inclbomboom_le.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn invalidbo9() {
    /*
        Test ID:invalid-bo-9
        Test URI:incl8bomboom.xml
        Spec Sections:4.3.3
        Description:A byte order mark and a backwards one in general entity cause an illegal char. error (utf-8)
    */
    test_eduni_errata4e_error(
        fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/incl8bomboom.xml")
            .unwrap()
            .as_str(),
    );
}

/*
#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn xrmt008() {
    /*
        This test is deliberately ignored.
        In 5th edition, any document number other than 1.1 is treated as a 1.0 document.
    */
    /*
        Test ID:x-rmt-008
        Test URI:008.xml
        Spec Sections:2.8 4.3.4
        Description:a document with version=1.7, illegal in XML 1.0 through 4th edition
    */
    test_eduni_errata4e_error(
        fs::read_to_string("tests/conformance/xml/xmlconf/eduni/errata-4e/008.xml")
            .unwrap()
            .as_str());
}
*/
