Example #1
0
 @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()));
 }
Example #2
0
 // 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));
 }
Example #3
0
 @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));
 }
Example #4
0
 @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));
   }
 }
Example #5
0
 // 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());
 }
Example #6
0
 @Test(expected = NoSuchElementException.class)
 public void getNotExistsElement() {
   map.put(1, 1l);
   map.get(0);
 }
Example #7
0
 // get
 @Test(expected = NullPointerException.class)
 public void getFromEmptyMap() {
   map.get(0);
 }
Example #8
0
 @After
 public void tearDown() {
   map.clear();
 }