Skip to content

Commit

Permalink
Improve tests of mapMulti()
Browse files Browse the repository at this point in the history
  • Loading branch information
julgus committed Aug 30, 2023
1 parent 5633faa commit 17050cd
Showing 1 changed file with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

import com.speedment.jpastreamer.javasixteen.Java16StreamUtil;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.EnabledForJreRange;
import org.junit.jupiter.api.condition.JRE;

import java.util.Arrays;
import java.util.concurrent.atomic.AtomicInteger;
Expand All @@ -23,6 +25,7 @@
import java.util.stream.Stream;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

final class AutoClosingStreamTest extends AbstractAutoClosingStreamTest<Integer, Stream<Integer>> {

Expand Down Expand Up @@ -183,34 +186,75 @@ void findAny() {
}

@Test
@EnabledForJreRange(min = JRE.JAVA_16)
void toList() { testTerminal(Java16StreamUtil::toList); }

@Test
@EnabledForJreRange(min = JRE.JAVA_16)
void mapMulti() { testIntermediate(s -> Java16StreamUtil.mapMulti(s, ((i, mapper) -> {
if (EVEN.test(i)) {
mapper.accept(i);
}
}))); }

@Test
void mapMultiToInt() { testTerminal(s -> Java16StreamUtil.mapMultiToDouble(s, ((i, mapper) -> {
@EnabledForJreRange(min = JRE.JAVA_16)
void mapMultiToInt16() { testTerminal(s -> Java16StreamUtil.mapMultiToInt(s, ((i, mapper) -> {
if (EVEN.test(i)) {
mapper.accept(i);
}
})).boxed().collect(Collectors.toList())); }

@Test
@EnabledForJreRange(max = JRE.JAVA_15)
void mapMultiToInt() {
Exception exception = assertThrows(UnsupportedOperationException.class, () -> {
testTerminal(s -> Java16StreamUtil.mapMultiToInt(s, ((i, mapper) -> {
if (EVEN.test(i)) {
mapper.accept(i);
}
})).boxed().collect(Collectors.toList()));
});
}

@Test
void mapMultiToDouble() { testTerminal(s -> Java16StreamUtil.mapMultiToDouble(s, ((i, mapper) -> {
@EnabledForJreRange(min = JRE.JAVA_16)
void mapMultiToDouble16() { testTerminal(s -> Java16StreamUtil.mapMultiToDouble(s, ((i, mapper) -> {
if (EVEN.test(i)) {
mapper.accept(i);
}
})).boxed().collect(Collectors.toList())); }

@Test
void mapMultiToLong() { testTerminal(s -> Java16StreamUtil.mapMultiToLong(s, ((i, mapper) -> {
@EnabledForJreRange(max = JRE.JAVA_15)
void mapMultiToDouble() {
Exception exception = assertThrows(UnsupportedOperationException.class, () -> {
testTerminal(s -> Java16StreamUtil.mapMultiToDouble(s, ((i, mapper) -> {
if (EVEN.test(i)) {
mapper.accept(i);
}
})).boxed().collect(Collectors.toList()));
});
}

@Test
@EnabledForJreRange(min = JRE.JAVA_16)
void mapMultiToLong16() { testTerminal(s -> Java16StreamUtil.mapMultiToLong(s, ((i, mapper) -> {
if (EVEN.test(i)) {
mapper.accept(i);
}
})).boxed().collect(Collectors.toList())); }

@Test
@EnabledForJreRange(max = JRE.JAVA_15)
void mapMultiToLong() {
Exception exception = assertThrows(UnsupportedOperationException.class, () -> {
testTerminal(s -> Java16StreamUtil.mapMultiToLong(s, ((i, mapper) -> {
if (EVEN.test(i)) {
mapper.accept(i);
}
})).boxed().collect(Collectors.toList()));
});
}

}

0 comments on commit 17050cd

Please sign in to comment.