Skip to content

Commit 00cca37

Browse files
committed
Properly create void models (for mocking void methods)
1 parent 63a7eda commit 00cca37

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

utbot-framework-api/src/main/kotlin/org/utbot/framework/plugin/api/util/IdUtil.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import org.utbot.framework.plugin.api.MethodId
1111
import org.utbot.framework.plugin.api.UtModel
1212
import org.utbot.framework.plugin.api.UtNullModel
1313
import org.utbot.framework.plugin.api.UtPrimitiveModel
14+
import org.utbot.framework.plugin.api.UtVoidModel
1415
import org.utbot.framework.plugin.api.id
1516
import soot.SootField
1617
import java.lang.reflect.Constructor
@@ -449,6 +450,7 @@ fun ClassId.defaultValueModel(): UtModel = when (this) {
449450
doubleClassId -> UtPrimitiveModel(0.0)
450451
booleanClassId -> UtPrimitiveModel(false)
451452
charClassId -> UtPrimitiveModel('\u0000')
453+
voidClassId -> UtVoidModel
452454
else -> UtNullModel(this)
453455
}
454456

utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/JavaLanguage.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ fun defaultValueProviders(idGenerator: IdentityPreservingIdGenerator<Int>) = lis
5050
IteratorValueProvider(idGenerator),
5151
EmptyCollectionValueProvider(idGenerator),
5252
DateValueProvider(idGenerator),
53+
VoidValueProvider,
5354
NullValueProvider,
5455
)
5556

utbot-java-fuzzing/src/main/kotlin/org/utbot/fuzzing/providers/Primitives.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.utbot.fuzzing.providers
22

33
import org.utbot.framework.plugin.api.ClassId
44
import org.utbot.framework.plugin.api.UtPrimitiveModel
5+
import org.utbot.framework.plugin.api.UtVoidModel
56
import org.utbot.framework.plugin.api.util.*
67
import org.utbot.fuzzer.FuzzedContext
78
import org.utbot.fuzzer.FuzzedContext.Comparison.*
@@ -236,4 +237,9 @@ object StringValueProvider : PrimitiveValueProvider(stringClassId, java.lang.Cha
236237
else -> false
237238
}
238239
}
240+
}
241+
242+
object VoidValueProvider : PrimitiveValueProvider(voidClassId) {
243+
override fun generate(description: FuzzedDescription, type: FuzzedType): Sequence<Seed<FuzzedType, FuzzedValue>> =
244+
sequenceOf(Seed.Simple(UtVoidModel.fuzzed { summary = "%var% = void" }))
239245
}

0 commit comments

Comments
 (0)