コード例 #1
0
 /** Test method for {@link DefaultJavadocTokenStream#nextToken()}. */
 @Test
 public void testNextTokenSimple() {
   DefaultJavadocTokenStream stream = stream("alphabets.txt");
   for (char c = 'a'; c <= 'z'; c++) {
     assertEquals(String.valueOf(c), stream.nextToken().getText());
   }
   assertEquals(EOF, stream.nextToken().getKind());
   assertEquals(EOF, stream.nextToken().getKind());
 }
コード例 #2
0
 /** Test method for {@link DefaultJavadocTokenStream#nextToken()}. */
 @Test
 public void testNextTokenLines() {
   DefaultJavadocTokenStream stream = stream("blank-lines.txt");
   assertEquals("a", stream.nextToken().getText());
   assertEquals("b", stream.nextToken().getText());
   assertEquals("c", stream.nextToken().getText());
   assertEquals("d", stream.nextToken().getText());
   assertEquals(EOF, stream.nextToken().getKind());
   assertEquals(EOF, stream.nextToken().getKind());
 }
コード例 #3
0
 /** Test method for {@link DefaultJavadocTokenStream#rewind()}. */
 @Test
 public void testRewind() {
   DefaultJavadocTokenStream stream = stream("blank-lines.txt");
   stream.mark();
   assertEquals("a", stream.nextToken().getText());
   stream.mark();
   assertEquals("b", stream.nextToken().getText());
   stream.rewind();
   assertEquals("b", stream.nextToken().getText());
   stream.rewind();
   assertEquals("a", stream.nextToken().getText());
   try {
     stream.rewind();
     fail();
   } catch (IllegalStateException e) {
     // ok.
   }
 }
コード例 #4
0
  /** Test method for {@link DefaultJavadocTokenStream#lookahead(int)}. */
  @Test
  public void testLookahead() {
    DefaultJavadocTokenStream stream = stream("alphabets.txt");

    assertEquals("a", stream.lookahead(0).getText());
    assertEquals("a", stream.lookahead(0).getText());
    assertEquals("b", stream.lookahead(2).getText());
    assertEquals("c", stream.lookahead(4).getText());
    assertEquals("d", stream.lookahead(6).getText());
    assertEquals("e", stream.lookahead(8).getText());

    stream.nextToken();
    assertEquals("b", stream.lookahead(1).getText());
    assertEquals("c", stream.lookahead(3).getText());
    assertEquals("d", stream.lookahead(5).getText());
  }
コード例 #5
0
  /** Test method for {@link DefaultJavadocTokenStream#peek()}. */
  @Test
  public void testPeek() {
    DefaultJavadocTokenStream stream = stream("alphabets.txt");

    assertEquals("a", stream.peek().getText());
    assertEquals("a", stream.peek().getText());
    assertEquals("a", stream.peek().getText());

    stream.nextToken();

    assertEquals("b", stream.peek().getText());
    assertEquals("b", stream.peek().getText());
    assertEquals("b", stream.peek().getText());
  }
コード例 #6
0
  /** Test method for {@link DefaultJavadocTokenStream#mark()}. */
  @Test
  public void testMark() {
    DefaultJavadocTokenStream stream = stream("blank-lines.txt");
    stream.mark();
    assertEquals("a", stream.nextToken().getText());
    stream.mark();
    assertEquals("b", stream.nextToken().getText());
    stream.mark();
    assertEquals("c", stream.nextToken().getText());
    stream.mark();
    assertEquals("d", stream.nextToken().getText());

    stream.rewind();
    assertEquals("d", stream.nextToken().getText());
    stream.rewind();
    assertEquals("c", stream.nextToken().getText());
    stream.rewind();
    assertEquals("b", stream.nextToken().getText());
    stream.rewind();
    assertEquals("a", stream.nextToken().getText());
  }