@@ -13,6 +13,7 @@ import org.utbot.tests.infrastructure.isException
13
13
import org.utbot.framework.plugin.api.CodegenLanguage
14
14
import org.utbot.testcheckers.eq
15
15
import org.utbot.testcheckers.withoutConcrete
16
+ import org.utbot.tests.infrastructure.AtLeast
16
17
import org.utbot.tests.infrastructure.CodeGeneration
17
18
import java.util.Optional
18
19
import java.util.stream.Stream
@@ -69,10 +70,46 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
69
70
fun testMapExample () {
70
71
checkWithException(
71
72
BaseStreamExample ::mapExample,
72
- eq( 2 ) ,
73
+ ignoreExecutionsNumber ,
73
74
{ c, r -> null in c && r.isException<NullPointerException >() },
74
75
{ c, r -> r.getOrThrow().contentEquals(c.map { it * 2 }.toTypedArray()) },
75
- coverage = DoNotCalculate
76
+ coverage = AtLeast (90 )
77
+ )
78
+ }
79
+
80
+ @Test
81
+ @Tag(" slow" )
82
+ fun testMapToIntExample () {
83
+ checkWithException(
84
+ BaseStreamExample ::mapToIntExample,
85
+ ignoreExecutionsNumber,
86
+ { c, r -> null in c && r.isException<NullPointerException >() },
87
+ { c, r -> r.getOrThrow().contentEquals(c.map { it.toInt() }.toIntArray()) },
88
+ coverage = AtLeast (90 )
89
+ )
90
+ }
91
+
92
+ @Test
93
+ @Tag(" slow" )
94
+ fun testMapToLongExample () {
95
+ checkWithException(
96
+ BaseStreamExample ::mapToLongExample,
97
+ ignoreExecutionsNumber,
98
+ { c, r -> null in c && r.isException<NullPointerException >() },
99
+ { c, r -> r.getOrThrow().contentEquals(c.map { it.toLong() }.toLongArray()) },
100
+ coverage = AtLeast (90 )
101
+ )
102
+ }
103
+
104
+ @Test
105
+ @Tag(" slow" )
106
+ fun testMapToDoubleExample () {
107
+ checkWithException(
108
+ BaseStreamExample ::mapToDoubleExample,
109
+ ignoreExecutionsNumber,
110
+ { c, r -> null in c && r.isException<NullPointerException >() },
111
+ { c, r -> r.getOrThrow().contentEquals(c.map { it.toDouble() }.toDoubleArray()) },
112
+ coverage = AtLeast (90 )
76
113
)
77
114
}
78
115
@@ -86,6 +123,37 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
86
123
)
87
124
}
88
125
126
+ @Test
127
+ @Tag(" slow" )
128
+ fun testFlatMapToIntExample () {
129
+ check(
130
+ BaseStreamExample ::flatMapToIntExample,
131
+ ignoreExecutionsNumber,
132
+ { c, r -> r.contentEquals(c.flatMap { listOf (it?.toInt() ? : 0 , it?.toInt() ? : 0 ) }.toIntArray()) },
133
+ coverage = FullWithAssumptions (assumeCallsNumber = 1 )
134
+ )
135
+ }
136
+
137
+ @Test
138
+ fun testFlatMapToLongExample () {
139
+ check(
140
+ BaseStreamExample ::flatMapToLongExample,
141
+ ignoreExecutionsNumber,
142
+ { c, r -> r.contentEquals(c.flatMap { listOf (it?.toLong() ? : 0L , it?.toLong() ? : 0L ) }.toLongArray()) },
143
+ coverage = FullWithAssumptions (assumeCallsNumber = 1 )
144
+ )
145
+ }
146
+
147
+ @Test
148
+ fun testFlatMapToDoubleExample () {
149
+ check(
150
+ BaseStreamExample ::flatMapToDoubleExample,
151
+ ignoreExecutionsNumber,
152
+ { c, r -> r.contentEquals(c.flatMap { listOf (it?.toDouble() ? : 0.0 , it?.toDouble() ? : 0.0 ) }.toDoubleArray()) },
153
+ coverage = FullWithAssumptions (assumeCallsNumber = 1 )
154
+ )
155
+ }
156
+
89
157
@Test
90
158
@Tag(" slow" )
91
159
fun testDistinctExample () {
@@ -146,17 +214,17 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
146
214
fun testForEachExample () {
147
215
checkThisAndStaticsAfter(
148
216
BaseStreamExample ::forEachExample,
149
- eq( 2 ) ,
217
+ ignoreExecutionsNumber ,
150
218
* streamConsumerStaticsMatchers,
151
- coverage = DoNotCalculate
219
+ coverage = AtLeast ( 92 )
152
220
)
153
221
}
154
222
155
223
@Test
156
224
fun testToArrayExample () {
157
225
check(
158
226
BaseStreamExample ::toArrayExample,
159
- ignoreExecutionsNumber ,
227
+ eq( 2 ) ,
160
228
{ c, r -> c.toTypedArray().contentEquals(r) },
161
229
coverage = FullWithAssumptions (assumeCallsNumber = 1 )
162
230
)
@@ -311,10 +379,11 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
311
379
fun testIteratorExample () {
312
380
checkWithException(
313
381
BaseStreamExample ::iteratorSumExample,
314
- eq(2 ),
382
+ ignoreExecutionsNumber,
383
+ { c, r -> c.isEmpty() && r.getOrThrow() == 0 },
315
384
{ c, r -> null in c && r.isException<NullPointerException >() },
316
- { c, r -> null !in c && r.getOrThrow() == c.sum() },
317
- coverage = DoNotCalculate
385
+ { c, r -> c.isNotEmpty() && null !in c && r.getOrThrow() == c.sum() },
386
+ coverage = AtLeast ( 75 )
318
387
)
319
388
}
320
389
@@ -393,15 +462,15 @@ class BaseStreamExampleTest : UtValueTestCaseChecker(
393
462
coverage = Full
394
463
)
395
464
}
465
+ }
396
466
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
467
+ internal val streamConsumerStaticsMatchers = arrayOf(
468
+ { _: Any , c: List <Int ?>, _: StaticsType , _: Int? -> null in c },
469
+ { _: Any , c: List <Int ?>, statics: StaticsType , r: Int? ->
470
+ val x = statics.values.single().value as Int
401
471
402
- r!! + c.sumOf { it ? : 0 } == x
403
- }
404
- )
405
- }
472
+ r!! + c.sumOf { it ? : 0 } == x
473
+ }
474
+ )
406
475
407
- private fun <E : Comparable <E >> Sequence<E>.isSorted (): Boolean = zipWithNext { a, b -> a <= b }.all { it }
476
+ internal fun <E : Comparable <E >> Sequence<E>.isSorted (): Boolean = zipWithNext { a, b -> a <= b }.all { it }
0 commit comments