Skip to content

Commit d401783

Browse files
author
Kamenev Yury
committed
Added any collection test
1 parent 9a4322c commit d401783

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

utbot-framework/src/test/kotlin/org/utbot/examples/lambda/SimpleLambdaExamplesTest.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package org.utbot.examples.lambda
33
import org.junit.jupiter.api.Disabled
44
import org.junit.jupiter.api.Test
55
import org.utbot.examples.AbstractTestCaseGeneratorTest
6-
import org.utbot.examples.DoNotCalculate
76
import org.utbot.examples.eq
87
import org.utbot.examples.isException
98

@@ -13,7 +12,7 @@ class SimpleLambdaExamplesTest : AbstractTestCaseGeneratorTest(testClass = Simpl
1312
checkWithException(
1413
SimpleLambdaExamples::biFunctionLambdaExample,
1514
eq(2),
16-
{ a, b, r -> b == 0 && r.isException<ArithmeticException>() },
15+
{ _, b, r -> b == 0 && r.isException<ArithmeticException>() },
1716
{ a, b, r -> b != 0 && r.getOrThrow() == a / b },
1817
)
1918
}
@@ -29,4 +28,4 @@ class SimpleLambdaExamplesTest : AbstractTestCaseGeneratorTest(testClass = Simpl
2928
// TODO coverage calculation fails https://github.com/UnitTestBot/UTBotJava/issues/192
3029
)
3130
}
32-
}
31+
}

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,17 @@ class BaseStreamExampleTest : AbstractTestCaseGeneratorTest(
341341
)
342342
}
343343

344+
@Test
345+
fun testAnyCollectionStreamExample() {
346+
check(
347+
BaseStreamExample::anyCollectionStreamExample,
348+
ignoreExecutionsNumber,
349+
{ c, r -> c.isEmpty() && r == 0L },
350+
{ c, r -> c.isNotEmpty() && c.size.toLong() == r },
351+
coverage = FullWithAssumptions(assumeCallsNumber = 1)
352+
)
353+
}
354+
344355
@Test
345356
fun testGenerateExample() {
346357
check(

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,16 @@ long customCollectionStreamExample(CustomCollection<Integer> customCollection) {
423423
}
424424
}
425425

426+
long anyCollectionStreamExample(Collection<Integer> c) {
427+
UtMock.assume(c != null);
428+
429+
if (c.isEmpty()) {
430+
return c.stream().count();
431+
} else {
432+
return c.stream().count();
433+
}
434+
}
435+
426436
Integer[] generateExample() {
427437
return Stream.generate(() -> 42).limit(10).toArray(Integer[]::new);
428438
}

0 commit comments

Comments
 (0)