Пример #1
0
 @Test
 public void testGetFromEmpty() {
   OpenIntToFieldHashMap<Fraction> map = new OpenIntToFieldHashMap<Fraction>(field);
   Assert.assertTrue(field.getZero().equals(map.get(5)));
   Assert.assertTrue(field.getZero().equals(map.get(0)));
   Assert.assertTrue(field.getZero().equals(map.get(50)));
 }
Пример #2
0
  @Test
  public void testGetAbsent() {
    Map<Integer, Fraction> generated = generateAbsent();
    OpenIntToFieldHashMap<Fraction> map = createFromJavaMap(field);

    for (Map.Entry<Integer, Fraction> mapEntry : generated.entrySet())
      Assert.assertTrue(field.getZero().equals(map.get(mapEntry.getKey())));
  }
Пример #3
0
  @Test
  public void testRemoveAbsent() {
    Map<Integer, Fraction> generated = generateAbsent();

    OpenIntToFieldHashMap<Fraction> map = createFromJavaMap(field);
    int mapSize = map.size();

    for (Map.Entry<Integer, Fraction> mapEntry : generated.entrySet()) {
      map.remove(mapEntry.getKey());
      Assert.assertEquals(mapSize, map.size());
      Assert.assertTrue(field.getZero().equals(map.get(mapEntry.getKey())));
    }
  }
Пример #4
0
  @Test
  public void testRemove() {
    OpenIntToFieldHashMap<Fraction> map = createFromJavaMap(field);
    int mapSize = javaMap.size();
    Assert.assertEquals(mapSize, map.size());
    for (Map.Entry<Integer, Fraction> mapEntry : javaMap.entrySet()) {
      map.remove(mapEntry.getKey());
      Assert.assertEquals(--mapSize, map.size());
      Assert.assertTrue(field.getZero().equals(map.get(mapEntry.getKey())));
    }

    /* Ensure that put and get still work correctly after removals */
    assertPutAndGet(map);
  }