Ejemplo n.º 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());
 }
Ejemplo n.º 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());
 }
Ejemplo n.º 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());
 }
Ejemplo n.º 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());
  }