예제 #1
0
 /** Test {@link TextInput#getChar(int)}. */
 public void testGetCharInt() {
   final String first = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
   for (int i = 0; i < first.length(); i++) {
     assertEquals(first.charAt(i), qedeqInput.getChar(0));
     assertEquals(first.charAt(i), qedeqInput.read());
   }
   qedeqInput.setPosition(qedeqInput.getMaximumPosition());
   for (int i = 0; i < 10; i++) {
     assertEquals(-1, qedeqInput.getChar(0));
   }
   for (int i = 0; i < 10; i++) {
     assertEquals(-1, qedeqInput.getChar(i));
   }
   assertEquals('>', qedeqInput.getChar(-1));
   assertEquals('Q', qedeqInput.getChar(-2));
   assertEquals('E', qedeqInput.getChar(-3));
   assertEquals('D', qedeqInput.getChar(-4));
   assertEquals('E', qedeqInput.getChar(-5));
   assertEquals('Q', qedeqInput.getChar(-6));
   assertEquals('/', qedeqInput.getChar(-7));
   assertEquals('<', qedeqInput.getChar(-8));
   qedeqInput.setPosition(0);
   for (int i = 0; i < first.length(); i++) {
     assertEquals(first.charAt(i), qedeqInput.getChar(0));
     assertEquals(first.charAt(i), qedeqInput.read());
   }
   qedeqInput.setPosition(0);
   for (int i = 0; i < first.length(); i++) {
     assertEquals(first.charAt(i), qedeqInput.getChar(i));
   }
 }
예제 #2
0
 /** Test {@link TextInput#isEmpty()}. */
 public void testIsEmpty() {
   assertFalse(qedeqInput.isEmpty());
   final String first = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
   for (int i = 0; i < first.length(); i++) {
     qedeqInput.read();
     assertFalse(qedeqInput.isEmpty());
   }
   qedeqInput.setPosition(qedeqInput.getMaximumPosition());
   assertTrue(qedeqInput.isEmpty());
 }
예제 #3
0
 /** Test {@link TextInput#getChar()}. */
 public void testGetChar() {
   final String first = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n";
   for (int i = 0; i < first.length(); i++) {
     assertEquals(first.charAt(i), qedeqInput.getChar());
     assertEquals(first.charAt(i), qedeqInput.read());
   }
   qedeqInput.setPosition(qedeqInput.getMaximumPosition());
   for (int i = 0; i < 10; i++) {
     assertEquals(-1, qedeqInput.getChar());
     assertEquals(-1, qedeqInput.read());
   }
   qedeqInput.setPosition(0);
   for (int i = 0; i < first.length(); i++) {
     assertEquals(first.charAt(i), qedeqInput.getChar());
     assertEquals(first.charAt(i), qedeqInput.read());
   }
 }