@@ -3,6 +3,7 @@ package org.utbot.examples.stream
33import org.junit.jupiter.api.Disabled
44import org.junit.jupiter.api.Tag
55import org.junit.jupiter.api.Test
6+ import org.utbot.examples.AtLeast
67import org.utbot.examples.UtValueTestCaseChecker
78import org.utbot.examples.DoNotCalculate
89import org.utbot.examples.Full
@@ -69,10 +70,43 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
6970 fun testMapExample () {
7071 checkWithException(
7172 BaseStreamExample ::mapExample,
72- eq( 2 ) ,
73+ ignoreExecutionsNumber ,
7374 { c, r -> null in c && r.isException<NullPointerException >() },
7475 { c, r -> r.getOrThrow().contentEquals(c.map { it * 2 }.toTypedArray()) },
75- coverage = DoNotCalculate
76+ coverage = AtLeast (90 )
77+ )
78+ }
79+
80+ @Test
81+ fun testMapToIntExample () {
82+ checkWithException(
83+ BaseStreamExample ::mapToIntExample,
84+ ignoreExecutionsNumber,
85+ { c, r -> null in c && r.isException<NullPointerException >() },
86+ { c, r -> r.getOrThrow().contentEquals(c.map { it.toInt() }.toIntArray()) },
87+ coverage = AtLeast (90 )
88+ )
89+ }
90+
91+ @Test
92+ fun testMapToLongExample () {
93+ checkWithException(
94+ BaseStreamExample ::mapToLongExample,
95+ ignoreExecutionsNumber,
96+ { c, r -> null in c && r.isException<NullPointerException >() },
97+ { c, r -> r.getOrThrow().contentEquals(c.map { it.toLong() }.toLongArray()) },
98+ coverage = AtLeast (90 )
99+ )
100+ }
101+
102+ @Test
103+ fun testMapToDoubleExample () {
104+ checkWithException(
105+ BaseStreamExample ::mapToDoubleExample,
106+ ignoreExecutionsNumber,
107+ { c, r -> null in c && r.isException<NullPointerException >() },
108+ { c, r -> r.getOrThrow().contentEquals(c.map { it.toDouble() }.toDoubleArray()) },
109+ coverage = AtLeast (90 )
76110 )
77111 }
78112
@@ -86,6 +120,36 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
86120 )
87121 }
88122
123+ @Test
124+ fun testFlatMapToIntExample () {
125+ check(
126+ BaseStreamExample ::flatMapToIntExample,
127+ ignoreExecutionsNumber,
128+ { c, r -> r.contentEquals(c.flatMap { listOf (it?.toInt() ? : 0 , it?.toInt() ? : 0 ) }.toIntArray()) },
129+ coverage = FullWithAssumptions (assumeCallsNumber = 1 )
130+ )
131+ }
132+
133+ @Test
134+ fun testFlatMapToLongExample () {
135+ check(
136+ BaseStreamExample ::flatMapToLongExample,
137+ ignoreExecutionsNumber,
138+ { c, r -> r.contentEquals(c.flatMap { listOf (it?.toLong() ? : 0L , it?.toLong() ? : 0L ) }.toLongArray()) },
139+ coverage = FullWithAssumptions (assumeCallsNumber = 1 )
140+ )
141+ }
142+
143+ @Test
144+ fun testFlatMapToDoubleExample () {
145+ check(
146+ BaseStreamExample ::flatMapToDoubleExample,
147+ ignoreExecutionsNumber,
148+ { c, r -> r.contentEquals(c.flatMap { listOf (it.toDouble(), it.toDouble()) }.toDoubleArray()) },
149+ coverage = FullWithAssumptions (assumeCallsNumber = 1 )
150+ )
151+ }
152+
89153 @Test
90154 fun testDistinctExample () {
91155 check(
@@ -145,17 +209,17 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
145209 fun testForEachExample () {
146210 checkThisAndStaticsAfter(
147211 BaseStreamExample ::forEachExample,
148- eq( 2 ) ,
212+ ignoreExecutionsNumber ,
149213 * streamConsumerStaticsMatchers,
150- coverage = DoNotCalculate
214+ coverage = AtLeast ( 92 )
151215 )
152216 }
153217
154218 @Test
155219 fun testToArrayExample () {
156220 check(
157221 BaseStreamExample ::toArrayExample,
158- ignoreExecutionsNumber ,
222+ eq( 2 ) ,
159223 { c, r -> c.toTypedArray().contentEquals(r) },
160224 coverage = FullWithAssumptions (assumeCallsNumber = 1 )
161225 )
@@ -310,10 +374,11 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
310374 fun testIteratorExample () {
311375 checkWithException(
312376 BaseStreamExample ::iteratorSumExample,
313- eq(2 ),
377+ ignoreExecutionsNumber,
378+ { c, r -> c.isEmpty() && r.getOrThrow() == 0 },
314379 { c, r -> null in c && r.isException<NullPointerException >() },
315- { c, r -> null !in c && r.getOrThrow() == c.sum() },
316- coverage = DoNotCalculate
380+ { c, r -> c.isNotEmpty() && null !in c && r.getOrThrow() == c.sum() },
381+ coverage = AtLeast ( 75 )
317382 )
318383 }
319384
@@ -393,15 +458,15 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
393458 coverage = Full
394459 )
395460 }
461+ }
396462
397- private val streamConsumerStaticsMatchers = arrayOf(
398- { _: BaseStreamExample , c: List <Int ?>, _: StaticsType , _: Int? -> null in c },
399- { _: BaseStreamExample , c: List <Int ?>, statics: StaticsType , r: Int? ->
400- val x = statics.values.single().value as Int
463+ internal val streamConsumerStaticsMatchers = arrayOf(
464+ { _: Any , c: List <Int ?>, _: StaticsType , _: Int? -> null in c },
465+ { _: Any , c: List <Int ?>, statics: StaticsType , r: Int? ->
466+ val x = statics.values.single().value as Int
401467
402- r!! + c.sumOf { it ? : 0 } == x
403- }
404- )
405- }
468+ r!! + c.sumOf { it ? : 0 } == x
469+ }
470+ )
406471
407- private fun <E : Comparable <E >> Sequence<E>.isSorted (): Boolean = zipWithNext { a, b -> a <= b }.all { it }
472+ internal fun <E : Comparable <E >> Sequence<E>.isSorted (): Boolean = zipWithNext { a, b -> a <= b }.all { it }
0 commit comments