Skip to content

Commit 17126eb

Browse files
Correct asserts on booleans in parametrized tests (#303)
Correct asserts on booleans in parametrized tests
1 parent ff035e5 commit 17126eb

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgMethodConstructor.kt

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,15 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
534534
doubleDelta
535535
)
536536
expectedModel.value is Boolean -> {
537-
if (expectedModel.value as Boolean) {
538-
assertions[assertTrue](actual)
539-
} else {
540-
assertions[assertFalse](actual)
537+
when (parameterizedTestSource) {
538+
ParametrizedTestSource.DO_NOT_PARAMETRIZE ->
539+
if (expectedModel.value as Boolean) {
540+
assertions[assertTrue](actual)
541+
} else {
542+
assertions[assertFalse](actual)
543+
}
544+
ParametrizedTestSource.PARAMETRIZE ->
545+
assertions[assertEquals](expected, actual)
541546
}
542547
}
543548
// other primitives and string
@@ -1018,10 +1023,14 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
10181023
)
10191024
}
10201025
expected == nullLiteral() -> testFrameworkManager.assertNull(actual)
1021-
expected is CgLiteral && expected.value is Boolean -> testFrameworkManager.assertBoolean(
1022-
expected.value,
1023-
actual
1024-
)
1026+
expected is CgLiteral && expected.value is Boolean -> {
1027+
when (parameterizedTestSource) {
1028+
ParametrizedTestSource.DO_NOT_PARAMETRIZE ->
1029+
testFrameworkManager.assertBoolean(expected.value, actual)
1030+
ParametrizedTestSource.PARAMETRIZE ->
1031+
testFrameworkManager.assertEquals(expected, actual)
1032+
}
1033+
}
10251034
else -> {
10261035
if (expected is CgLiteral) {
10271036
// Literal can only be Primitive or String, can use equals here

0 commit comments

Comments
 (0)