Skip to content

Commit ae027d0

Browse files
author
Kamenev Yury
committed
Fixed failed test
1 parent 8907139 commit ae027d0

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

utbot-framework/src/test/kotlin/org/utbot/examples/stream/BaseStreamExampleTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ class BaseStreamExampleTest : AbstractTestCaseGeneratorTest(
162162
BaseStreamExample::complexReduceExample,
163163
ignoreExecutionsNumber,
164164
{ c, r -> c.isEmpty() && c.sumOf { it.toDouble() } + 42.0 == r },
165+
{ c, _ -> c.isNotEmpty() && null in c },
165166
{ c, r -> c.isNotEmpty() && c.sumOf { it.toDouble() } + 42.0 == r },
166167
coverage = DoNotCalculate
167168
)

utbot-sample/src/main/java/org/utbot/examples/stream/BaseStreamExample.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,16 @@ Optional<Integer> optionalReduceExample(List<Integer> list) {
151151
Double complexReduceExample(List<Integer> list) {
152152
UtMock.assume(list != null);
153153

154+
if (list.isEmpty()) {
155+
return list.stream().reduce(42.0, (Double a, Integer b) -> a + b.doubleValue(), Double::sum);
156+
}
157+
158+
if (list.contains(null)) {
159+
return list.stream().reduce(42.0, (Double a, Integer b) -> a + b.doubleValue(), Double::sum);
160+
}
161+
154162
return list.stream().reduce(42.0, (Double a, Integer b) -> a + b.doubleValue(), Double::sum);
155-
}
163+
}
156164

157165
Integer collectExample(List<Integer> list) {
158166
UtMock.assume(list != null);

0 commit comments

Comments
 (0)