1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/*
IBM test cases
*/
#[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::{Error, ErrorKind};
#[cfg(all(test, feature = "test-conformance-xml"))]
fn test_ibm_error(xmldoc: &str, docloc: &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(docloc.to_string())
.build();
let parseresult = xml::parse_with_state(xmldoc, ps, ss);
assert!(parseresult.is_err());
}
#[cfg(all(test, feature = "test-conformance-xml"))]
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 ibmnotwf_p69ibm69n05xml() {
/*
Test ID:ibm-not-wf-P69-ibm69n05.xml
Test URI:not-wf/P69/ibm69n05.xml
Spec Sections:4.1
Description:Based on E29 substantial source: minutes XML-Syntax 1999-02-24 E38 in XML 1.0 Errata, this WFC does not apply to P69, but the VC Entity declared still apply. Tests PEReference which is against P69 WFC: Entity Declared. The PE with the name "paaa" is referred before declared in the DTD.
*/
test_ibm_error(
fs::read_to_string("tests/conformance/xml/xmlconf/ibm/not-wf/P69/ibm69n05.xml")
.unwrap()
.as_str(),
"tests/conformance/xml/xmlconf/ibm/not-wf/P69/",
);
}
#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn ibminvalid_p68ibm68i01xml() {
/*
Test ID:ibm-invalid-P68-ibm68i01.xml
Test URI:invalid/P68/ibm68i01.xml
Spec Sections:4.1
Description:Tests invalid EntityRef which is against P68 VC: Entity Declared. The GE with the name "ge2" is referred in the file ibm68i01.dtd", but not declared.
*/
test_ibm_error(
fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P68/ibm68i01.xml")
.unwrap()
.as_str(),
"tests/conformance/xml/xmlconf/ibm/invalid/P68/",
);
}
#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn ibminvalid_p68ibm68i02xml() {
/*
Test ID:ibm-invalid-P68-ibm68i02.xml
Test URI:invalid/P68/ibm68i02.xml
Spec Sections:4.1
Description:Tests invalid EntityRef which is against P68 VC: Entity Declared. The GE with the name "ge1" is referred before declared in the file ibm68i01.dtd".
*/
test_ibm_error(
fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P68/ibm68i02.xml")
.unwrap()
.as_str(),
"tests/conformance/xml/xmlconf/ibm/invalid/P68/",
);
}
#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn ibminvalid_p68ibm68i03xml() {
/*
Test ID:ibm-invalid-P68-ibm68i03.xml
Test URI:invalid/P68/ibm68i03.xml
Spec Sections:4.1
Description:Tests invalid EntityRef which is against P68 VC: Entity Declared. The GE with the name "ge2" is referred in the file ibm68i03.ent", but not declared.
*/
test_ibm_error(
fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P68/ibm68i03.xml")
.unwrap()
.as_str(),
"tests/conformance/xml/xmlconf/ibm/invalid/P68/",
);
}
#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn ibminvalid_p68ibm68i04xml() {
/*
Test ID:ibm-invalid-P68-ibm68i04.xml
Test URI:invalid/P68/ibm68i04.xml
Spec Sections:4.1
Description:Tests invalid EntityRef which is against P68 VC: Entity Declared. The GE with the name "ge1" is referred before declared in the file ibm68i04.ent".
*/
test_ibm_error(
fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P68/ibm68i04.xml")
.unwrap()
.as_str(),
"tests/conformance/xml/xmlconf/ibm/invalid/P68/",
);
}
#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn ibminvalid_p69ibm69i01xml() {
/*
Test ID:ibm-invalid-P69-ibm69i01.xml
Test URI:invalid/P69/ibm69i01.xml
Spec Sections:4.1
Description:Tests invalid PEReference which is against P69 VC: Entity Declared. The Name "pe2" in the PEReference in the file ibm69i01.dtd does not match the Name of any declared PE.
*/
test_ibm_error(
fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P69/ibm69i01.xml")
.unwrap()
.as_str(),
"tests/conformance/xml/xmlconf/ibm/invalid/P69/",
);
}
#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn ibminvalid_p69ibm69i02xml() {
/*
Test ID:ibm-invalid-P69-ibm69i02.xml
Test URI:invalid/P69/ibm69i02.xml
Spec Sections:4.1
Description:Tests invalid PEReference which is against P69 VC: Entity Declared. The PE with the name "pe1" is referred before declared in the file ibm69i02.dtd
*/
test_ibm_error(
fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P69/ibm69i02.xml")
.unwrap()
.as_str(),
"tests/conformance/xml/xmlconf/ibm/invalid/P69/",
);
}
#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn ibminvalid_p69ibm69i03xml() {
/*
Test ID:ibm-invalid-P69-ibm69i03.xml
Test URI:invalid/P69/ibm69i03.xml
Spec Sections:4.1
Description:Tests invalid PEReference which is against P69 VC: Entity Declared. The Name "pe3" in the PEReference in the file ibm69i03.ent does not match the Name of any declared PE.
*/
test_ibm_error(
fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P69/ibm69i03.xml")
.unwrap()
.as_str(),
"tests/conformance/xml/xmlconf/ibm/invalid/P69/",
);
}
#[test]
#[cfg(all(test, feature = "test-conformance-xml"))]
fn ibminvalid_p69ibm69i04xml() {
/*
Test ID:ibm-invalid-P69-ibm69i04.xml
Test URI:invalid/P69/ibm69i04.xml
Spec Sections:4.1
Description:Tests invalid PEReference which is against P69 VC: Entity Declared. The PE with the name "pe2" is referred before declared in the file ibm69i04.ent.
*/
test_ibm_error(
fs::read_to_string("tests/conformance/xml/xmlconf/ibm/invalid/P69/ibm69i04.xml")
.unwrap()
.as_str(),
"tests/conformance/xml/xmlconf/ibm/invalid/P69/",
);
}