MCPcopy Create free account
hub / github.com/apache/poi / testKeySet

Method testKeySet

src/testcases/org/apache/poi/util/TestBinaryTree.java:391–536  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

389 }
390
391 public void testKeySet() {
392 testKeySet(new BinaryTree());
393 Map m = new BinaryTree();
394 LocalTestNode nodes[] = makeLocalNodes();
395
396 for (int k = 0; k < nodes.length; k++)
397 {
398 m.put(nodes[ k ].getKey(), nodes[ k ]);
399 }
400 testKeySet(m);
401 m = new BinaryTree();
402 for (int k = 0; k < nodes.length; k++)
403 {
404 m.put(nodes[ k ].getKey(), nodes[ k ]);
405 }
406 int count = m.size();
407
408 for (Iterator iter = m.keySet().iterator(); iter.hasNext(); )
409 {
410 iter.next();
411 iter.remove();
412 --count;
413 assertEquals(count, m.size());
414 }
415 assertTrue(m.isEmpty());
416 m = new BinaryTree();
417 for (int k = 0; k < nodes.length; k++)
418 {
419 m.put(nodes[ k ].getKey(), nodes[ k ]);
420 }
421 Set s = m.keySet();
422
423 try
424 {
425 s.remove(null);
426 fail("should have caught NullPointerException");
427 }
428 catch (NullPointerException ignored)
429 {
430 }
431 try
432 {
433 s.remove(new Object());
434 fail("should have caught ClassCastException");
435 }
436 catch (ClassCastException ignored)
437 {
438 }
439 for (int k = 0; k < nodes.length; k++)
440 {
441 Comparable key = nodes[ k ].getKey();
442
443 assertTrue(s.remove(key));
444 assertTrue(!s.contains(key));
445 assertTrue(!m.containsKey(key));
446 assertTrue(!m.containsValue(nodes[ k ]));
447 }
448 assertTrue(m.isEmpty());

Callers

nothing calls this directly

Calls 15

makeLocalNodesMethod · 0.95
putMethod · 0.95
getKeyMethod · 0.95
sizeMethod · 0.95
keySetMethod · 0.95
hasNextMethod · 0.95
nextMethod · 0.95
removeMethod · 0.95
containsKeyMethod · 0.95
containsValueMethod · 0.95
iteratorMethod · 0.65
isEmptyMethod · 0.65

Tested by

no test coverage detected