< prev index next >
test/java/util/stream/bootlib/java.base/java/util/stream/LambdaTestHelpers.java
Print this page
*** 45,54 ****
--- 45,55 ----
import java.util.function.ToIntFunction;
import java.util.function.ToLongFunction;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
+ import static org.testng.Assert.assertFalse;
/**
* LambdaTestHelpers -- assertion methods and useful objects for lambda test cases
*/
public class LambdaTestHelpers {
*** 398,407 ****
--- 399,422 ----
public static<T> void assertContentsUnordered(Iterator<T> actual, Iterator<T> expected) {
assertEquals(toBoxedMultiset(actual), toBoxedMultiset(expected));
}
+ public static<T> void assertContains(Optional<T> actual, Iterator<T> it) {
+ if (actual.isPresent()) {
+ T r = actual.get();
+ boolean contained = false;
+ while (!contained && it.hasNext()) {
+ contained = Objects.equals(r, it.next());
+ }
+ assertTrue(contained);
+ }
+ else {
+ assertFalse(it.hasNext());
+ }
+ }
+
public static void launderAssertion(Runnable r, Supplier<String> additionalInfo) {
try {
r.run();
}
catch (AssertionError ae) {
< prev index next >