Breaking update

- Added: Optionals for the missing JDK ones.
- Removed: Default values for Reduce and FindFirst. Using Optionals
instead.
This commit is contained in:
2026-05-11 18:00:00 +02:00
parent c6f656ee66
commit 3d39d5526d
34 changed files with 597 additions and 297 deletions
@@ -25,6 +25,15 @@ public class FILE_KEY_TYPECollectionForEachTester KEY_GENERIC_TYPE extends ABSTR
collection.forEach(elements::add);
HELPERS.assertContentsAnyOrder(elements, createSamplesArray());
}
#ignore
@CollectionFeature.Require(absent = KNOWN_ORDER)
public void testIndexedForEachUnknownOrder() {
#endignore
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
collection.forEachIndexed((K, V) -> elements.add(V));
HELPERS.assertContentsAnyOrder(elements, createSamplesArray());
}
#ignore
@CollectionFeature.Require(absent = KNOWN_ORDER)
@@ -43,6 +52,15 @@ public class FILE_KEY_TYPECollectionForEachTester KEY_GENERIC_TYPE extends ABSTR
collection.forEach(elements::add);
assertEquals("Different ordered iteration", HELPERS.copyToList(getOrderedElements()), elements);
}
#ignore
@CollectionFeature.Require(KNOWN_ORDER)
public void testIndexedForEachKnownOrder() {
#endignore
LIST KEY_GENERIC_TYPE elements = new ARRAY_LISTBRACES();
collection.forEachIndexed((K, V) -> elements.add(V));
assertEquals("Different ordered iteration", HELPERS.copyToList(getOrderedElements()), elements);
}
#ignore
@CollectionFeature.Require(KNOWN_ORDER)
@@ -4,6 +4,12 @@ package speiger.src.testers.PACKAGE.tests.iterable;
import java.util.Objects;
#endif
#if JDK_TYPE
import java.util.OPTIONAL;
#else
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
#endif
import org.junit.Ignore;
import com.google.common.collect.testing.features.CollectionSize;
@@ -27,17 +33,17 @@ public class FILE_KEY_TYPEIterableFindFirstTester KEY_GENERIC_TYPE extends ABSTR
@CollectionSize.Require(absent = CollectionSize.ZERO)
#endignore
public void testIterableFindFirst_FindFirstElements() {
assertEquals("First Element should be found", e0(), container.findFirst(T -> KEY_EQUALS(T, e0())));
assertEquals("First Element should be found", e0(), container.findFirst(T -> KEY_EQUALS(T, e0())).SUPPLY_GET());
}
public void testIterableFindFirst_FindNothing() {
assertEquals("No element should be found", EMPTY_KEY_VALUE, container.findFirst(T -> KEY_EQUALS(T, e4())));
assertEquals("No element should be found", OPTIONAL.empty(), container.findFirst(T -> KEY_EQUALS(T, e4())));
}
#ignore
@CollectionSize.Require(CollectionSize.SEVERAL)
#endignore
public void testIterableFindFirst_FindLastElement() {
assertEquals("Last Element should be found", e2(), container.findFirst(T -> KEY_EQUALS(T, e2())));
assertEquals("Last Element should be found", e2(), container.findFirst(T -> KEY_EQUALS(T, e2())).SUPPLY_GET());
}
}
@@ -3,9 +3,16 @@ package speiger.src.testers.PACKAGE.tests.iterable;
#if TYPE_OBJECT
import java.util.Objects;
#endif
#if JDK_TYPE
import java.util.OPTIONAL;
#else
import speiger.src.collections.PACKAGE.functions.OPTIONAL;
#endif
import org.junit.Ignore;
import com.google.common.collect.testing.features.CollectionSize;
import speiger.src.testers.PACKAGE.tests.base.ABSTRACT_COLLECTION_TESTER;
@Ignore
@@ -29,7 +36,7 @@ public class FILE_KEY_TYPEIterableReduceTester KEY_GENERIC_TYPE extends ABSTRACT
}
public void testIterableReduce() {
assertEquals("The sum of the collection should match", getSum(), collection.reduce(this::sum));
assertEquals("The sum of the collection should match", size == CollectionSize.ZERO ? OPTIONAL.empty() : OPTIONAL.GET_OPTIONAL(getSum()), collection.reduce(this::sum));
}
public void testIterableExtraReduce() {