@@ -3,15 +3,16 @@ package org.utbot.fuzzing
3
3
import kotlinx.coroutines.runBlocking
4
4
import org.junit.jupiter.api.Assertions.*
5
5
import org.junit.jupiter.api.Test
6
- import org.junit.jupiter.api.assertDoesNotThrow
7
6
import org.utbot.framework.plugin.api.MethodId
8
7
import org.utbot.framework.plugin.api.TestIdentityPreservingIdGenerator
8
+ import org.utbot.framework.plugin.api.UtAssembleModel
9
9
import org.utbot.framework.plugin.api.UtPrimitiveModel
10
10
import org.utbot.framework.plugin.api.util.*
11
11
import org.utbot.fuzzer.FuzzedConcreteValue
12
12
import org.utbot.fuzzing.samples.DeepNested
13
13
import org.utbot.fuzzer.FuzzedType
14
14
import org.utbot.fuzzing.samples.AccessibleObjects
15
+ import org.utbot.fuzzing.samples.FailToGenerateListGeneric
15
16
import org.utbot.fuzzing.samples.Stubs
16
17
import org.utbot.fuzzing.utils.Trie
17
18
import java.lang.reflect.GenericArrayType
@@ -214,6 +215,30 @@ class JavaFuzzingTest {
214
215
assertEquals(0 , exec) { " Fuzzer should not create any values of private classes" }
215
216
}
216
217
218
+ @Test
219
+ fun `fuzzing generate single test in case of collection with fail-to-generate generic type` () {
220
+ val size = 100
221
+ var exec = size
222
+ val collections = ArrayList <Any ?>(exec)
223
+ runBlockingWithContext {
224
+ runJavaFuzzing(
225
+ TestIdentityPreservingIdGenerator ,
226
+ methodUnderTest = FailToGenerateListGeneric ::class .java.declaredMethods.first { it.name == " func" }.executableId,
227
+ constants = emptyList(),
228
+ names = emptyList()
229
+ ) { _, _, v ->
230
+ collections.add(v.first().model as ? UtAssembleModel )
231
+ BaseFeedback (Trie .emptyNode(), if (-- exec > 0 ) Control .CONTINUE else Control .STOP )
232
+ }
233
+ }
234
+ assertEquals(0 , exec) { " Total fuzzer run number must be 0" }
235
+ assertEquals(size, collections.size) { " Total generated values number must be $size " }
236
+ assertEquals(size, collections.count { it is UtAssembleModel }) { " Total assemble models size must be $size " }
237
+ collections.filterIsInstance<UtAssembleModel >().forEach {
238
+ assertEquals(0 , it.modificationsChain.size)
239
+ }
240
+ }
241
+
217
242
private fun <T > runBlockingWithContext (block : suspend () -> T ) : T {
218
243
return withUtContext(UtContext (this ::class .java.classLoader)) {
219
244
runBlocking {
0 commit comments