예제 #1
0
 @Test
 public void testMultiple() {
   BufferedReader br = new BufferedReader(new StringReader("my cat my cat my cat my cat"));
   CompoundWordIterator it = new CompoundWordIterator(br, myCat);
   for (int i = 0; i < 4; ++i) assertEquals("my cat", it.next());
   assertFalse(it.hasNext());
 }
예제 #2
0
 @Test
 public void testNext() {
   BufferedReader br = new BufferedReader(new StringReader("my cat is big"));
   CompoundWordIterator it = new CompoundWordIterator(br, myCat);
   assertEquals("my cat", it.next());
   assertEquals("is", it.next());
   assertEquals("big", it.next());
   assertFalse(it.hasNext());
 }
예제 #3
0
 @Test
 public void testNextWithEmptyMiddleNewlines() {
   BufferedReader br = new BufferedReader(new StringReader("my\ncat\n\n\n\n\nis\nbig"));
   CompoundWordIterator it = new CompoundWordIterator(br, myCat);
   assertEquals("my cat", it.next());
   assertEquals("is", it.next());
   assertEquals("big", it.next());
   assertFalse(it.hasNext());
 }
예제 #4
0
  @Test
  public void testCompoundsWithSameStart() {

    BufferedReader br = new BufferedReader(new StringReader("my cat my dog my chicken"));
    Set<String> compounds = new HashSet<String>();
    compounds.add("my cat");
    compounds.add("my dog");
    CompoundWordIterator it = new CompoundWordIterator(br, compounds);
    assertEquals("my cat", it.next());
    assertEquals("my dog", it.next());
    assertEquals("my", it.next());
    assertEquals("chicken", it.next());
    assertFalse(it.hasNext());
  }