@Test(timeout = 200) public void testRemove() { addBasic(); for (int i = 0; i < 5; i++) { list.remove(i); } assertEquals( "Size isn't being decremented correctly when removing from" + " the list", 6, list.size()); for (int i = 5; i < 10; i++) { list.remove(i); } assertEquals( "Size isn't being decremented correctly when removing from" + " the list", 1, list.size()); list.remove(10); assertEquals("Size should be 0 on an empty list", 0, list.size()); }
@Test(timeout = 200) public void testEmptyBasic() { assertNull(list.first()); assertNull(list.last()); assertNull(list.get(1)); assertNull(list.remove(1)); assertEquals( "Empty set not being returned for an empty list", list.dataSet(), new HashSet<Integer>()); }
@Test(timeout = 10000) public void stressTesting_String() { Random r = new Random(98); Set<String> set = new HashSet<>(); for (int i = 0; i < 50; i++) { String str = Character.toString((char) (r.nextInt(90) + 33)); if (r.nextBoolean()) { set.add(str); if (!listString.contains(str)) { listString.put(str); } } else { set.remove(str); listString.remove(str); } } assertEquals("Check your remove method", set, listString.dataSet()); assertEquals("Size isn't being decremented correctly", set.size(), listString.dataSet().size()); }
@Test(timeout = 1000) public void stressTesting_AddAndRemove() { Random r = new Random(System.currentTimeMillis()); Set<Integer> set = new HashSet<>(); for (int i = 0; i < 1000; i++) { Integer num = r.nextInt(); if (r.nextBoolean()) { set.add(num); if (!list.contains(num)) { list.put(num); } } else { set.remove(num); list.remove(num); } } assertEquals("Check your remove method", set, list.dataSet()); assertEquals("Size isn't being decremented correctly", set.size(), list.dataSet().size()); }
@Test(timeout = 1000) public void testRemoveNull() { assertEquals(null, list.remove(2)); }
@Test(timeout = 1000, expected = IllegalArgumentException.class) public void testIllegalRemove() { list.remove(null); }