From 058087e15a0d25c1f10995b1cc602801d339ef8b Mon Sep 17 00:00:00 2001 From: Speiger Date: Sat, 30 Oct 2021 07:21:41 +0200 Subject: [PATCH] Added some more tests for some of the new functions --- .../ints/base/BaseIntCollectionTest.java | 25 +++++++++++++++++++ .../ints/base/BaseIntListTest.java | 21 ++++++++++++++++ .../src/collections/tests/CollectionTest.java | 2 ++ .../src/collections/tests/ListTest.java | 2 ++ 4 files changed, 50 insertions(+) diff --git a/src/test/java/speiger/src/collections/ints/base/BaseIntCollectionTest.java b/src/test/java/speiger/src/collections/ints/base/BaseIntCollectionTest.java index c9f0cc97..f670a2e7 100644 --- a/src/test/java/speiger/src/collections/ints/base/BaseIntCollectionTest.java +++ b/src/test/java/speiger/src/collections/ints/base/BaseIntCollectionTest.java @@ -118,6 +118,14 @@ public abstract class BaseIntCollectionTest extends BaseIntIterableTest Assert.assertTrue(collection.removeAll(Arrays.asList(IntArrays.wrap(CONTAINS_ARRAY)))); } + @Test + public void testRemoveAllListener() { + if(!getValidCollectionTests().contains(CollectionTest.REMOVE_ALL_LISTENER)) return; + IntCollection collection = create(TEST_ARRAY); + Assert.assertTrue(collection.removeAll(create(CONTAINS_ARRAY), T -> {})); + Assert.assertFalse(collection.removeAll(create(CONTAINS_ARRAY), T -> Assert.assertTrue(false))); + } + @Test public void testRetainAll() { if(!getValidCollectionTests().contains(CollectionTest.RETAIN_ALL)) return; @@ -135,6 +143,23 @@ public abstract class BaseIntCollectionTest extends BaseIntIterableTest Assert.assertTrue(collection.isEmpty()); } + @Test + public void testRetainAllListener() { + if(!getValidCollectionTests().contains(CollectionTest.RETAIN_ALL_LISTENER)) return; + IntCollection collection = create(TEST_ARRAY); + IntCollection retained = create(CONTAINS_ARRAY); + Assert.assertTrue(collection.retainAll(retained, T -> {})); + Assert.assertFalse(collection.retainAll(retained, T -> Assert.assertTrue(false))); + Assert.assertEquals(CONTAINS_ARRAY.length, collection.size()); + int[] retainedArray = retained.toIntArray(); + int[] collectionArray = collection.toIntArray(); + IntArrays.stableSort(retainedArray); + IntArrays.stableSort(collectionArray); + Assert.assertArrayEquals(retainedArray, collectionArray); + collection.retainAll(IntCollections.EMPTY, T -> {}); + Assert.assertTrue(collection.isEmpty()); + } + @Test public void testToArray() { if(!getValidCollectionTests().contains(CollectionTest.TO_ARRAY)) return; diff --git a/src/test/java/speiger/src/collections/ints/base/BaseIntListTest.java b/src/test/java/speiger/src/collections/ints/base/BaseIntListTest.java index f903da8f..702b8618 100644 --- a/src/test/java/speiger/src/collections/ints/base/BaseIntListTest.java +++ b/src/test/java/speiger/src/collections/ints/base/BaseIntListTest.java @@ -64,6 +64,16 @@ public abstract class BaseIntListTest extends BaseIntCollectionTest for(int i = 0;i