1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
package org.qedeq.base.io; |
17 |
|
|
18 |
|
import java.io.File; |
19 |
|
import java.io.IOException; |
20 |
|
import java.io.Reader; |
21 |
|
|
22 |
|
import org.qedeq.base.test.QedeqTestCase; |
23 |
|
import org.qedeq.base.utility.StringUtility; |
24 |
|
|
25 |
|
|
26 |
|
@link |
27 |
|
|
28 |
|
@author |
29 |
|
|
|
|
| 88.9% |
Uncovered Elements: 50 (451) |
Complexity: 90 |
Complexity Density: 0.25 |
|
30 |
|
public class TextInputTest extends QedeqTestCase { |
31 |
|
|
32 |
|
private TextInput qedeqInput; |
33 |
|
|
34 |
|
private TextInput emptyInput; |
35 |
|
|
36 |
|
private static final String XML_DATA = |
37 |
|
"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" |
38 |
|
+ "<QEDEQ \n" |
39 |
|
+ " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" |
40 |
|
+ " xsi:noNamespaceSchemaLocation=\"http://www.qedeq.org/0_01_06/xml/qedeq.xsd\">\n" |
41 |
|
+ " <HEADER email=\"mime@qedeq.org\">\n" |
42 |
|
+ " <SPEC name=\"qedeq_sample1\" ruleVersion=\"1.00.00\">\n" |
43 |
|
+ " <LOCATIONS>\n" |
44 |
|
+ " \t\r <LOCATION value=\"http://qedeq.org/0.01.06/sample1\"/>\n" |
45 |
|
+ " </LOCATIONS>\n" |
46 |
|
+ " </SPEC>\n" |
47 |
|
+ " <TITLE>\n" |
48 |
|
+ " <LATEX language=\"en\">\n" |
49 |
|
+ " Example1\n" |
50 |
|
+ " </LATEX>\n" |
51 |
|
+ " </TITLE>\n" |
52 |
|
+ " <ABSTRACT>\n" |
53 |
|
+ " <LATEX language=\"en\">\n" |
54 |
|
+ " 1789.01239In this very first qedeq module the XML specification is demonstrated.\n" |
55 |
|
+ " </LATEX>\n" |
56 |
|
+ " </ABSTRACT>\n" |
57 |
|
+ " <AUTHORS>\n" |
58 |
|
+ " <AUTHOR email=\"michael@meyling.com\">\n" |
59 |
|
+ " <LATEX language=\"de\">\n" |
60 |
|
+ " <![CDATA[Michael Meyling]]>\n" |
61 |
|
+ " </LATEX>\n" |
62 |
|
+ " </AUTHOR>\n" |
63 |
|
+ " </AUTHORS>\n" |
64 |
|
+ " </HEADER>\n" |
65 |
|
+ "</QEDEQ>"; |
66 |
|
|
67 |
|
|
68 |
|
|
69 |
|
@see |
70 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
71 |
28
|
protected void setUp() throws Exception {... |
72 |
28
|
qedeqInput = new TextInput(XML_DATA); |
73 |
28
|
emptyInput = new TextInput(""); |
74 |
28
|
super.setUp(); |
75 |
|
} |
76 |
|
|
77 |
|
|
78 |
|
@see |
79 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
80 |
28
|
protected void tearDown() throws Exception {... |
81 |
28
|
qedeqInput = null; |
82 |
28
|
super.tearDown(); |
83 |
|
} |
84 |
|
|
85 |
|
|
86 |
|
@link |
87 |
|
@throws |
88 |
|
|
|
|
| 90.9% |
Uncovered Elements: 1 (11) |
Complexity: 3 |
Complexity Density: 0.33 |
1
PASS
|
|
89 |
1
|
public void testTextInputFileString() throws Exception {... |
90 |
1
|
final File file = new File(getOutdir(), this.getClass().getName() + ".testTexFileInput.impl"); |
91 |
1
|
IoUtility.saveFile(file, XML_DATA, IoUtility.getDefaultEncoding()); |
92 |
1
|
TextInput ti = new TextInput(file, IoUtility.getDefaultEncoding()); |
93 |
833
|
while (!qedeqInput.isEmpty()) { |
94 |
832
|
assertEquals(qedeqInput.read(), ti.read()); |
95 |
|
} |
96 |
1
|
try { |
97 |
1
|
new TextInput((File) null, "UTF-8"); |
98 |
0
|
fail("Exception expected"); |
99 |
|
} catch (RuntimeException e) { |
100 |
|
|
101 |
|
} |
102 |
1
|
assertTrue(file.delete()); |
103 |
|
} |
104 |
|
|
105 |
|
|
106 |
|
@link |
107 |
|
|
|
|
| 87.5% |
Uncovered Elements: 1 (8) |
Complexity: 3 |
Complexity Density: 0.5 |
1
PASS
|
|
108 |
1
|
public void testTextInputStringStringString() {... |
109 |
1
|
int i = 0; |
110 |
833
|
while (!qedeqInput.isEmpty()) { |
111 |
832
|
assertEquals(qedeqInput.read(), XML_DATA.charAt(i++)); |
112 |
|
} |
113 |
1
|
try { |
114 |
1
|
new TextInput((String) null); |
115 |
0
|
fail("NullPointerException expected"); |
116 |
|
} catch (NullPointerException e) { |
117 |
|
|
118 |
|
} |
119 |
|
} |
120 |
|
|
121 |
|
|
122 |
|
@link |
123 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 3 |
Complexity Density: 0.38 |
1
PASS
|
|
124 |
1
|
public void testTextInputStringBufferStringString() {... |
125 |
1
|
final StringBuffer buffer = new StringBuffer(XML_DATA); |
126 |
1
|
final TextInput ti = new TextInput(buffer); |
127 |
1
|
int i = 0; |
128 |
833
|
while (!ti.isEmpty()) { |
129 |
832
|
assertEquals(ti.read(), XML_DATA.charAt(i++)); |
130 |
|
} |
131 |
1
|
try { |
132 |
1
|
new TextInput((StringBuffer) null); |
133 |
0
|
fail("NullPointerException expected"); |
134 |
|
} catch (NullPointerException e) { |
135 |
|
|
136 |
|
} |
137 |
|
} |
138 |
|
|
139 |
|
|
140 |
|
@link |
141 |
|
|
|
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 3 |
Complexity Density: 0.43 |
1
PASS
|
|
142 |
1
|
public void testTextInputReader() throws Exception {... |
143 |
1
|
final TextInput ti = new TextInput(new Reader() { |
144 |
|
int pos = 0; |
145 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
146 |
1
|
public void close() throws IOException {... |
147 |
|
} |
148 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 3 |
Complexity Density: 0.43 |
|
149 |
833
|
public int read(char[] cbuf, int off, int len) throws IOException {... |
150 |
833
|
if (pos >= XML_DATA.length()) { |
151 |
1
|
return -1; |
152 |
|
} |
153 |
832
|
final String result = StringUtility.substring(XML_DATA, pos, len); |
154 |
1664
|
for (int i = 0; i < result.length(); i++) { |
155 |
832
|
cbuf[off + i] = result.charAt(i); |
156 |
|
} |
157 |
832
|
pos += result.length(); |
158 |
832
|
return result.length(); |
159 |
|
} |
160 |
|
|
161 |
|
}); |
162 |
1
|
int i = 0; |
163 |
833
|
while (!ti.isEmpty()) { |
164 |
832
|
assertEquals(ti.read(), XML_DATA.charAt(i++)); |
165 |
|
} |
166 |
1
|
try { |
167 |
1
|
new TextInput((Reader) null); |
168 |
0
|
fail("NullPointerException expected"); |
169 |
|
} catch (NullPointerException e) { |
170 |
|
|
171 |
|
} |
172 |
|
} |
173 |
|
|
174 |
|
|
175 |
|
@link |
176 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 5 |
Complexity Density: 0.45 |
1
PASS
|
|
177 |
1
|
public void testRead() {... |
178 |
1
|
final String first = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; |
179 |
45
|
for (int i = 0; i < first.length(); i++) { |
180 |
44
|
assertEquals(first.charAt(i), qedeqInput.read()); |
181 |
|
} |
182 |
1
|
qedeqInput.setPosition(qedeqInput.getMaximumPosition()); |
183 |
11
|
for (int i = 0; i < 10; i++) { |
184 |
10
|
assertEquals(-1, qedeqInput.read()); |
185 |
|
} |
186 |
1
|
qedeqInput.setPosition(0); |
187 |
45
|
for (int i = 0; i < first.length(); i++) { |
188 |
44
|
assertEquals(first.charAt(i), qedeqInput.read()); |
189 |
|
} |
190 |
11
|
for (int i = 0; i < 10; i++) { |
191 |
10
|
assertEquals(-1, emptyInput.read()); |
192 |
|
} |
193 |
|
} |
194 |
|
|
195 |
|
|
196 |
|
@link |
197 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
198 |
1
|
public void testReadString() {... |
199 |
1
|
qedeqInput.read(); |
200 |
1
|
qedeqInput.read(); |
201 |
1
|
assertEquals("xml", qedeqInput.readString(3)); |
202 |
|
} |
203 |
|
|
204 |
|
|
205 |
|
@link |
206 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
1
PASS
|
|
207 |
1
|
public void testGetChar() {... |
208 |
1
|
final String first = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; |
209 |
45
|
for (int i = 0; i < first.length(); i++) { |
210 |
44
|
assertEquals(first.charAt(i), qedeqInput.getChar()); |
211 |
44
|
assertEquals(first.charAt(i), qedeqInput.read()); |
212 |
|
} |
213 |
1
|
qedeqInput.setPosition(qedeqInput.getMaximumPosition()); |
214 |
11
|
for (int i = 0; i < 10; i++) { |
215 |
10
|
assertEquals(-1, qedeqInput.getChar()); |
216 |
10
|
assertEquals(-1, qedeqInput.read()); |
217 |
|
} |
218 |
1
|
qedeqInput.setPosition(0); |
219 |
45
|
for (int i = 0; i < first.length(); i++) { |
220 |
44
|
assertEquals(first.charAt(i), qedeqInput.getChar()); |
221 |
44
|
assertEquals(first.charAt(i), qedeqInput.read()); |
222 |
|
} |
223 |
|
} |
224 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1
PASS
|
|
225 |
1
|
public void testForwardInt() {... |
226 |
1
|
qedeqInput.forward(-1); |
227 |
1
|
assertEquals(0, qedeqInput.getPosition()); |
228 |
1
|
qedeqInput.forward(0); |
229 |
1
|
assertEquals(0, qedeqInput.getPosition()); |
230 |
1
|
qedeqInput.forward(1); |
231 |
1
|
assertEquals(1, qedeqInput.getPosition()); |
232 |
1
|
qedeqInput.forward(6); |
233 |
1
|
assertEquals(7, qedeqInput.getPosition()); |
234 |
1
|
qedeqInput.forward(9); |
235 |
1
|
assertEquals(16, qedeqInput.getPosition()); |
236 |
1
|
qedeqInput.forward(99999); |
237 |
1
|
assertEquals(XML_DATA.length(), qedeqInput.getPosition()); |
238 |
|
} |
239 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1
PASS
|
|
240 |
1
|
public void testForwardString() {... |
241 |
1
|
qedeqInput.forward("zafsduizasif"); |
242 |
1
|
assertEquals(832, qedeqInput.getPosition()); |
243 |
1
|
qedeqInput.setPosition(0); |
244 |
1
|
qedeqInput.forward("<?xml"); |
245 |
1
|
assertEquals(0, qedeqInput.getPosition()); |
246 |
|
} |
247 |
|
|
248 |
|
|
249 |
|
@link |
250 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (34) |
Complexity: 6 |
Complexity Density: 0.25 |
1
PASS
|
|
251 |
1
|
public void testGetCharInt() {... |
252 |
1
|
final String first = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; |
253 |
45
|
for (int i = 0; i < first.length(); i++) { |
254 |
44
|
assertEquals(first.charAt(i), qedeqInput.getChar(0)); |
255 |
44
|
assertEquals(first.charAt(i), qedeqInput.read()); |
256 |
|
} |
257 |
1
|
qedeqInput.setPosition(qedeqInput.getMaximumPosition()); |
258 |
11
|
for (int i = 0; i < 10; i++) { |
259 |
10
|
assertEquals(-1, qedeqInput.getChar(0)); |
260 |
|
} |
261 |
11
|
for (int i = 0; i < 10; i++) { |
262 |
10
|
assertEquals(-1, qedeqInput.getChar(i)); |
263 |
|
} |
264 |
1
|
assertEquals('>', qedeqInput.getChar(-1)); |
265 |
1
|
assertEquals('Q', qedeqInput.getChar(-2)); |
266 |
1
|
assertEquals('E', qedeqInput.getChar(-3)); |
267 |
1
|
assertEquals('D', qedeqInput.getChar(-4)); |
268 |
1
|
assertEquals('E', qedeqInput.getChar(-5)); |
269 |
1
|
assertEquals('Q', qedeqInput.getChar(-6)); |
270 |
1
|
assertEquals('/', qedeqInput.getChar(-7)); |
271 |
1
|
assertEquals('<', qedeqInput.getChar(-8)); |
272 |
1
|
qedeqInput.setPosition(0); |
273 |
45
|
for (int i = 0; i < first.length(); i++) { |
274 |
44
|
assertEquals(first.charAt(i), qedeqInput.getChar(0)); |
275 |
44
|
assertEquals(first.charAt(i), qedeqInput.read()); |
276 |
|
} |
277 |
1
|
qedeqInput.setPosition(0); |
278 |
45
|
for (int i = 0; i < first.length(); i++) { |
279 |
44
|
assertEquals(first.charAt(i), qedeqInput.getChar(i)); |
280 |
|
} |
281 |
|
} |
282 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (22) |
Complexity: 1 |
Complexity Density: 0.05 |
1
PASS
|
|
283 |
1
|
public void testGetSubstring() {... |
284 |
1
|
final String text = "one two three"; |
285 |
1
|
final TextInput ti = new TextInput(text); |
286 |
1
|
assertEquals("", ti.getSubstring(text.length(), text.length())); |
287 |
1
|
assertEquals("", ti.getSubstring(-1, -1)); |
288 |
1
|
assertEquals("", (new TextInput("")).getSubstring(-100, 100)); |
289 |
1
|
assertEquals("", (new TextInput("")).getSubstring(100, -100)); |
290 |
1
|
assertEquals("", ti.getSubstring(0, 0)); |
291 |
1
|
assertEquals("", ti.getSubstring(text.length(), 0)); |
292 |
1
|
assertEquals("", ti.getSubstring(text.length(), text.length() + 1)); |
293 |
1
|
assertEquals("e", ti.getSubstring(text.length() - 1, text.length() + 1)); |
294 |
1
|
assertEquals("e", ti.getSubstring(text.length() - 1, text.length())); |
295 |
1
|
assertEquals("", ti.getSubstring(text.length() + 1, 0)); |
296 |
1
|
assertEquals("", ti.getSubstring(text.length() + 1, text.length())); |
297 |
1
|
assertEquals("", ti.getSubstring(text.length() + 1, -1)); |
298 |
1
|
assertEquals(text, ti.getSubstring(-10, 999)); |
299 |
1
|
assertEquals(text, ti.getSubstring(-10, text.length())); |
300 |
1
|
assertEquals(text, ti.getSubstring(0, 997)); |
301 |
1
|
assertEquals("one", ti.getSubstring(-1, 3)); |
302 |
1
|
assertEquals("thre", ti.getSubstring(8, text.length() - 1)); |
303 |
1
|
assertEquals("three", ti.getSubstring(8, text.length())); |
304 |
1
|
assertEquals("three", ti.getSubstring(8, text.length()+ 1)); |
305 |
1
|
assertEquals("two", ti.getSubstring(4, 7)); |
306 |
|
} |
307 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
308 |
1
|
public void testAsString() {... |
309 |
1
|
final String text = "one two three"; |
310 |
1
|
final TextInput ti = new TextInput(text); |
311 |
1
|
assertEquals(text, ti.asString()); |
312 |
|
} |
313 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1
PASS
|
|
314 |
1
|
public void testReplace() {... |
315 |
1
|
final String text = "one two three"; |
316 |
1
|
final TextInput ti = new TextInput(text); |
317 |
1
|
ti.replace(4, 7, "2"); |
318 |
1
|
assertEquals("one 2 three", ti.asString()); |
319 |
1
|
ti.skipToEndOfLine(); |
320 |
1
|
ti.replace(0, 3, "1"); |
321 |
1
|
ti.setPosition(2); |
322 |
1
|
ti.replace(0, 2, ""); |
323 |
|
} |
324 |
|
|
325 |
|
|
326 |
|
@link |
327 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
1
PASS
|
|
328 |
1
|
public void testSkipWhiteSpace() {... |
329 |
1
|
final String first = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"; |
330 |
1
|
qedeqInput.skipWhiteSpace(); |
331 |
1
|
assertEquals(0, qedeqInput.getPosition()); |
332 |
1
|
qedeqInput.setPosition(first.length()); |
333 |
1
|
qedeqInput.skipWhiteSpace(); |
334 |
1
|
assertEquals(first.length() + 1, qedeqInput.getPosition()); |
335 |
1
|
qedeqInput.setRow(8); |
336 |
1
|
assertEquals(" \t\r <LOCATION value=\"http://qedeq.org/0.01.06/sample1\"/>", qedeqInput.getLine()); |
337 |
1
|
qedeqInput.skipWhiteSpace(); |
338 |
1
|
assertEquals(9, qedeqInput.getColumn()); |
339 |
1
|
assertEquals('<', qedeqInput.getChar()); |
340 |
1
|
qedeqInput.setRow(8); |
341 |
1
|
qedeqInput.setPosition(qedeqInput.getPosition() - 1); |
342 |
1
|
qedeqInput.skipWhiteSpace(); |
343 |
1
|
assertEquals(9, qedeqInput.getColumn()); |
344 |
1
|
assertEquals('<', qedeqInput.getChar()); |
345 |
|
} |
346 |
|
|
347 |
|
|
348 |
|
@link |
349 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0.07 |
1
PASS
|
|
350 |
1
|
public void testSkipWhiteSpaceInverse() {... |
351 |
1
|
final String first = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"; |
352 |
1
|
qedeqInput.skipWhiteSpaceInverse(); |
353 |
1
|
assertEquals(0, qedeqInput.getPosition()); |
354 |
1
|
qedeqInput.setPosition(first.length() + 1); |
355 |
1
|
qedeqInput.skipWhiteSpaceInverse(); |
356 |
1
|
assertEquals('\n', qedeqInput.getChar()); |
357 |
1
|
assertEquals(first.length(), qedeqInput.getPosition()); |
358 |
1
|
qedeqInput.setRow(8); |
359 |
1
|
assertEquals(" \t\r <LOCATION value=\"http://qedeq.org/0.01.06/sample1\"/>", qedeqInput.getLine()); |
360 |
1
|
qedeqInput.setColumn(9); |
361 |
1
|
qedeqInput.skipWhiteSpaceInverse(); |
362 |
1
|
assertEquals(7, qedeqInput.getRow()); |
363 |
1
|
assertEquals('>', qedeqInput.getChar(-1)); |
364 |
1
|
qedeqInput.read(); |
365 |
1
|
assertEquals(8, qedeqInput.getRow()); |
366 |
|
} |
367 |
|
|
368 |
|
|
369 |
|
@link |
370 |
|
|
|
|
| 90.9% |
Uncovered Elements: 2 (22) |
Complexity: 3 |
Complexity Density: 0.14 |
1
PASS
|
|
371 |
1
|
public void testSkipBackToBeginOfXmlTag() {... |
372 |
1
|
final TextInput ti = new TextInput("hiso \"<\"hiso >goto blub > &"); |
373 |
1
|
ti.setPosition(300); |
374 |
1
|
try { |
375 |
1
|
ti.skipBackToBeginOfXmlTag(); |
376 |
0
|
fail("Exception expected"); |
377 |
|
} catch (RuntimeException e) { |
378 |
|
|
379 |
|
} |
380 |
1
|
final String first = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"; |
381 |
1
|
qedeqInput.setPosition(first.length()); |
382 |
1
|
qedeqInput.skipBackToBeginOfXmlTag(); |
383 |
1
|
assertEquals(0, qedeqInput.getPosition()); |
384 |
1
|
qedeqInput.setPosition(first.length() + 1); |
385 |
1
|
qedeqInput.skipWhiteSpace(); |
386 |
|
|
387 |
1
|
final int pos = qedeqInput.getPosition(); |
388 |
1
|
qedeqInput.skipBackToBeginOfXmlTag(); |
389 |
1
|
assertEquals(pos, qedeqInput.getPosition()); |
390 |
1
|
qedeqInput.readInverse(); |
391 |
|
|
392 |
1
|
qedeqInput.skipBackToBeginOfXmlTag(); |
393 |
1
|
assertEquals(0, qedeqInput.getPosition()); |
394 |
1
|
final TextInput ti2 = new TextInput("we will test if this is working"); |
395 |
1
|
ti2.setPosition(300); |
396 |
1
|
try { |
397 |
1
|
ti2.skipBackToBeginOfXmlTag(); |
398 |
0
|
fail("Exception expected"); |
399 |
|
} catch (RuntimeException e) { |
400 |
|
|
401 |
|
} |
402 |
|
} |
403 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
1
PASS
|
|
404 |
1
|
public void testSkipToEndOfLine() {... |
405 |
1
|
qedeqInput.skipToEndOfLine(); |
406 |
1
|
assertEquals('\n', qedeqInput.readInverse()); |
407 |
1
|
final TextInput ti = new TextInput("\n\n\n\n"); |
408 |
1
|
ti.skipToEndOfLine(); |
409 |
1
|
assertEquals(1, ti.getPosition()); |
410 |
1
|
ti.skipToEndOfLine(); |
411 |
1
|
assertEquals(2, ti.getPosition()); |
412 |
1
|
ti.skipToEndOfLine(); |
413 |
1
|
assertEquals(3, ti.getPosition()); |
414 |
1
|
ti.skipToEndOfLine(); |
415 |
1
|
assertEquals(4, ti.getPosition()); |
416 |
1
|
ti.skipToEndOfLine(); |
417 |
1
|
assertEquals(4, ti.getPosition()); |
418 |
|
} |
419 |
|
|
|
|
| 89.5% |
Uncovered Elements: 2 (19) |
Complexity: 3 |
Complexity Density: 0.16 |
1
PASS
|
|
420 |
1
|
public void testSkipForwardToEndOfXmlTag() {... |
421 |
1
|
qedeqInput.skipForwardToEndOfXmlTag(); |
422 |
1
|
assertEquals('\n', qedeqInput.getChar()); |
423 |
1
|
qedeqInput.skipForwardToEndOfXmlTag(); |
424 |
1
|
assertEquals('\n', qedeqInput.read()); |
425 |
1
|
assertEquals(" <HEADER", qedeqInput.readString(" <HEADER".length())); |
426 |
1
|
final TextInput ti = new TextInput("<Head this=\">is not the end\">zulu"); |
427 |
1
|
ti.skipForwardToEndOfXmlTag(); |
428 |
1
|
assertEquals("zulu", ti.readString(4)); |
429 |
1
|
final TextInput ti2 = new TextInput("<Head this=\"one\" that=\"two\">zulu"); |
430 |
1
|
ti2.skipForwardToEndOfXmlTag(); |
431 |
1
|
assertEquals("zulu", ti2.readString(4)); |
432 |
1
|
final TextInput ti3 = new TextInput("<Head this=\"one\" that=\"two>zulu"); |
433 |
1
|
try { |
434 |
1
|
ti3.skipForwardToEndOfXmlTag(); |
435 |
0
|
fail("Exception expected"); |
436 |
|
} catch (RuntimeException e) { |
437 |
|
|
438 |
|
} |
439 |
1
|
final TextInput ti4 = new TextInput("<Head this=\"one\" that=\"two\" this= that"); |
440 |
1
|
try { |
441 |
1
|
ti4.skipForwardToEndOfXmlTag(); |
442 |
0
|
fail("Exception expected"); |
443 |
|
} catch (RuntimeException e) { |
444 |
|
|
445 |
|
} |
446 |
|
} |
447 |
|
|
|
|
| 78.6% |
Uncovered Elements: 3 (14) |
Complexity: 4 |
Complexity Density: 0.29 |
1
PASS
|
|
448 |
1
|
public void testReadXmlName() {... |
449 |
1
|
final TextInput ti = new TextInput("<Head this=\">is not the end\">zulu"); |
450 |
1
|
try { |
451 |
1
|
ti.readNextXmlName(); |
452 |
0
|
fail("Exception expected"); |
453 |
|
} catch (RuntimeException e) { |
454 |
|
|
455 |
|
} |
456 |
1
|
ti.read(); |
457 |
1
|
assertEquals("Head", ti.readNextXmlName()); |
458 |
1
|
assertEquals("this", ti.readNextXmlName()); |
459 |
1
|
try { |
460 |
1
|
System.out.println("name=" + ti.readNextXmlName()); |
461 |
0
|
fail("Exception expected"); |
462 |
|
} catch (RuntimeException e) { |
463 |
|
|
464 |
|
} |
465 |
1
|
assertEquals(">is not the end", ti.readNextAttributeValue()); |
466 |
1
|
try { |
467 |
1
|
System.out.println("name=" + ti.readNextXmlName()); |
468 |
0
|
fail("Exception expected"); |
469 |
|
} catch (RuntimeException e) { |
470 |
|
|
471 |
|
} |
472 |
|
} |
473 |
|
|
|
|
| 80% |
Uncovered Elements: 4 (20) |
Complexity: 5 |
Complexity Density: 0.25 |
1
PASS
|
|
474 |
1
|
public void testReadNextAttributeValue() {... |
475 |
1
|
final TextInput ti = new TextInput("<Head this=\">is not the end\" we=zorg go=\"hi"); |
476 |
1
|
try { |
477 |
1
|
System.out.println("attribute=" + ti.readNextAttributeValue()); |
478 |
0
|
fail("Exception expected"); |
479 |
|
} catch (RuntimeException e) { |
480 |
|
|
481 |
|
} |
482 |
1
|
ti.read(); |
483 |
1
|
try { |
484 |
1
|
System.out.println("attribute=" + ti.readNextAttributeValue()); |
485 |
0
|
fail("Exception expected"); |
486 |
|
} catch (RuntimeException e) { |
487 |
|
|
488 |
|
} |
489 |
1
|
assertEquals("Head", ti.readNextXmlName()); |
490 |
1
|
try { |
491 |
1
|
System.out.println("attribute=" + ti.readNextAttributeValue()); |
492 |
0
|
fail("Exception expected"); |
493 |
|
} catch (RuntimeException e) { |
494 |
|
|
495 |
|
} |
496 |
1
|
assertEquals("this", ti.readNextXmlName()); |
497 |
1
|
assertEquals(">is not the end", ti.readNextAttributeValue()); |
498 |
1
|
assertEquals("we", ti.readNextXmlName()); |
499 |
1
|
assertEquals("zorg", ti.readNextAttributeValue()); |
500 |
1
|
assertEquals("go", ti.readNextXmlName()); |
501 |
1
|
try { |
502 |
1
|
System.out.println("attribute=" + ti.readNextAttributeValue()); |
503 |
0
|
fail("Exception expected"); |
504 |
|
} catch (RuntimeException e) { |
505 |
|
|
506 |
|
} |
507 |
|
} |
508 |
|
|
|
|
| 80% |
Uncovered Elements: 4 (20) |
Complexity: 5 |
Complexity Density: 0.25 |
1
PASS
|
|
509 |
1
|
public void testReadNextAttributeValue2() {... |
510 |
1
|
final TextInput ti = new TextInput("<Head this=\">is not \n the end\" we\n=\tzorg " |
511 |
|
+ " go = \"hi"); |
512 |
1
|
try { |
513 |
1
|
System.out.println("attribute=" + ti.readNextAttributeValue()); |
514 |
0
|
fail("Exception expected"); |
515 |
|
} catch (RuntimeException e) { |
516 |
|
|
517 |
|
} |
518 |
1
|
ti.read(); |
519 |
1
|
try { |
520 |
1
|
System.out.println("attribute=" + ti.readNextAttributeValue()); |
521 |
0
|
fail("Exception expected"); |
522 |
|
} catch (RuntimeException e) { |
523 |
|
|
524 |
|
} |
525 |
1
|
assertEquals("Head", ti.readNextXmlName()); |
526 |
1
|
try { |
527 |
1
|
System.out.println("attribute=" + ti.readNextAttributeValue()); |
528 |
0
|
fail("Exception expected"); |
529 |
|
} catch (RuntimeException e) { |
530 |
|
|
531 |
|
} |
532 |
1
|
assertEquals("this", ti.readNextXmlName()); |
533 |
1
|
assertEquals(">is not \n the end", ti.readNextAttributeValue()); |
534 |
1
|
assertEquals("we", ti.readNextXmlName()); |
535 |
1
|
assertEquals("zorg", ti.readNextAttributeValue()); |
536 |
1
|
assertEquals("go", ti.readNextXmlName()); |
537 |
1
|
try { |
538 |
1
|
System.out.println("attribute=" + ti.readNextAttributeValue()); |
539 |
0
|
fail("Exception expected"); |
540 |
|
} catch (RuntimeException e) { |
541 |
|
|
542 |
|
} |
543 |
|
} |
544 |
|
|
545 |
|
|
546 |
|
@link |
547 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 2 |
Complexity Density: 0.29 |
1
PASS
|
|
548 |
1
|
public void testIsEmpty() {... |
549 |
1
|
assertFalse(qedeqInput.isEmpty()); |
550 |
1
|
final String first = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; |
551 |
45
|
for (int i = 0; i < first.length(); i++) { |
552 |
44
|
qedeqInput.read(); |
553 |
44
|
assertFalse(qedeqInput.isEmpty()); |
554 |
|
} |
555 |
1
|
qedeqInput.setPosition(qedeqInput.getMaximumPosition()); |
556 |
1
|
assertTrue(qedeqInput.isEmpty()); |
557 |
|
} |
558 |
|
|
559 |
|
|
560 |
|
@link |
561 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 2 |
Complexity Density: 0.17 |
1
PASS
|
|
562 |
1
|
public void testIsEmptyInt() {... |
563 |
1
|
assertFalse(qedeqInput.isEmpty(0)); |
564 |
1
|
assertFalse(qedeqInput.isEmpty(-1)); |
565 |
1
|
assertFalse(qedeqInput.isEmpty(1)); |
566 |
1
|
final String first = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"; |
567 |
1
|
assertFalse(qedeqInput.isEmpty(first.length())); |
568 |
45
|
for (int i = 0; i < first.length(); i++) { |
569 |
44
|
qedeqInput.read(); |
570 |
|
} |
571 |
1
|
assertFalse(qedeqInput.isEmpty(0)); |
572 |
1
|
qedeqInput.setPosition(qedeqInput.getMaximumPosition()); |
573 |
1
|
assertTrue(qedeqInput.isEmpty(0)); |
574 |
1
|
assertFalse(qedeqInput.isEmpty(-1)); |
575 |
1
|
assertTrue(qedeqInput.isEmpty(1)); |
576 |
|
} |
577 |
|
|
578 |
|
|
579 |
|
@link |
580 |
|
|
|
|
| 86.7% |
Uncovered Elements: 2 (15) |
Complexity: 3 |
Complexity Density: 0.2 |
1
PASS
|
|
581 |
1
|
public void testReadLetterDigitString() {... |
582 |
1
|
qedeqInput.read(); |
583 |
1
|
qedeqInput.read(); |
584 |
1
|
assertEquals("xml", qedeqInput.readLetterDigitString()); |
585 |
1
|
qedeqInput.setRow(13); |
586 |
1
|
assertEquals("Example1", qedeqInput.readLetterDigitString()); |
587 |
1
|
qedeqInput.setRow(13); |
588 |
1
|
qedeqInput.setColumn(1); |
589 |
1
|
qedeqInput.skipWhiteSpace(); |
590 |
1
|
assertEquals("Example1", qedeqInput.readLetterDigitString()); |
591 |
1
|
try { |
592 |
1
|
qedeqInput.readLetterDigitString(); |
593 |
0
|
fail("IllegalArgumentException expected"); |
594 |
|
} catch (IllegalArgumentException e) { |
595 |
|
|
596 |
|
} |
597 |
1
|
try { |
598 |
1
|
emptyInput.readLetterDigitString(); |
599 |
0
|
fail("IllegalArgumentException expected"); |
600 |
|
} catch (IllegalArgumentException e) { |
601 |
|
|
602 |
|
} |
603 |
|
} |
604 |
|
|
605 |
|
|
606 |
|
@link |
607 |
|
|
|
|
| 76.5% |
Uncovered Elements: 4 (17) |
Complexity: 5 |
Complexity Density: 0.29 |
1
PASS
|
|
608 |
1
|
public void testReadCounter() {... |
609 |
1
|
qedeqInput.setRow(18); |
610 |
1
|
assertEquals("1789", qedeqInput.readCounter()); |
611 |
1
|
try { |
612 |
1
|
qedeqInput.readCounter(); |
613 |
0
|
fail("IllegalArgumentException expected"); |
614 |
|
} catch (IllegalArgumentException e) { |
615 |
|
|
616 |
|
} |
617 |
1
|
qedeqInput.read(); |
618 |
1
|
try { |
619 |
1
|
qedeqInput.readCounter(); |
620 |
0
|
fail("IllegalArgumentException expected"); |
621 |
|
} catch (IllegalArgumentException e) { |
622 |
|
|
623 |
|
} |
624 |
1
|
qedeqInput.read(); |
625 |
1
|
assertEquals("1239", qedeqInput.readCounter()); |
626 |
1
|
try { |
627 |
1
|
qedeqInput.readCounter(); |
628 |
0
|
fail("IllegalArgumentException expected"); |
629 |
|
} catch (IllegalArgumentException e) { |
630 |
|
|
631 |
|
} |
632 |
1
|
try { |
633 |
1
|
emptyInput.readCounter(); |
634 |
0
|
fail("IllegalArgumentException expected"); |
635 |
|
} catch (IllegalArgumentException e) { |
636 |
|
|
637 |
|
} |
638 |
|
} |
639 |
|
|
640 |
|
|
641 |
|
@link |
642 |
|
|
|
|
| 92.9% |
Uncovered Elements: 1 (14) |
Complexity: 2 |
Complexity Density: 0.14 |
1
PASS
|
|
643 |
1
|
public void testReadQuoted() {... |
644 |
1
|
final TextInput first = new TextInput("Hell=\"one\" Water=\"two\""); |
645 |
1
|
first.setPosition(5); |
646 |
1
|
assertEquals("one", first.readQuoted()); |
647 |
1
|
first.readString(7); |
648 |
1
|
assertEquals("two", first.readQuoted()); |
649 |
1
|
final TextInput second = new TextInput("\"\"\"one\" Water=\"two\""); |
650 |
1
|
assertEquals("\"one", second.readQuoted()); |
651 |
1
|
second.setPosition(1); |
652 |
1
|
assertEquals("", second.readQuoted()); |
653 |
1
|
final int position = second.getPosition(); |
654 |
1
|
try { |
655 |
1
|
second.readQuoted(); |
656 |
0
|
fail("IllegalArgumentException expected"); |
657 |
|
} catch (IllegalArgumentException e) { |
658 |
|
|
659 |
|
} |
660 |
1
|
assertTrue(position < second.getPosition()); |
661 |
|
} |
662 |
|
|
663 |
|
|
664 |
|
@link |
665 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1
PASS
|
|
666 |
1
|
public void testReadInverse() {... |
667 |
1
|
assertEquals(-1, qedeqInput.readInverse()); |
668 |
1
|
assertEquals('<', qedeqInput.read()); |
669 |
1
|
assertEquals('<', qedeqInput.readInverse()); |
670 |
|
} |
671 |
|
|
672 |
|
|
673 |
|
@link |
674 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
675 |
0
|
public void pestGetRow() {... |
676 |
0
|
fail("not implemented"); |
677 |
|
} |
678 |
|
|
679 |
|
|
680 |
|
@link |
681 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
682 |
0
|
public void pestGetColumn() {... |
683 |
0
|
fail("not implemented"); |
684 |
|
} |
685 |
|
|
686 |
|
|
687 |
|
@link |
688 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
689 |
0
|
public void pestGetLine() {... |
690 |
0
|
fail("not implemented"); |
691 |
|
} |
692 |
|
|
693 |
|
|
694 |
|
@link@link |
695 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
696 |
0
|
public void pestGetSetPosition() {... |
697 |
0
|
fail("not implemented"); |
698 |
|
} |
699 |
|
|
700 |
|
|
701 |
|
@link |
702 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
703 |
0
|
public void pestGetMaximumPosition() {... |
704 |
0
|
fail("not implemented"); |
705 |
|
} |
706 |
|
|
707 |
|
|
708 |
|
@link |
709 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
710 |
0
|
public void pestSetRow() {... |
711 |
0
|
fail("not implemented"); |
712 |
|
} |
713 |
|
|
714 |
|
|
715 |
|
@link |
716 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
717 |
0
|
public void pestSetColumn() {... |
718 |
0
|
fail("not implemented"); |
719 |
|
} |
720 |
|
|
721 |
|
|
722 |
|
@link |
723 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
724 |
0
|
public void pestGetAddress() {... |
725 |
0
|
fail("not implemented"); |
726 |
|
} |
727 |
|
|
728 |
|
|
729 |
|
@link |
730 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
731 |
0
|
public void pestGetLocalAddress() {... |
732 |
0
|
fail("not implemented"); |
733 |
|
} |
734 |
|
|
735 |
|
|
736 |
|
@link |
737 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
738 |
0
|
public void pestShowLinePosition() {... |
739 |
0
|
fail("not implemented"); |
740 |
|
} |
741 |
|
|
742 |
|
|
743 |
|
@link |
744 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
745 |
0
|
public void pestHashCode() {... |
746 |
0
|
fail("not implemented"); |
747 |
|
} |
748 |
|
|
749 |
|
|
750 |
|
@link |
751 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1
PASS
|
|
752 |
1
|
public void testEquals() {... |
753 |
1
|
assertTrue(qedeqInput.equals(qedeqInput)); |
754 |
1
|
assertFalse(emptyInput.equals(qedeqInput)); |
755 |
1
|
assertFalse(emptyInput.equals(null)); |
756 |
1
|
assertFalse(qedeqInput.equals(null)); |
757 |
1
|
assertFalse(qedeqInput.equals(emptyInput)); |
758 |
1
|
assertTrue(emptyInput.equals(emptyInput)); |
759 |
|
} |
760 |
|
|
761 |
|
|
762 |
|
@link |
763 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
764 |
0
|
public void pestToString() {... |
765 |
0
|
fail("not implemented"); |
766 |
|
} |
767 |
|
|
768 |
|
} |