コード例 #1
0
  public void testMarkAndReset() throws IOException {
    UnsyncStringReader unsyncStringReader = new UnsyncStringReader("abc");

    assertEquals('a', unsyncStringReader.read());

    unsyncStringReader.mark(-1);

    assertEquals('b', unsyncStringReader.read());
    assertEquals('c', unsyncStringReader.read());
    assertEquals(-1, unsyncStringReader.read());

    unsyncStringReader.reset();

    assertEquals('b', unsyncStringReader.read());
    assertEquals('c', unsyncStringReader.read());
    assertEquals(-1, unsyncStringReader.read());
  }
コード例 #2
0
  public void testClose() {
    UnsyncStringReader unsyncStringReader = new UnsyncStringReader("abcdefg");

    unsyncStringReader.close();

    assertTrue(unsyncStringReader.string == null);

    try {
      unsyncStringReader.mark(0);

      fail();
    } catch (IOException ioe) {
    }

    try {
      unsyncStringReader.read();

      fail();
    } catch (IOException ioe) {
    }

    try {
      unsyncStringReader.read(new char[5]);

      fail();
    } catch (IOException ioe) {
    }

    try {
      unsyncStringReader.ready();

      fail();
    } catch (IOException ioe) {
    }

    try {
      unsyncStringReader.reset();

      fail();
    } catch (IOException ioe) {
    }

    unsyncStringReader.close();
  }