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

Method testRemove

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

Source from the content-addressed store, hash-verified

247 }
248
249 public void testRemove() {
250 BinaryTree m = new BinaryTree();
251 LocalTestNode nodes[] = makeLocalNodes();
252
253 for (int k = 0; k < nodes.length; k++)
254 {
255 m.put(nodes[ k ].getKey(), nodes[ k ]);
256 }
257 try
258 {
259 m.remove(null);
260 fail("should have caught NullPointerException");
261 }
262 catch (NullPointerException ignored)
263 {
264 }
265 try
266 {
267 m.remove(new Object());
268 fail("should have caught ClassCastException");
269 }
270 catch (ClassCastException ignored)
271 {
272 }
273 assertNull(m.remove(Integer.valueOf(-1)));
274 try
275 {
276 m.remove("foo");
277 fail("should have caught ClassCastException");
278 }
279 catch (ClassCastException ignored)
280 {
281 }
282 for (int k = 0; k < nodes.length; k += 2)
283 {
284 Comparable key = nodes[ k ].getKey();
285
286 assertNotNull(m.get(key));
287 assertSame(nodes[ k ], m.remove(key));
288 assertNull(m.remove(key));
289 assertNull(m.get(key));
290 }
291 for (int k = 1; k < nodes.length; k += 2)
292 {
293 Comparable key = nodes[ k ].getKey();
294
295 assertNotNull(m.get(key));
296 assertSame(nodes[ k ], m.remove(key));
297 assertNull(m.remove(key));
298 assertNull(m.get(key));
299 }
300 assertTrue(m.isEmpty());
301 }
302
303 public void testPutAll() {
304 Map m = new BinaryTree();

Callers

nothing calls this directly

Calls 7

makeLocalNodesMethod · 0.95
putMethod · 0.95
removeMethod · 0.95
getMethod · 0.95
isEmptyMethod · 0.65
getKeyMethod · 0.45
valueOfMethod · 0.45

Tested by

no test coverage detected