@Test void isEmptyTest() { final HopscotchCollection<Integer> hopscotchCollection = new HopscotchCollection<>(); Assert.assertTrue(hopscotchCollection.isEmpty()); hopscotchCollection.add(1); Assert.assertFalse(hopscotchCollection.isEmpty()); }
@Test void resizeTest() { final HopscotchCollection<Integer> hopscotchCollection = new HopscotchCollection<>(1); final int N_ENTRIES = 1000000; for (int idx = 0; idx != N_ENTRIES; ++idx) { hopscotchCollection.add(idx); } Assert.assertEquals(hopscotchCollection.size(), N_ENTRIES); Assert.assertEquals(hopscotchCollection.stream().mapToInt(i -> i).min().orElse(-1), 0); Assert.assertEquals( hopscotchCollection.stream().mapToInt(i -> i).max().orElse(-1), N_ENTRIES - 1); }
@Test void sizeTest() { final HopscotchCollection<Integer> hopscotchCollection = new HopscotchCollection<>(); Assert.assertEquals(hopscotchCollection.size(), 0); hopscotchCollection.addAll(testVals); Assert.assertEquals(hopscotchCollection.size(), testVals.size()); hopscotchCollection.add(notInTestVals); Assert.assertEquals(hopscotchCollection.size(), testVals.size() + 1); hopscotchCollection.removeEach(notInTestVals); Assert.assertEquals(hopscotchCollection.size(), testVals.size()); hopscotchCollection.clear(); Assert.assertEquals(hopscotchCollection.size(), 0); }