Search in sources :

Example 1 with IterableOfInts

use of org.cactoos.iterable.IterableOfInts in project cactoos by yegor256.

the class FirstOfTest method returnsMatchingValueWithExceptionalFallback.

@Test
void returnsMatchingValueWithExceptionalFallback() {
    final int value = 2;
    new Assertion<>("Exception was not thrown", new FirstOf<>(i -> i >= value, new IterableOfInts(0, value), () -> {
        throw new IllegalArgumentException("This exception should not be thrown");
    }), new HasValue<>(value)).affirm();
}
Also used : IterableOfInts(org.cactoos.iterable.IterableOfInts) HasValue(org.llorllale.cactoos.matchers.HasValue) Test(org.junit.jupiter.api.Test)

Example 2 with IterableOfInts

use of org.cactoos.iterable.IterableOfInts in project cactoos by yegor256.

the class FirstOfTest method returnsMatchingValue.

@Test
void returnsMatchingValue() {
    final int value = 1;
    new Assertion<>("Must return the only matching element", new FirstOf<>(i -> i >= value, new IterableOfInts(0, value), () -> -1), new HasValue<>(value)).affirm();
}
Also used : IterableOfInts(org.cactoos.iterable.IterableOfInts) HasValue(org.llorllale.cactoos.matchers.HasValue) Test(org.junit.jupiter.api.Test)

Aggregations

IterableOfInts (org.cactoos.iterable.IterableOfInts)2 Test (org.junit.jupiter.api.Test)2 HasValue (org.llorllale.cactoos.matchers.HasValue)2