@Test public void putValues() { // first 16 keys for (int i = 0; i < 16; i++) { assertTrue(map.put(i, random.nextLong())); } // not put assertFalse(map.put(random.nextInt(), random.nextLong())); }
// put @Test public void putNulls() { // first null key assertTrue(map.put(null, 1l)); // second -- not put assertFalse(map.put(null, 3l)); // first null value assertTrue(map.put(1, null)); // second -- also put assertTrue(map.put(3, null)); }
@Test public void getNulls() { // put some nulls (according to the test putNulls) map.put(null, 1l); // put map.put(null, 3l); // not put map.put(1, null); // put map.put(3, null); // put // check assertEquals((Long) 1l, map.get(null)); assertEquals(null, map.get(1)); assertEquals(null, map.get(3)); }
@Test public void getValues() { long[] testArray = new long[16]; long curValue; // put values for (int i = 0; i < 16; i++) { curValue = random.nextLong(); map.put(i, curValue); testArray[i] = curValue; } // check for (int i = 0; i < 16; i++) { assertEquals((Long) testArray[i], map.get(i)); } }
// size @Test public void resize() { assertEquals(0, map.size()); // first 16 keys for (int i = 0; i < 16; i++) { map.put(i, random.nextLong()); assertEquals(i + 1, map.size()); } assertEquals(16, map.size()); // not put assertFalse(map.put(random.nextInt(), random.nextLong())); assertEquals(16, map.size()); }
@Test(expected = NoSuchElementException.class) public void getNotExistsElement() { map.put(1, 1l); map.get(0); }
// get @Test(expected = NullPointerException.class) public void getFromEmptyMap() { map.get(0); }
@After public void tearDown() { map.clear(); }