Skip to content

Commit 9f47eed

Browse files
authored
Replace nullFuzzedValue with primitive-aware defaultFuzzedValue (#2449)
* Replace `nullFuzzedValue` with primitive-aware `defaultFuzzedValue` * Use `defaultFuzzedValue` only in `FieldValueProvider`
1 parent 8dd947c commit 9f47eed

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class FieldValueProvider(
3939
val thisInstanceValue = values.single()
4040
val thisInstanceModel = when (val model = thisInstanceValue.model) {
4141
is UtReferenceModel -> model
42-
is UtNullModel -> return@Create nullFuzzedValue(type.classId)
42+
is UtNullModel -> return@Create defaultFuzzedValue(type.classId)
4343
else -> {
4444
logger.warn { "This instance model can be only UtReferenceModel or UtNullModel, but $model is met" }
45-
return@Create nullFuzzedValue(type.classId)
45+
return@Create defaultFuzzedValue(type.classId)
4646
}
4747
}
4848
UtAssembleModel(
@@ -62,7 +62,7 @@ class FieldValueProvider(
6262
}
6363
},
6464
modify = emptySequence(),
65-
empty = nullRoutine(type.classId)
65+
empty = defaultValueRoutine(type.classId)
6666
)
6767
)
6868
}

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

Lines changed: 8 additions & 1 deletion
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.UtNullModel
5+
import org.utbot.framework.plugin.api.util.defaultValueModel
56
import org.utbot.fuzzer.FuzzedType
67
import org.utbot.fuzzer.FuzzedValue
78
import org.utbot.fuzzer.fuzzed
@@ -11,4 +12,10 @@ fun nullRoutine(classId: ClassId): Routine.Empty<FuzzedType, FuzzedValue> =
1112
Routine.Empty { nullFuzzedValue(classId) }
1213

1314
fun nullFuzzedValue(classId: ClassId): FuzzedValue =
14-
UtNullModel(classId).fuzzed { summary = "%var% = null" }
15+
UtNullModel(classId).fuzzed { summary = "%var% = null" }
16+
17+
fun defaultValueRoutine(classId: ClassId): Routine.Empty<FuzzedType, FuzzedValue> =
18+
Routine.Empty { defaultFuzzedValue(classId) }
19+
20+
fun defaultFuzzedValue(classId: ClassId): FuzzedValue =
21+
classId.defaultValueModel().fuzzed { summary = "%var% = $model" }

0 commit comments

Comments
 (0)