use of org.eclipse.collections.api.map.primitive.LongLongMap in project mapdb by jankotek.
the class AbstractLongLongMapTestCase method average.
@Test
public void average() {
LongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
Assert.assertEquals(1.5, map.average(), 0.0);
LongLongMap map1 = this.newWithKeysValues(1L, 1L);
Assert.assertEquals(1.0, map1.average(), 0.0);
}
use of org.eclipse.collections.api.map.primitive.LongLongMap in project mapdb by jankotek.
the class AbstractLongLongMapTestCase method sum.
@Test
public void sum() {
LongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
Assert.assertEquals(6L, map.sum());
LongLongMap map2 = this.newWithKeysValues(2L, 2L, 3L, 3L, 4L, 4L);
Assert.assertEquals(9L, map2.sum());
LongLongMap map3 = this.newWithKeysValues(2L, 2L);
Assert.assertEquals(2L, map3.sum());
}
use of org.eclipse.collections.api.map.primitive.LongLongMap in project mapdb by jankotek.
the class AbstractLongLongMapTestCase method appendString.
@Test
public void appendString() {
Appendable appendable = new StringBuilder();
this.getEmptyMap().appendString(appendable);
Assert.assertEquals("", appendable.toString());
this.getEmptyMap().appendString(appendable, "/");
Assert.assertEquals("", appendable.toString());
this.getEmptyMap().appendString(appendable, "{", "/", "}");
Assert.assertEquals("{}", appendable.toString());
Appendable appendable0 = new StringBuilder();
this.newWithKeysValues(0L, 0L).appendString(appendable0);
Assert.assertEquals("0", appendable0.toString());
Appendable appendable01 = new StringBuilder();
this.newWithKeysValues(0L, 0L).appendString(appendable01, "/");
Assert.assertEquals("0", appendable01.toString());
Appendable appendable02 = new StringBuilder();
this.newWithKeysValues(0L, 0L).appendString(appendable02, "{", "/", "}");
Assert.assertEquals("{0}", appendable02.toString());
Appendable appendable1 = new StringBuilder();
this.newWithKeysValues(1L, 1L).appendString(appendable1);
Assert.assertEquals("1", appendable1.toString());
Appendable appendable2 = new StringBuilder();
this.newWithKeysValues(5L, 5L).appendString(appendable2);
Assert.assertEquals("5", appendable2.toString());
Appendable appendable3 = new StringBuilder();
LongLongMap map1 = this.newWithKeysValues(0L, 0L, 1L, 1L);
map1.appendString(appendable3);
Assert.assertTrue(appendable3.toString(), "0, 1".equals(appendable3.toString()) || "1, 0".equals(appendable3.toString()));
Appendable appendable4 = new StringBuilder();
LongLongMap map2 = this.newWithKeysValues(1L, 1L, 32L, 32L);
map2.appendString(appendable4, "[", "/", "]");
Assert.assertTrue(appendable4.toString(), "[1/32]".equals(appendable4.toString()) || "[32/1]".equals(appendable4.toString()));
Appendable appendable5 = new StringBuilder();
LongLongMap map3 = this.newWithKeysValues(1L, 1L, 32L, 32L);
map3.appendString(appendable5, "[", "/", "]");
Assert.assertTrue(appendable5.toString(), "[1/32]".equals(appendable5.toString()) || "[32/1]".equals(appendable5.toString()));
Appendable appendable6 = new StringBuilder();
map1.appendString(appendable6, "/");
Assert.assertTrue(appendable6.toString(), "0/1".equals(appendable6.toString()) || "1/0".equals(appendable6.toString()));
}
use of org.eclipse.collections.api.map.primitive.LongLongMap in project mapdb by jankotek.
the class AbstractLongLongMapTestCase method toBag.
@Test
public void toBag() {
LongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
Assert.assertEquals(LongHashBag.newBagWith(0L, 1L, 2L, 3L), map.toBag());
Assert.assertEquals(LongHashBag.newBagWith(), this.getEmptyMap().toBag());
Assert.assertEquals(LongHashBag.newBagWith(1L), this.newWithKeysValues(1L, 1L).toBag());
}
use of org.eclipse.collections.api.map.primitive.LongLongMap in project mapdb by jankotek.
the class AbstractLongLongMapTestCase method select.
@Test
public void select() {
LongLongMap map = this.newWithKeysValues(0L, 0L, 1L, 1L, 2L, 2L, 3L, 3L);
LongLongMap actual1 = map.select((long key, long value) -> key == 1L || value == 3L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(1L, 1L, 3L, 3L), actual1);
LongLongMap actual2 = map.select((long key, long value) -> key == 0L || value == 2L);
Assert.assertEquals(LongLongHashMap.newWithKeysValues(0L, 0L, 2L, 2L), actual2);
}
Aggregations