Clover Coverage Report
Coverage timestamp: Fri May 24 2013 13:47:27 UTC
367   768   90   8.34
40   570   0.25   44
44     2.05  
1    
 
  TextInputTest       Line # 30 367 90 88.9% 0.88913524
 
  (28)
 
1    /* This file is part of the project "Hilbert II" - http://www.qedeq.org
2    *
3    * Copyright 2000-2013, Michael Meyling <mime@qedeq.org>.
4    *
5    * "Hilbert II" is free software; you can redistribute
6    * it and/or modify it under the terms of the GNU General Public
7    * License as published by the Free Software Foundation; either
8    * version 2 of the License, or (at your option) any later version.
9    *
10    * This program is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13    * GNU General Public License for more details.
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    * Test {@link TextInput}.
27    *
28    * @author Michael Meyling
29    */
 
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    /* 1 */ "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"
38    /* 2 */ + "<QEDEQ \n"
39    /* 3 */ + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
40    /* 4 */ + " xsi:noNamespaceSchemaLocation=\"http://www.qedeq.org/0_01_06/xml/qedeq.xsd\">\n"
41    /* 5 */ + " <HEADER email=\"mime@qedeq.org\">\n"
42    /* 6 */ + " <SPEC name=\"qedeq_sample1\" ruleVersion=\"1.00.00\">\n"
43    /* 7 */ + " <LOCATIONS>\n"
44    /* 8 */ + " \t\r <LOCATION value=\"http://qedeq.org/0.01.06/sample1\"/>\n"
45    /* 9 */ + " </LOCATIONS>\n"
46    /* 10 */ + " </SPEC>\n"
47    /* 11 */ + " <TITLE>\n"
48    /* 12 */ + " <LATEX language=\"en\">\n"
49    /* 13 */ + " Example1\n"
50    /* 14 */ + " </LATEX>\n"
51    /* 15 */ + " </TITLE>\n"
52    /* 16 */ + " <ABSTRACT>\n"
53    /* 17 */ + " <LATEX language=\"en\">\n"
54    /* 18 */ + " 1789.01239In this very first qedeq module the XML specification is demonstrated.\n"
55    /* 19 */ + " </LATEX>\n"
56    /* 20 */ + " </ABSTRACT>\n"
57    /* 21 */ + " <AUTHORS>\n"
58    /* 22 */ + " <AUTHOR email=\"michael@meyling.com\">\n"
59    /* 23 */ + " <LATEX language=\"de\">\n"
60    /* 24 */ + " <![CDATA[Michael Meyling]]>\n"
61    /* 25 */ + " </LATEX>\n"
62    /* 26 */ + " </AUTHOR>\n"
63    /* 27 */ + " </AUTHORS>\n"
64    /* 28 */ + " </HEADER>\n"
65    /* 29 */ + "</QEDEQ>";
66   
67   
68    /*
69    * @see TestCase#setUp()
70    */
 
71  28 toggle 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 TestCase#tearDown()
79    */
 
80  28 toggle protected void tearDown() throws Exception {
81  28 qedeqInput = null;
82  28 super.tearDown();
83    }
84   
85    /**
86    * Test constructor {@link TextInput#TextInput(File)}.
87    * @throws Exception Test failed.
88    */
 
89  1 toggle 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    // OK
101    }
102  1 assertTrue(file.delete());
103    }
104   
105    /**
106    * Test constructor {@link TextInput#TextInput(String)}.
107    */
 
108  1 toggle 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    // expected
118    }
119    }
120   
121    /**
122    * Test constructor {@link TextInput#TextInput(StringBuffer)}.
123    */
 
124  1 toggle 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    // expected
136    }
137    }
138   
139    /**
140    * Test constructor {@link TextInput#TextInput(Reader)}.
141    */
 
142  1 toggle public void testTextInputReader() throws Exception {
143  1 final TextInput ti = new TextInput(new Reader() {
144    int pos = 0;
145   
 
146  1 toggle public void close() throws IOException {
147    }
148   
 
149  833 toggle 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    // expected
171    }
172    }
173   
174    /**
175    * Test {@link TextInput#read()}.
176    */
 
177  1 toggle 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    * Test {@link TextInput#read()}.
197    */
 
198  1 toggle public void testReadString() {
199  1 qedeqInput.read();
200  1 qedeqInput.read();
201  1 assertEquals("xml", qedeqInput.readString(3));
202    }
203   
204    /**
205    * Test {@link TextInput#getChar()}.
206    */
 
207  1 toggle 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   
 
225  1 toggle 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   
 
240  1 toggle 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    * Test {@link TextInput#getChar(int)}.
250    */
 
251  1 toggle 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   
 
283  1 toggle 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   
 
308  1 toggle 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   
 
314  1 toggle 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    * Test {@link TextInput#skipWhiteSpace()}.
327    */
 
328  1 toggle 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    * Test {@link TextInput#skipWhiteSpace()}.
349    */
 
350  1 toggle 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    * Tests {@link TextInput#skipBackToBeginOfXmlTag()}.
370    */
 
371  1 toggle 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    // OK
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    // now we are at "<"
387  1 final int pos = qedeqInput.getPosition();
388  1 qedeqInput.skipBackToBeginOfXmlTag();
389  1 assertEquals(pos, qedeqInput.getPosition());
390  1 qedeqInput.readInverse();
391    // now we are just before "<"
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    // OK
401    }
402    }
403   
 
404  1 toggle 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   
 
420  1 toggle 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"); // the quotation is not ended!
436    } catch (RuntimeException e) {
437    // OK
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"); // the tag is not ended with >
443    } catch (RuntimeException e) {
444    // OK
445    }
446    }
447   
 
448  1 toggle 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"); // we are not within the tag yet
453    } catch (RuntimeException e) {
454    // OK
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"); // now we have the value
462    } catch (RuntimeException e) {
463    // OK
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"); // now we have the value
469    } catch (RuntimeException e) {
470    // OK
471    }
472    }
473   
 
474  1 toggle 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"); // now we have the value
479    } catch (RuntimeException e) {
480    // OK
481    }
482  1 ti.read(); // skip <
483  1 try {
484  1 System.out.println("attribute=" + ti.readNextAttributeValue());
485  0 fail("Exception expected"); // now we have the value
486    } catch (RuntimeException e) {
487    // OK
488    }
489  1 assertEquals("Head", ti.readNextXmlName());
490  1 try {
491  1 System.out.println("attribute=" + ti.readNextAttributeValue());
492  0 fail("Exception expected"); // now we have the value
493    } catch (RuntimeException e) {
494    // OK
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"); // now we have the value
504    } catch (RuntimeException e) {
505    // OK
506    }
507    }
508   
 
509  1 toggle 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"); // now we have the value
515    } catch (RuntimeException e) {
516    // OK
517    }
518  1 ti.read(); // skip <
519  1 try {
520  1 System.out.println("attribute=" + ti.readNextAttributeValue());
521  0 fail("Exception expected"); // now we have the value
522    } catch (RuntimeException e) {
523    // OK
524    }
525  1 assertEquals("Head", ti.readNextXmlName());
526  1 try {
527  1 System.out.println("attribute=" + ti.readNextAttributeValue());
528  0 fail("Exception expected"); // now we have the value
529    } catch (RuntimeException e) {
530    // OK
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"); // now we have the value
540    } catch (RuntimeException e) {
541    // OK
542    }
543    }
544   
545    /**
546    * Test {@link TextInput#isEmpty()}.
547    */
 
548  1 toggle 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    * Test {@link TextInput#isEmpty()}.
561    */
 
562  1 toggle 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    * Test {@link TextInput#readLetterDigitString()}.
580    */
 
581  1 toggle 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    // expected
596    }
597  1 try {
598  1 emptyInput.readLetterDigitString();
599  0 fail("IllegalArgumentException expected");
600    } catch (IllegalArgumentException e) {
601    // expected
602    }
603    }
604   
605    /**
606    * Tests {@link TextInput#readCounter()}.
607    */
 
608  1 toggle 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    // expected
616    }
617  1 qedeqInput.read();
618  1 try {
619  1 qedeqInput.readCounter();
620  0 fail("IllegalArgumentException expected");
621    } catch (IllegalArgumentException e) {
622    // expected
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    // expected
631    }
632  1 try {
633  1 emptyInput.readCounter();
634  0 fail("IllegalArgumentException expected");
635    } catch (IllegalArgumentException e) {
636    // expected
637    }
638    }
639   
640    /**
641    * Test {@link TextInput#readQuoted()}.
642    */
 
643  1 toggle 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    // expected
659    }
660  1 assertTrue(position < second.getPosition());
661    }
662   
663    /**
664    * Test {@link TextInput#readInverse()}.
665    */
 
666  1 toggle public void testReadInverse() {
667  1 assertEquals(-1, qedeqInput.readInverse());
668  1 assertEquals('<', qedeqInput.read());
669  1 assertEquals('<', qedeqInput.readInverse());
670    }
671   
672    /**
673    * Test {@link TextInput#getRow()}.
674    */
 
675  0 toggle public void pestGetRow() {
676  0 fail("not implemented");
677    }
678   
679    /**
680    * Test {@link TextInput#getColumn()}.
681    */
 
682  0 toggle public void pestGetColumn() {
683  0 fail("not implemented");
684    }
685   
686    /**
687    * Test {@link TextInput#getLine()}.
688    */
 
689  0 toggle public void pestGetLine() {
690  0 fail("not implemented");
691    }
692   
693    /**
694    * Test {@link TextInput#getPosition()} and {@link TextInput#setPosition(int)}.
695    */
 
696  0 toggle public void pestGetSetPosition() {
697  0 fail("not implemented");
698    }
699   
700    /**
701    * Test {@link TextInput#getMaximumPosition()}.
702    */
 
703  0 toggle public void pestGetMaximumPosition() {
704  0 fail("not implemented");
705    }
706   
707    /**
708    * Test {@link TextInput#setRow(int)}.
709    */
 
710  0 toggle public void pestSetRow() {
711  0 fail("not implemented");
712    }
713   
714    /**
715    * Test {@link TextInput#setColumn(int)}.
716    */
 
717  0 toggle public void pestSetColumn() {
718  0 fail("not implemented");
719    }
720   
721    /**
722    * Test {@link TextInput#getAddress()}.
723    */
 
724  0 toggle public void pestGetAddress() {
725  0 fail("not implemented");
726    }
727   
728    /**
729    * Test {@link TextInput#getLocalAddress()}.
730    */
 
731  0 toggle public void pestGetLocalAddress() {
732  0 fail("not implemented");
733    }
734   
735    /**
736    * Test {@link TextInput#showLinePosition()}.
737    */
 
738  0 toggle public void pestShowLinePosition() {
739  0 fail("not implemented");
740    }
741   
742    /**
743    * Test {@link TextInput#hashCode()}.
744    */
 
745  0 toggle public void pestHashCode() {
746  0 fail("not implemented");
747    }
748   
749    /**
750    * Test {@link TextInput#equals(Object)}.
751    */
 
752  1 toggle 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    * Test {@link TextInput#toString()}.
763    */
 
764  0 toggle public void pestToString() {
765  0 fail("not implemented");
766    }
767   
768    }