Skip to content

Commit fcf7c58

Browse files
committed
Generate assert true in cross-reference relationship
1 parent 1f812d9 commit fcf7c58

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
839839

840840
// if model is already processed, so we don't want to add new statements
841841
if (fieldModel in visitedModels) {
842+
currentBlock += testFrameworkManager.getDeepEqualsAssertion(expected, actual).toStatement()
842843
return
843844
}
844845

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
package org.utbot.examples.codegen.deepequals
2+
3+
import org.junit.jupiter.api.Disabled
4+
import org.junit.jupiter.api.Test
5+
import org.utbot.examples.DoNotCalculate
6+
import org.utbot.examples.UtValueTestCaseChecker
7+
import org.utbot.examples.eq
8+
import org.utbot.framework.codegen.CodeGeneration
9+
import org.utbot.framework.plugin.api.CodegenLanguage
10+
11+
class ClassWithCrossReferenceRelationshipTest : UtValueTestCaseChecker(
12+
testClass = ClassWithCrossReferenceRelationship::class,
13+
testCodeGeneration = true,
14+
languagePipelines = listOf(
15+
CodeGenerationLanguageLastStage(CodegenLanguage.JAVA),
16+
CodeGenerationLanguageLastStage(CodegenLanguage.KOTLIN, CodeGeneration)
17+
)
18+
) {
19+
// TODO: The test is disabled due to [https://github.com/UnitTestBot/UTBotJava/issues/812]
20+
@Disabled
21+
@Test
22+
fun testClassWithCrossReferenceRelationship() {
23+
check(
24+
ClassWithCrossReferenceRelationship::returnFirstClass,
25+
eq(2),
26+
coverage = DoNotCalculate
27+
)
28+
}
29+
}

utbot-framework/src/test/kotlin/org/utbot/examples/codegen/deepequals/ClassWithNullableFieldTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class ClassWithNullableFieldTest : UtValueTestCaseChecker(
1616
)
1717
) {
1818
@Test
19-
fun testClassWithNullableField() {
19+
fun testClassWithNullableFieldInCompound() {
2020
check(
2121
ClassWithNullableField::returnCompoundWithNullableField,
2222
eq(2),
@@ -25,7 +25,7 @@ class ClassWithNullableFieldTest : UtValueTestCaseChecker(
2525
}
2626

2727
@Test
28-
fun testClassWithNullableField1() {
28+
fun testClassWithNullableFieldInGreatCompound() {
2929
check(
3030
ClassWithNullableField::returnGreatCompoundWithNullableField,
3131
eq(3),
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package org.utbot.examples.codegen.deepequals;
2+
3+
class FirstClass {
4+
SecondClass secondClass;
5+
6+
FirstClass(SecondClass second) {
7+
this.secondClass = second;
8+
}
9+
}
10+
11+
class SecondClass {
12+
FirstClass firstClass;
13+
14+
SecondClass(FirstClass first) {
15+
this.firstClass = first;
16+
}
17+
}
18+
19+
public class ClassWithCrossReferenceRelationship {
20+
public FirstClass returnFirstClass(int value) {
21+
if (value == 0) {
22+
return new FirstClass(new SecondClass(null));
23+
} else {
24+
FirstClass first = new FirstClass(null);
25+
first.secondClass = new SecondClass(first);
26+
27+
return first;
28+
}
29+
}
30+
}

0 commit comments

Comments
 (0)