Ejemplo n.º 1
0
  /** Test of addAll method, of class DefaultIndexer. */
  @Test
  public void testAddAll() {
    DefaultIndexer<String> instance = new DefaultIndexer<String>();
    assertTrue(instance.isEmpty());

    instance.add("something");

    List<String> values = Arrays.asList("a", "c", new String("a"), null, "b");
    instance.addAll(values);

    assertEquals(5, instance.size());
    assertEquals(0, (int) instance.getIndex("something"));
    assertEquals(1, (int) instance.getIndex("a"));
    assertEquals(4, (int) instance.getIndex("b"));
    assertEquals(2, (int) instance.getIndex("c"));
    assertEquals(3, (int) instance.getIndex(null));

    instance.addAll(values);
    assertEquals(0, (int) instance.getIndex("something"));
    assertEquals(1, (int) instance.getIndex("a"));
    assertEquals(4, (int) instance.getIndex("b"));
    assertEquals(2, (int) instance.getIndex("c"));
    assertEquals(3, (int) instance.getIndex(null));
  }
Ejemplo n.º 2
0
  /** Test of valueList method, of class DefaultIndexer. */
  @Test
  public void testValueList() {
    DefaultIndexer<String> instance = new DefaultIndexer<String>();
    assertTrue(instance.valueList().isEmpty());

    instance.add("something");
    assertEquals(1, instance.valueSet().size());
    assertTrue(instance.valueList().contains("something"));

    List<String> values = Arrays.asList("a", "c", new String("a"), null, "b");
    instance.addAll(values);
    assertEquals(5, instance.valueList().size());
    assertTrue(instance.valueList().contains("something"));
    assertTrue(instance.valueList().containsAll(values));
  }