Test of remove method, of class IntDoubleMap.
()
| 337 | * Test of remove method, of class IntDoubleMap. |
| 338 | */ |
| 339 | @Test |
| 340 | public void testRemove_int() |
| 341 | { |
| 342 | System.out.println("remove"); |
| 343 | Integer key = null; |
| 344 | Double value = null; |
| 345 | |
| 346 | Map<Integer, Double> truthMap = new HashMap<Integer, Double>(); |
| 347 | IntDoubleMap idMap = new IntDoubleMap(); |
| 348 | |
| 349 | int MAX = TEST_SIZE/2; |
| 350 | for(int i = 0; i < MAX; i++) |
| 351 | { |
| 352 | key = Integer.valueOf(rand.nextInt(MAX)); |
| 353 | value = Double.valueOf(rand.nextInt(1000)); |
| 354 | |
| 355 | Double prevTruth = truthMap.put(key, value); |
| 356 | Double prev = idMap.put(key, value); |
| 357 | assertEquals(prevTruth, prev); |
| 358 | assertEquals(truthMap.size(), idMap.size()); |
| 359 | } |
| 360 | |
| 361 | assertEntriesAreEqual(truthMap, idMap); |
| 362 | |
| 363 | |
| 364 | for(int i = 0; i < MAX/4; i++) |
| 365 | { |
| 366 | key = Integer.valueOf(rand.nextInt(MAX)); |
| 367 | |
| 368 | Double prevTruth = truthMap.remove(key); |
| 369 | Double prev = idMap.remove(key.intValue()); |
| 370 | if(prev.isNaN()) |
| 371 | prev = null; |
| 372 | assertEquals(prevTruth, prev); |
| 373 | assertEquals(truthMap.size(), idMap.size()); |
| 374 | } |
| 375 | |
| 376 | |
| 377 | assertEntriesAreEqual(truthMap, idMap); |
| 378 | } |
| 379 | |
| 380 | /** |
| 381 | * Test of containsKey method, of class IntDoubleMap. |