@@ -155,7 +155,6 @@ import org.utbot.framework.plugin.api.util.shortClassId
155
155
import org.utbot.framework.plugin.api.util.shortWrapperClassId
156
156
import org.utbot.framework.plugin.api.util.stringClassId
157
157
import org.utbot.framework.plugin.api.util.voidClassId
158
- import org.utbot.framework.plugin.api.util.wrapPrimitives
159
158
import org.utbot.framework.util.isUnit
160
159
import org.utbot.summary.SummarySentenceConstants.TAB
161
160
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl
@@ -431,15 +430,22 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
431
430
* Generates result assertions in parameterized tests for successful executions
432
431
* and just runs the method if all executions are unsuccessful.
433
432
*/
434
- private fun generateAssertionsForParameterizedTest (method : MethodId , expectedResult : CgVariable ) {
433
+ private fun generateAssertionsForParameterizedTest () {
435
434
emptyLineIfNeeded()
435
+ val method = currentExecutable as MethodId
436
436
currentExecution!! .result
437
437
.onSuccess { result ->
438
438
if (result.isUnit()) {
439
439
+ thisInstance[method](* methodArguments.toTypedArray())
440
440
} else {
441
441
resultModel = result
442
442
443
+ val expected = variableConstructor.parameterizedVariable(
444
+ result.classId,
445
+ expectedResultVarName,
446
+ isNotNull = true
447
+ )
448
+
443
449
val actualVariableName = when (codegenLanguage) {
444
450
CodegenLanguage .JAVA -> when (method.returnType) {
445
451
intClassId -> " ${intWrapperClassId.simpleName.capitalize()} .valueOf(actual)"
@@ -455,7 +461,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
455
461
CodegenLanguage .KOTLIN -> " actual"
456
462
}
457
463
458
- assertEquality(expectedResult , CgVariable (actualVariableName, method.returnType))
464
+ assertEquality(expected , CgVariable (actualVariableName, method.returnType))
459
465
}
460
466
}
461
467
.onFailure { thisInstance[method](* methodArguments.toTypedArray()).intercepted() }
@@ -1248,19 +1254,15 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1248
1254
argument.name, argument.type, isReferenceType = ! argument.type.isPrimitive
1249
1255
)
1250
1256
}
1251
-
1252
1257
val method = currentExecutable as MethodId
1253
1258
val containsFailureExecution = containsFailureExecution(testSet)
1254
1259
1255
- val expectedResult = variableConstructor.parameterizedVariable(
1256
- method.returnType.wrapPrimitives(),
1257
- expectedResultVarName,
1258
- )
1260
+ val expectedResultClassId = wrapTypeIfRequired(method.returnType)
1259
1261
1260
- if (method.returnType != voidClassId) {
1262
+ if (expectedResultClassId != voidClassId) {
1261
1263
testArguments + = CgParameterDeclaration (
1262
- expectedResult ,
1263
- isReferenceType = containsFailureExecution || ! expectedResult.type. isPrimitive,
1264
+ expectedResultVarName, resultClassId(expectedResultClassId) ,
1265
+ isReferenceType = containsFailureExecution || ! expectedResultClassId. isPrimitive
1264
1266
)
1265
1267
}
1266
1268
if (containsFailureExecution) {
@@ -1273,7 +1275,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1273
1275
1274
1276
// record result and generate result assertions
1275
1277
recordActualResult()
1276
- generateAssertionsForParameterizedTest(method, expectedResult )
1278
+ generateAssertionsForParameterizedTest()
1277
1279
}
1278
1280
1279
1281
methodType = PARAMETRIZED
@@ -1537,6 +1539,18 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
1537
1539
private fun containsFailureExecution (testSet : UtMethodTestSet ) =
1538
1540
testSet.executions.any { it.result is UtExecutionFailure }
1539
1541
1542
+ private fun resultClassId (returnType : ClassId ): ClassId = when (returnType) {
1543
+ booleanClassId -> booleanWrapperClassId
1544
+ byteClassId -> byteWrapperClassId
1545
+ charClassId -> charWrapperClassId
1546
+ shortClassId -> shortWrapperClassId
1547
+ intClassId -> intWrapperClassId
1548
+ longClassId -> longWrapperClassId
1549
+ floatClassId -> floatWrapperClassId
1550
+ doubleClassId -> doubleWrapperClassId
1551
+ else -> returnType
1552
+ }
1553
+
1540
1554
/* *
1541
1555
* A [ClassId] for Class<Throwable>.
1542
1556
*/
0 commit comments