Skip to content

DeepEquals: generate absent assertion #813

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -839,6 +839,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c

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

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.utbot.examples.codegen.deepequals

import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import org.utbot.examples.DoNotCalculate
import org.utbot.examples.UtValueTestCaseChecker
import org.utbot.examples.eq
import org.utbot.framework.codegen.CodeGeneration
import org.utbot.framework.plugin.api.CodegenLanguage

class ClassWithCrossReferenceRelationshipTest : UtValueTestCaseChecker(
testClass = ClassWithCrossReferenceRelationship::class,
testCodeGeneration = true,
languagePipelines = listOf(
CodeGenerationLanguageLastStage(CodegenLanguage.JAVA),
CodeGenerationLanguageLastStage(CodegenLanguage.KOTLIN, CodeGeneration)
)
) {
// TODO: The test is disabled due to [https://github.com/UnitTestBot/UTBotJava/issues/812]
@Disabled
@Test
fun testClassWithCrossReferenceRelationship() {
check(
ClassWithCrossReferenceRelationship::returnFirstClass,
eq(2),
coverage = DoNotCalculate
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ClassWithNullableFieldTest : UtValueTestCaseChecker(
)
) {
@Test
fun testClassWithNullableField() {
fun testClassWithNullableFieldInCompound() {
check(
ClassWithNullableField::returnCompoundWithNullableField,
eq(2),
Expand All @@ -25,7 +25,7 @@ class ClassWithNullableFieldTest : UtValueTestCaseChecker(
}

@Test
fun testClassWithNullableField1() {
fun testClassWithNullableFieldInGreatCompound() {
check(
ClassWithNullableField::returnGreatCompoundWithNullableField,
eq(3),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package org.utbot.examples.codegen.deepequals;

class FirstClass {
SecondClass secondClass;

FirstClass(SecondClass second) {
this.secondClass = second;
}
}

class SecondClass {
FirstClass firstClass;

SecondClass(FirstClass first) {
this.firstClass = first;
}
}

public class ClassWithCrossReferenceRelationship {
public FirstClass returnFirstClass(int value) {
if (value == 0) {
return new FirstClass(new SecondClass(null));
} else {
FirstClass first = new FirstClass(null);
first.secondClass = new SecondClass(first);

return first;
}
}
}