/*

OASIS/NIST test cases

*/

#[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"))]
use chadpath::validators::Schema;

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

    assert!(parseresult.is_ok());

    let doc = parseresult.unwrap();
    let validation = doc.validate(Schema::DTD);
    assert!(validation.is_ok());
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op01pass2() {
    /*
        Test ID:o-p01pass2
        Test URI:p01pass2.xml
        Spec Sections:2.2 [1]
        Description:various Misc items where they can occur
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p01pass2.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op06pass1() {
    /*
        Test ID:o-p06pass1
        Test URI:p06pass1.xml
        Spec Sections:2.3 [6]
        Description:various satisfactions of the Names production in a NAMES attribute
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p06pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op07pass1() {
    /*
        Test ID:o-p07pass1
        Test URI:p07pass1.xml
        Spec Sections:2.3 [7]
        Description:various valid Nmtoken 's in an attribute list declaration.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p07pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op08pass1() {
    /*
        Test ID:o-p08pass1
        Test URI:p08pass1.xml
        Spec Sections:2.3 [8]
        Description:various satisfaction of an NMTOKENS attribute value.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p08pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op09pass1() {
    /*
        Test ID:o-p09pass1
        Test URI:p09pass1.xml
        Spec Sections:2.3 [9]
        Description:valid EntityValue's. Except for entity references, markup is not recognized.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p09pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op12pass1() {
    /*
        Test ID:o-p12pass1
        Test URI:p12pass1.xml
        Spec Sections:2.3 [12]
        Description:valid public IDs.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p12pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op22pass4() {
    /*
        Test ID:o-p22pass4
        Test URI:p22pass4.xml
        Spec Sections:2.8 [22]
        Description:XML decl and doctypedecl
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p22pass4.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op22pass5() {
    /*
        Test ID:o-p22pass5
        Test URI:p22pass5.xml
        Spec Sections:2.8 [22]
        Description:just doctypedecl
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p22pass5.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op22pass6() {
    /*
        Test ID:o-p22pass6
        Test URI:p22pass6.xml
        Spec Sections:2.8 [22]
        Description:S between decls is not required
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p22pass6.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op28pass1() {
    /*
        Test ID:o-p28pass1
        Test URI:p28pass1.xml
        Spec Sections:3.1 [43] [44]
        Description:Empty-element tag must be used for element which are declared EMPTY.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p28pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op28pass3() {
    /*
        Test ID:o-p28pass3
        Test URI:p28pass3.xml
        Spec Sections:2.8 4.1 [28] [69]
        Description:Valid doctypedecl with Parameter entity reference. The declaration of a parameter entity must precede any reference to it.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p28pass3.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op28pass4() {
    /*
        Test ID:o-p28pass4
        Test URI:p28pass4.xml
        Spec Sections:2.8 4.2.2 [28] [75]
        Description:Valid doctypedecl with ExternalID as an External Entity declaration.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p28pass4.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op28pass5() {
    /*
        Test ID:o-p28pass5
        Test URI:p28pass5.xml
        Spec Sections:2.8 4.1 [28] [69]
        Description:Valid doctypedecl with ExternalID as an External Entity. A parameter entity reference is also used.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p28pass5.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op29pass1() {
    /*
        Test ID:o-p29pass1
        Test URI:p29pass1.xml
        Spec Sections:2.8 [29]
        Description:Valid types of markupdecl.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p29pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op30pass1() {
    /*
        Test ID:o-p30pass1
        Test URI:p30pass1.xml
        Spec Sections:2.8 4.2.2 [30] [75]
        Description:Valid doctypedecl with ExternalID as an External Entity. The external entity has an element declaration.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p30pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op30pass2() {
    /*
        Test ID:o-p30pass2
        Test URI:p30pass2.xml
        Spec Sections:2.8 4.2.2 4.3.1 [30] [75] [77]
        Description:Valid doctypedecl with ExternalID as an Enternal Entity. The external entity begins with a Text Declaration.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p30pass2.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op31pass1() {
    /*
        Test ID:o-p31pass1
        Test URI:p31pass1.xml
        Spec Sections:2.8 [31]
        Description:external subset can be empty
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p31pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op31pass2() {
    /*
        Test ID:o-p31pass2
        Test URI:p31pass2.xml
        Spec Sections:2.8 3.4 4.2.2 [31] [62] [63] [75]
        Description:Valid doctypedecl with EXternalID as Enternal Entity. The external entity contains a parameter entity reference and condtional sections.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p31pass2.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op43pass1() {
    /*
        Test ID:o-p43pass1
        Test URI:p43pass1.xml
        Spec Sections:2.4 2.5 2.6 2.7 [15] [16] [18]
        Description:Valid use of character data, comments, processing instructions and CDATA sections within the start and end tag.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p43pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op45pass1() {
    /*
        Test ID:o-p45pass1
        Test URI:p45pass1.xml
        Spec Sections:3.2 [45]
        Description:valid element declarations
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p45pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op46pass1() {
    /*
        Test ID:o-p46pass1
        Test URI:p46pass1.xml
        Spec Sections:3.2 3.2.1 3.2.2 [45] [46] [47] [51]
        Description:Valid use of contentspec, element content models, and mixed content within an element type declaration.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p46pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op47pass1() {
    /*
        Test ID:o-p47pass1
        Test URI:p47pass1.xml
        Spec Sections:3.2 3.2.1 [45] [46] [47]
        Description:Valid use of contentspec, element content models, choices, sequences and content particles within an element type declaration. The optional character following a name or list governs the number of times the element or content particle may appear.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p47pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op48pass1() {
    /*
        Test ID:o-p48pass1
        Test URI:p48pass1.xml
        Spec Sections:3.2 3.2.1 [45] [46] [47]
        Description:Valid use of contentspec, element content models, choices, sequences and content particles within an element type declaration. The optional character following a name or list governs the number of times the element or content particle may appear.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p48pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op49pass1() {
    /*
        Test ID:o-p49pass1
        Test URI:p49pass1.xml
        Spec Sections:3.2 3.2.1 [45] [46] [47]
        Description:Valid use of contentspec, element content models, choices, and content particles within an element type declaration. The optional character following a name or list governs the number of times the element or content particle may appear. Whitespace is also valid between choices.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p49pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op50pass1() {
    /*
        Test ID:o-p50pass1
        Test URI:p50pass1.xml
        Spec Sections:3.2 3.2.1 [45] [46] [47]
        Description:Valid use of contentspec, element content models, sequences and content particles within an element type declaration. The optional character following a name or list governs the number of times the element or content particle may appear. Whitespace is also valid between sequences.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p50pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op51pass1() {
    /*
        Test ID:o-p51pass1
        Test URI:p51pass1.xml
        Spec Sections:3.2.2 [51]
        Description:valid Mixed contentspec's.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p51pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op52pass1() {
    /*
        Test ID:o-p52pass1
        Test URI:p52pass1.xml
        Spec Sections:3.3 [52]
        Description:valid AttlistDecls: No AttDef's are required, and the terminating S is optional, multiple ATTLISTS per element are OK, and multiple declarations of the same attribute are OK.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p52pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op53pass1() {
    /*
        Test ID:o-p53pass1
        Test URI:p53pass1.xml
        Spec Sections:3.3 [53]
        Description:a valid AttDef
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p53pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op54pass1() {
    /*
        Test ID:o-p54pass1
        Test URI:p54pass1.xml
        Spec Sections:3.3.1 [54]
        Description:the three kinds of attribute types
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p54pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op55pass1() {
    /*
        Test ID:o-p55pass1
        Test URI:p55pass1.xml
        Spec Sections:3.3.1 [55]
        Description:StringType = "CDATA"
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p55pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op56pass1() {
    /*
        Test ID:o-p56pass1
        Test URI:p56pass1.xml
        Spec Sections:3.3.1 [56]
        Description:the 7 tokenized attribute types
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p56pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op57pass1() {
    /*
        Test ID:o-p57pass1
        Test URI:p57pass1.xml
        Spec Sections:3.3.1 [57]
        Description:enumerated types are NMTOKEN or NOTATION lists
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p57pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op58pass1() {
    /*
        Test ID:o-p58pass1
        Test URI:p58pass1.xml
        Spec Sections:3.3.1 [58]
        Description:NOTATION enumeration has on or more items
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p58pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op59pass1() {
    /*
        Test ID:o-p59pass1
        Test URI:p59pass1.xml
        Spec Sections:3.3.1 [59]
        Description:NMTOKEN enumerations have one or more items
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p59pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op60pass1() {
    /*
        Test ID:o-p60pass1
        Test URI:p60pass1.xml
        Spec Sections:3.3.2 [60]
        Description:the four types of default values
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p60pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op61pass1() {
    /*
        Test ID:o-p61pass1
        Test URI:p61pass1.xml
        Spec Sections:3.4 [61]
        Description:valid conditional sections are INCLUDE and IGNORE
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p61pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op62pass1() {
    /*
        Test ID:o-p62pass1
        Test URI:p62pass1.xml
        Spec Sections:3.4 [62]
        Description:valid INCLUDE sections -- options S before and after keyword, sections can nest
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p62pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op63pass1() {
    /*
        Test ID:o-p63pass1
        Test URI:p63pass1.xml
        Spec Sections:3.4 [63]
        Description:valid IGNORE sections
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p63pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op64pass1() {
    /*
        Test ID:o-p64pass1
        Test URI:p64pass1.xml
        Spec Sections:3.4 [64]
        Description:IGNOREd sections ignore everything except section delimiters
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p64pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op68pass1() {
    /*
        Test ID:o-p68pass1
        Test URI:p68pass1.xml
        Spec Sections:4.1 [68]
        Description:Valid entity references. Also ensures that a charref to '&' isn't interpreted as an entity reference open delimiter
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p68pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op69pass1() {
    /*
        Test ID:o-p69pass1
        Test URI:p69pass1.xml
        Spec Sections:4.1 [69]
        Description:Valid PEReferences.
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p69pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op70pass1() {
    /*
        Test ID:o-p70pass1
        Test URI:p70pass1.xml
        Spec Sections:4.2 [70]
        Description:An EntityDecl is either a GEDecl or a PEDecl
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p70pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op71pass1() {
    /*
        Test ID:o-p71pass1
        Test URI:p71pass1.xml
        Spec Sections:4.2 [71]
        Description:Valid GEDecls
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p71pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op72pass1() {
    /*
        Test ID:o-p72pass1
        Test URI:p72pass1.xml
        Spec Sections:4.2 [72]
        Description:Valid PEDecls
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p72pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op73pass1() {
    /*
        Test ID:o-p73pass1
        Test URI:p73pass1.xml
        Spec Sections:4.2 [73]
        Description:EntityDef is either Entity value or an external id, with an optional NDataDecl
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p73pass1.xml")
            .unwrap()
            .as_str(),
    );
}

#[test]
#[ignore]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn op76pass1() {
    /*
        Test ID:o-p76pass1
        Test URI:p76pass1.xml
        Spec Sections:4.2.2 [76]
        Description:valid NDataDecls
    */

    test_oasis_valid(
        fs::read_to_string("tests/conformance/xml/xmlconf/oasis/p76pass1.xml")
            .unwrap()
            .as_str(),
    );
}
