Skip to content
Permalink
Browse files
Merge branch 'pr-233'
This closes #233
  • Loading branch information
kinow committed Oct 9, 2021
2 parents 699abc8 + ff0fabd commit cee61e4b761cf57eaa12629ca875c6ca7ae46b38
Showing 81 changed files with 910 additions and 967 deletions.
@@ -291,6 +291,9 @@
<action type="update" dev="kinow" due-to="Dependabot">
Bump easymock from 4.2 to 4.3 #226.
</action>
<action issue="COLLECTIONS-793" type="update" dev="kinow" due-to="Arturo Bernal">
Simplify Assertion.
</action>
</release>
<release version="4.4" date="2019-07-05" description="Maintenance release.">
<action issue="COLLECTIONS-710" dev="ggregory" type="fix" due-to="Yu Shi, Gary Gregory">
@@ -104,7 +104,7 @@ public void testObjectEqualsSelf() {

public void testEqualsNull() {
final Object obj = makeObject();
assertEquals(false, obj.equals(null)); // make sure this doesn't throw NPE either
assertFalse(obj.equals(null)); // make sure this doesn't throw NPE either
}

public void testObjectHashCodeEqualsSelfHashCode() {
@@ -124,9 +124,7 @@ public void testObjectHashCodeEqualsContract() {
assertEquals(
"[2] When two objects are equal, their hashCodes should be also.",
obj1.hashCode(), obj2.hashCode());
assertTrue(
"When obj1.equals(obj2) is true, then obj2.equals(obj1) should also be true",
obj2.equals(obj1));
assertEquals("When obj1.equals(obj2) is true, then obj2.equals(obj1) should also be true", obj2, obj1);
}
}

@@ -66,7 +66,7 @@ public void testPushPeekPop() {
final ArrayStack<E> stack = makeObject();

stack.push((E) "First Item");
assertTrue("Stack is not empty", !stack.empty());
assertFalse("Stack is not empty", stack.empty());
assertEquals("Stack size is one", 1, stack.size());
assertEquals("Top item is 'First Item'",
"First Item", (String) stack.peek());
@@ -311,25 +311,25 @@ public void collateException2() {
public void collect() {
final Transformer<Number, Long> transformer = TransformerUtils.constantTransformer(2L);
Collection<Number> collection = CollectionUtils.<Integer, Number>collect(iterableA, transformer);
assertTrue(collection.size() == collectionA.size());
assertEquals(collection.size(), collectionA.size());
assertCollectResult(collection);

ArrayList<Number> list;
list = CollectionUtils.collect(collectionA, transformer, new ArrayList<Number>());
assertTrue(list.size() == collectionA.size());
assertEquals(list.size(), collectionA.size());
assertCollectResult(list);

Iterator<Integer> iterator = null;
list = CollectionUtils.collect(iterator, transformer, new ArrayList<Number>());

iterator = iterableA.iterator();
list = CollectionUtils.collect(iterator, transformer, list);
assertTrue(collection.size() == collectionA.size());
assertEquals(collection.size(), collectionA.size());
assertCollectResult(collection);

iterator = collectionA.iterator();
collection = CollectionUtils.<Integer, Number>collect(iterator, transformer);
assertTrue(collection.size() == collectionA.size());
assertEquals(collection.size(), collectionA.size());
assertTrue(collection.contains(2L) && !collection.contains(1));
collection = CollectionUtils.collect((Iterator<Integer>) null, (Transformer<Integer, Number>) null);
assertTrue(collection.isEmpty());
@@ -2140,9 +2140,9 @@ public void testSizeIsEmpty_List() {
@Test
public void testSizeIsEmpty_Map() {
final Map<String, String> map = new HashMap<>();
assertEquals(true, CollectionUtils.sizeIsEmpty(map));
assertTrue(CollectionUtils.sizeIsEmpty(map));
map.put("1", "a");
assertEquals(false, CollectionUtils.sizeIsEmpty(map));
assertFalse(CollectionUtils.sizeIsEmpty(map));
}

// -----------------------------------------------------------------------
@@ -57,7 +57,7 @@ public void getFromEnumeration() throws Exception {
} catch (final IndexOutOfBoundsException e) {
// expected
}
assertTrue(!en.hasMoreElements());
assertFalse(en.hasMoreElements());
}

@Test
@@ -75,13 +75,13 @@ public void testLastKey() {
public void testNextKey() {
resetEmpty();
OrderedBidiMap<K, V> bidi = (OrderedBidiMap<K, V>) map;
assertEquals(null, bidi.nextKey(getOtherKeys()[0]));
assertNull(bidi.nextKey(getOtherKeys()[0]));
if (!isAllowNullKey()) {
try {
assertEquals(null, bidi.nextKey(null)); // this is allowed too
assertNull(bidi.nextKey(null)); // this is allowed too
} catch (final NullPointerException ex) {}
} else {
assertEquals(null, bidi.nextKey(null));
assertNull(bidi.nextKey(null));
}

resetFull();
@@ -93,28 +93,28 @@ public void testNextKey() {
assertEquals(confirmedObject, bidi.nextKey(confirmedLast));
confirmedLast = confirmedObject;
}
assertEquals(null, bidi.nextKey(confirmedLast));
assertNull(bidi.nextKey(confirmedLast));

if (!isAllowNullKey()) {
try {
bidi.nextKey(null);
fail();
} catch (final NullPointerException ex) {}
} else {
assertEquals(null, bidi.nextKey(null));
assertNull(bidi.nextKey(null));
}
}

public void testPreviousKey() {
resetEmpty();
OrderedBidiMap<K, V> bidi = getMap();
assertEquals(null, bidi.previousKey(getOtherKeys()[0]));
assertNull(bidi.previousKey(getOtherKeys()[0]));
if (!isAllowNullKey()) {
try {
assertEquals(null, bidi.previousKey(null)); // this is allowed too
assertNull(bidi.previousKey(null)); // this is allowed too
} catch (final NullPointerException ex) {}
} else {
assertEquals(null, bidi.previousKey(null));
assertNull(bidi.previousKey(null));
}

resetFull();
@@ -128,15 +128,15 @@ public void testPreviousKey() {
assertEquals(confirmedObject, bidi.previousKey(confirmedLast));
confirmedLast = confirmedObject;
}
assertEquals(null, bidi.previousKey(confirmedLast));
assertNull(bidi.previousKey(confirmedLast));

if (!isAllowNullKey()) {
try {
bidi.previousKey(null);
fail();
} catch (final NullPointerException ex) {}
} else {
assertEquals(null, bidi.previousKey(null));
assertNull(bidi.previousKey(null));
}
}

@@ -851,7 +851,7 @@ public void testCollectionRemove() {
resetEmpty();
final E[] elements = getFullElements();
for (final E element : elements) {
assertTrue("Shouldn't remove nonexistent element", !getCollection().remove(element));
assertFalse("Shouldn't remove nonexistent element", getCollection().remove(element));
verify();
}

@@ -895,12 +895,10 @@ public void testCollectionRemoveAll() {
}

resetEmpty();
assertTrue("Empty collection removeAll should return false for empty input",
!getCollection().removeAll(Collections.EMPTY_SET));
assertFalse("Empty collection removeAll should return false for empty input", getCollection().removeAll(Collections.EMPTY_SET));
verify();

assertTrue("Empty collection removeAll should return false for nonempty input",
!getCollection().removeAll(new ArrayList<>(getCollection())));
assertFalse("Empty collection removeAll should return false for nonempty input", getCollection().removeAll(new ArrayList<>(getCollection())));
verify();

resetFull();
@@ -334,9 +334,9 @@ public void testRemoveAll() {
final Collection<E> removing = new ArrayList<>(one);
c.addComposited(one, two);
c.removeAll(removing);
assertTrue(!c.contains("1"));
assertTrue(!one.contains("1"));
assertTrue(!two.contains("1"));
assertFalse(c.contains("1"));
assertFalse(one.contains("1"));
assertFalse(two.contains("1"));
c.removeAll(null);
assertFalse(c.contains("1"));
assertFalse(one.contains("1"));
@@ -356,13 +356,13 @@ public void testRemoveIf() {
final Predicate<E> predicate = e -> e == "1";
c.addComposited(one, two);
c.removeIf(predicate);
assertTrue(!c.contains("1"));
assertTrue(!one.contains("1"));
assertTrue(!two.contains("1"));
assertFalse(c.contains("1"));
assertFalse(one.contains("1"));
assertFalse(two.contains("1"));
c.removeIf(null);
assertTrue(!c.contains("1"));
assertTrue(!one.contains("1"));
assertTrue(!two.contains("1"));
assertFalse(c.contains("1"));
assertFalse(one.contains("1"));
assertFalse(two.contains("1"));
}

@SuppressWarnings("unchecked")
@@ -105,7 +105,7 @@ public void testEmptyIterator() {
final Iterator<E> it = makeEmptyIterator();

// hasNext() should return false
assertEquals("hasNext() should return false for empty iterators", false, it.hasNext());
assertFalse("hasNext() should return false for empty iterators", it.hasNext());

// next() should throw a NoSuchElementException
try {
@@ -129,7 +129,7 @@ public void testFullIterator() {
final Iterator<E> it = makeObject();

// hasNext() must be true (ensure makeFullIterator is correct!)
assertEquals("hasNext() should return true for at least one element", true, it.hasNext());
assertTrue("hasNext() should return true for at least one element", it.hasNext());

// next() must not throw exception (ensure makeFullIterator is correct!)
try {
@@ -95,9 +95,9 @@ public void testEmptyListIteratorIsIndeedEmpty() {

final ListIterator<E> it = makeEmptyIterator();

assertEquals(false, it.hasNext());
assertFalse(it.hasNext());
assertEquals(0, it.nextIndex());
assertEquals(false, it.hasPrevious());
assertFalse(it.hasPrevious());
assertEquals(-1, it.previousIndex());

// next() should throw a NoSuchElementException
@@ -126,8 +126,8 @@ public void testWalkForwardAndBack() {
}

// check state at end
assertEquals(false, it.hasNext());
assertEquals(true, it.hasPrevious());
assertFalse(it.hasNext());
assertTrue(it.hasPrevious());
try {
it.next();
fail("NoSuchElementException must be thrown from next at end of ListIterator");
@@ -144,8 +144,8 @@ public void testWalkForwardAndBack() {
}

// check state at start
assertEquals(true, it.hasNext());
assertEquals(false, it.hasPrevious());
assertTrue(it.hasNext());
assertFalse(it.hasPrevious());
try {
it.previous();
fail("NoSuchElementException must be thrown from previous at start of ListIterator");
@@ -177,7 +177,7 @@ public void testAdd() {
// add at start should be OK, added should not be next
it = makeObject();
it.add(addValue);
assertTrue(addValue != it.next());
assertNotSame(addValue, it.next());

// add in middle and at end should be OK
it = makeObject();
@@ -114,7 +114,7 @@ public void testEmptyMapIterator() {
}

final MapIterator<K, V> it = makeEmptyIterator();
assertEquals(false, it.hasNext());
assertFalse(it.hasNext());

// next() should throw a NoSuchElementException
try {
@@ -161,9 +161,9 @@ public void testFullMapIterator() {

final MapIterator<K, V> it = makeObject();
final Map<K, V> map = getMap();
assertEquals(true, it.hasNext());
assertTrue(it.hasNext());

assertEquals(true, it.hasNext());
assertTrue(it.hasNext());
final Set<K> set = new HashSet<>();
while (it.hasNext()) {
// getKey
@@ -193,7 +193,7 @@ public void testMapIteratorSet() {
final MapIterator<K, V> it = makeObject();
final Map<K, V> map = getMap();
final Map<K, V> confirmed = getConfirmedMap();
assertEquals(true, it.hasNext());
assertTrue(it.hasNext());
final K key = it.next();
final V value = it.getValue();

@@ -209,11 +209,11 @@ public void testMapIteratorSet() {
assertSame("Key must not change after setValue", key, it.getKey());
assertSame("Value must be changed after setValue", newValue, it.getValue());
assertSame("setValue must return old value", value, old);
assertEquals("Map must contain key", true, map.containsKey(key));
assertTrue("Map must contain key", map.containsKey(key));
// test against confirmed, as map may contain value twice
assertEquals("Map must not contain old value",
confirmed.containsValue(old), map.containsValue(old));
assertEquals("Map must contain new value", true, map.containsValue(newValue));
assertTrue("Map must contain new value", map.containsValue(newValue));
verify();

it.setValue(newValue); // same value - should be OK
@@ -234,7 +234,7 @@ public void testRemove() { // override
final MapIterator<K, V> it = makeObject();
final Map<K, V> map = getMap();
final Map<K, V> confirmed = getConfirmedMap();
assertEquals(true, it.hasNext());
assertTrue(it.hasNext());
final K key = it.next();

if (!supportsRemove()) {
@@ -248,7 +248,7 @@ public void testRemove() { // override

it.remove();
confirmed.remove(key);
assertEquals(false, map.containsKey(key));
assertFalse(map.containsKey(key));
verify();

try {
@@ -266,7 +266,7 @@ public void testMapIteratorSetRemoveSet() {
final MapIterator<K, V> it = makeObject();
final Map<K, V> confirmed = getConfirmedMap();

assertEquals(true, it.hasNext());
assertTrue(it.hasNext());
final K key = it.next();

it.setValue(newValue);
@@ -288,7 +288,7 @@ public void testMapIteratorRemoveGetKey() {
final MapIterator<K, V> it = makeObject();
final Map<K, V> confirmed = getConfirmedMap();

assertEquals(true, it.hasNext());
assertTrue(it.hasNext());
final K key = it.next();

it.remove();
@@ -309,7 +309,7 @@ public void testMapIteratorRemoveGetValue() {
final MapIterator<K, V> it = makeObject();
final Map<K, V> confirmed = getConfirmedMap();

assertEquals(true, it.hasNext());
assertTrue(it.hasNext());
final K key = it.next();

it.remove();

0 comments on commit cee61e4

Please sign in to comment.