From 4f8c448f236e32bc38c4e534212b90f0d0e1b33c Mon Sep 17 00:00:00 2001 From: amandelpie Date: Tue, 28 Jun 2022 13:36:44 +0300 Subject: [PATCH 1/4] Repair testPow --- .../examples/SummaryTestCaseGeneratorTest.kt | 2 + .../src/test/kotlin/math/SummaryIntMath.kt | 227 ++++++++++-------- 2 files changed, 130 insertions(+), 99 deletions(-) diff --git a/utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt b/utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt index 443bee938e..11be2fcdb7 100644 --- a/utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt +++ b/utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt @@ -109,6 +109,8 @@ open class SummaryTestCaseGeneratorTest( /** * It removes from the String all whitespaces, tabs etc. * + * Also, it replaces all randomly added words from [nextSynonyms] that totally influence on the determinism in test name generation. + * * @see Explanation of the used regular expression. */ private fun String.normalize(): String { diff --git a/utbot-summary-tests/src/test/kotlin/math/SummaryIntMath.kt b/utbot-summary-tests/src/test/kotlin/math/SummaryIntMath.kt index 37e4ad24ee..2604ce0573 100644 --- a/utbot-summary-tests/src/test/kotlin/math/SummaryIntMath.kt +++ b/utbot-summary-tests/src/test/kotlin/math/SummaryIntMath.kt @@ -2,114 +2,143 @@ package math import examples.SummaryTestCaseGeneratorTest import guava.examples.math.IntMath -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Tag import org.junit.jupiter.api.Test +import org.utbot.examples.DoNotCalculate +import org.utbot.framework.plugin.api.MockStrategyApi -@Disabled class SummaryIntMath : SummaryTestCaseGeneratorTest( IntMath::class, ) { - - //TODO SAT-1205 - @Test - fun testLog2() { - checkOneArgument( - IntMath::log2, - summaryKeys = listOf() - ) - } - @Test fun testPow() { - val summaryPow1 = "
\n" +
-                "Test activates switch case: {@code 2}, returns from: {@code return 1;}\n" +
-                "
" - val summaryPow2 = "
\n" +
-                "Test executes conditions:\n" +
-                "    {@code (k < Integer.SIZE): False}\n" +
-                "returns from: {@code return 0;}\n" +
-                "
" - val summaryPow3 = "
\n" +
-                "Test executes conditions:\n" +
-                "    {@code ((k < Integer.SIZE)): False}\n" +
-                "returns from: {@code return (k < Integer.SIZE) ? (1 << k) : 0;}\n" +
-                "
" - val summaryPow4 = "
\n" +
-                "Test iterates the loop {@code for(int accum = 1; ; k >>= 1)} once,\n" +
-                "    inside this loop, the test returns from: {@code return b * accum;}\n" +
-                "
" - val summaryPow5 = "
\n" +
-                "Test executes conditions:\n" +
-                "    {@code ((k < Integer.SIZE)): True}\n" +
-                "returns from: {@code return (k < Integer.SIZE) ? (1 << k) : 0;}\n" +
-                "
" - val summaryPow6 = "
\n" +
-                "Test executes conditions:\n" +
-                "    {@code ((k == 0)): False}\n" +
-                "returns from: {@code return (k == 0) ? 1 : 0;}\n" +
-                "
" - val summaryPow7 = "
\n" +
-                "Test iterates the loop {@code for(int accum = 1; ; k >>= 1)} once,\n" +
-                "    inside this loop, the test returns from: {@code return accum;}\n" +
-                "
" - val summaryPow8 = "
\n" +
-                "Test executes conditions:\n" +
-                "    {@code ((k == 0)): True}\n" +
-                "returns from: {@code return (k == 0) ? 1 : 0;}\n" +
-                "
" - val summaryPow9 = "
\n" +
-                "Test executes conditions:\n" +
-                "    {@code (k < Integer.SIZE): True},\n" +
-                "    {@code (((k & 1) == 0)): True}\n" +
-                "returns from: {@code return ((k & 1) == 0) ? (1 << k) : -(1 << k);}\n" +
-                "
" - val summaryPow10 = "
\n" +
-                "Test iterates the loop {@code for(int accum = 1; ; k >>= 1)} twice,\n" +
+        val summary1 = "Test activates switch case: 2, returns from: return 1;\n"
+        val summary2 = "Test executes conditions:\n" +
+                "    (k < Integer.SIZE): False\n" +
+                "returns from: return 0;\n"
+        val summary3 = "Test executes conditions:\n" +
+                "    ((k < Integer.SIZE)): False\n" +
+                "returns from: return (k < Integer.SIZE) ? (1 << k) : 0;\n"
+        val summary4 = "Test iterates the loop for(int accum = 1; ; k >>= 1) once,\n" +
+                "    inside this loop, the test returns from: return b * accum;"
+        val summary5 = "Test executes conditions:\n" +
+                "    ((k < Integer.SIZE)): True\n" +
+                "returns from: return (k < Integer.SIZE) ? (1 << k) : 0;\n"
+        val summary6 = "Test executes conditions:\n" +
+                "    ((k == 0)): False\n" +
+                "returns from: return (k == 0) ? 1 : 0;\n"
+        val summary7 = "Test iterates the loop for(int accum = 1; ; k >>= 1) once,\n" +
+                "    inside this loop, the test returns from: return accum;"
+        val summary8 = "Test executes conditions:\n" +
+                "    ((k == 0)): True\n" +
+                "returns from: return (k == 0) ? 1 : 0;\n"
+        val summary9 = "Test executes conditions:\n" +
+                "    (k < Integer.SIZE): True,\n" +
+                "    (((k & 1) == 0)): True\n" +
+                "returns from: return ((k & 1) == 0) ? (1 << k) : -(1 << k);\n"
+        val summary10 = "Test executes conditions:\n" +
+                "    (k < Integer.SIZE): True,\n" +
+                "    (((k & 1) == 0)): False\n" +
+                "returns from: return ((k & 1) == 0) ? (1 << k) : -(1 << k);\n"
+        val summary11 = "Test executes conditions:\n" +
+                "    (((k & 1) == 0)): False\n" +
+                "returns from: return ((k & 1) == 0) ? 1 : -1;\n"
+        val summary12 = "Test executes conditions:\n" +
+                "    (((k & 1) == 0)): True\n" +
+                "returns from: return ((k & 1) == 0) ? 1 : -1;\n"
+        val summary13 = "Test iterates the loop for(int accum = 1; ; k >>= 1) twice,\n" +
                 "    inside this loop, the test executes conditions:\n" +
-                "    {@code (((k & 1) == 0)): False}\n" +
-                ", returns from: {@code return b * accum;}\n" +
-                "
" - val summaryPow11 = "
\n" +
-                "Test executes conditions:\n" +
-                "    {@code (((k & 1) == 0)): False}\n" +
-                "returns from: {@code return ((k & 1) == 0) ? 1 : -1;}\n" +
-                "
" - val summaryPow12 = "
\n" +
-                "Test executes conditions:\n" +
-                "    {@code (k < Integer.SIZE): True},\n" +
-                "    {@code (((k & 1) == 0)): False}\n" +
-                "returns from: {@code return ((k & 1) == 0) ? (1 << k) : -(1 << k);}\n" +
-                "
" - val summaryPow13 = "
\n" +
-                "Test executes conditions:\n" +
-                "    {@code (((k & 1) == 0)): True}\n" +
-                "returns from: {@code return ((k & 1) == 0) ? 1 : -1;}\n" +
-                "
" - val summaryPow14 = "
\n" +
-                "Test iterates the loop {@code for(int accum = 1; ; k >>= 1)} twice,\n" +
+                "    (((k & 1) == 0)): False\n" +
+                "returns from: return b * accum;"
+        val summmary14 = "Test iterates the loop for(int accum = 1; ; k >>= 1) twice,\n" +
                 "    inside this loop, the test executes conditions:\n" +
-                "    {@code (((k & 1) == 0)): True}\n" +
-                ", returns from: {@code return b * accum;}\n" +
-                "
" - checkOneArgument( - IntMath::pow, - summaryKeys = listOf( - summaryPow1, - summaryPow2, - summaryPow3, - summaryPow4, - summaryPow5, - summaryPow6, - summaryPow7, - summaryPow8, - summaryPow9, - summaryPow10, - summaryPow11, - summaryPow12, - summaryPow13, - summaryPow14 - ) + " (((k & 1) == 0)): True\n" + + "returns from: return b * accum;" + + val methodName1 = "testPow_Return1" + val methodName2 = "testPow_KGreaterOrEqualIntegerSIZE" + val methodName3 = "testPow_KGreaterOrEqualIntegerSIZE_1" + val methodName4 = "testPow_ReturnBMultiplyAccum" + val methodName5 = "testPow_KLessThanIntegerSIZE" + val methodName6 = "testPow_KNotEqualsZero" + val methodName7 = "testPow_ReturnAccum" + val methodName8 = "testPow_KEqualsZero" + val methodName9 = "testPow_KBitwiseAnd1EqualsZero" + val methodName10 = "testPow_KBitwiseAnd1NotEqualsZero" + val methodName11 = "testPow_KBitwiseAnd1NotEqualsZero_1" + val methodName12 = "testPow_KBitwiseAnd1EqualsZero_1" + val methodName13 = "testPow_KBitwiseAnd1NotEqualsZero_2" + val methodName14 = "testPow_KBitwiseAnd1EqualsZero_2" + + val displayName1 = "switch(b) case: 2 -> return 1" + val displayName2 = "k < Integer.SIZE : False -> return 0" + val displayName3 = "k < Integer.SIZE : False -> return (k < Integer.SIZE) ? (1 << k) : 0" + val displayName4 = "-> return b * accum" + val displayName5 = "k < Integer.SIZE : True -> return (k < Integer.SIZE) ? (1 << k) : 0" + val displayName6 = "k == 0 : False -> return (k == 0) ? 1 : 0" + val displayName7 = "-> return accum" + val displayName8 = "k == 0 : True -> return (k == 0) ? 1 : 0" + val displayName9 = "(k & 1) == 0 : True -> return ((k & 1) == 0) ? (1 << k) : -(1 << k)" + val displayName10 = "(k & 1) == 0 : False -> return ((k & 1) == 0) ? (1 << k) : -(1 << k)" + val displayName11 = "(k & 1) == 0 : False -> return ((k & 1) == 0) ? 1 : -1" + val displayName12 = "(k & 1) == 0 : True -> return ((k & 1) == 0) ? 1 : -1" + val displayName13 = "(k & 1) == 0 : False -> return b * accum" + val displayName14 = "(k & 1) == 0 : True -> return b * accum" + + val method = IntMath::pow + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2, + summary3, + summary4, + summary5, + summary6, + summary7, + summary8, + summary9, + summary10, + summary11, + summary12, + summary13, + summmary14 + ) + + val displayNames = listOf( + displayName1, + displayName2, + displayName3, + displayName4, + displayName5, + displayName6, + displayName7, + displayName8, + displayName9, + displayName10, + displayName11, + displayName12, + displayName13, + displayName14 ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3, + methodName4, + methodName5, + methodName6, + methodName7, + methodName8, + methodName9, + methodName10, + methodName11, + methodName12, + methodName13, + methodName14 + ) + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) } } \ No newline at end of file From aebff52c3949e63d7bdc20e48b571a930aa75da9 Mon Sep 17 00:00:00 2001 From: amandelpie Date: Tue, 28 Jun 2022 16:12:41 +0300 Subject: [PATCH 2/4] Repaired ReturnExampleTest tests --- .../examples/SummaryTestCaseGeneratorTest.kt | 2 +- .../algorithms/SummaryReturnExampleTest.kt | 793 ++++++++++-------- .../src/test/kotlin/math/SummaryIntMath.kt | 12 +- 3 files changed, 473 insertions(+), 334 deletions(-) diff --git a/utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt b/utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt index 11be2fcdb7..1ddf2f2076 100644 --- a/utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt +++ b/utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt @@ -144,7 +144,7 @@ open class SummaryTestCaseGeneratorTest( val notMatchedExecutions = this.filter { execution -> methodNames.none { methodName -> execution.testMethodName?.equals(methodName) == true } } - Assertions.assertTrue(notMatchedExecutions.isEmpty()) { "Not matched display names ${summaries(notMatchedExecutions)}" } + Assertions.assertTrue(notMatchedExecutions.isEmpty()) { "Not matched test names ${summaries(notMatchedExecutions)}" } } fun List.checkMatchersWithDisplayNames( diff --git a/utbot-summary-tests/src/test/kotlin/examples/algorithms/SummaryReturnExampleTest.kt b/utbot-summary-tests/src/test/kotlin/examples/algorithms/SummaryReturnExampleTest.kt index e2e5181004..aa25b7f508 100644 --- a/utbot-summary-tests/src/test/kotlin/examples/algorithms/SummaryReturnExampleTest.kt +++ b/utbot-summary-tests/src/test/kotlin/examples/algorithms/SummaryReturnExampleTest.kt @@ -1,366 +1,505 @@ package examples.algorithms import examples.SummaryTestCaseGeneratorTest -import org.junit.Ignore -import org.junit.jupiter.api.Disabled -import org.junit.jupiter.api.Tag import org.utbot.examples.algorithms.ReturnExample import org.junit.jupiter.api.Test -@Disabled +import org.utbot.examples.DoNotCalculate +import org.utbot.framework.plugin.api.MockStrategyApi + class SummaryReturnExampleTest : SummaryTestCaseGeneratorTest( ReturnExample::class, ) { - - val summaryCompare1 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (a < 0): True}\n" +
-            "returns from:\n" +
-            "    1st return statement: {@code return a;}\n" +
-            "
" - val summaryCompare2 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (a < 0): False},\n" +
-            "    {@code (b < 0): True}\n" +
-            "returns from:\n" +
-            "    1st return statement: {@code return a;}\n" +
-            "
" - val summaryCompare3 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (a < 0): False},\n" +
-            "    {@code (b < 0): False},\n" +
-            "    {@code (b == 10): True}\n" +
-            "returns from:\n" +
-            "    1st return statement: {@code return c;}\n" +
-            "
" - val summaryCompare4 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (a < 0): False},\n" +
-            "    {@code (b < 0): False},\n" +
-            "    {@code (b == 10): False},\n" +
-            "    {@code (a > b): False},\n" +
-            "    {@code (a < b): True}\n" +
-            "returns from:\n" +
-            "    2nd return statement: {@code return a;}\n" +
-            "
" - val summaryCompare5 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (a < 0): False},\n" +
-            "    {@code (b < 0): False},\n" +
-            "    {@code (b == 10): False},\n" +
-            "    {@code (a > b): True}\n" +
-            "returns from: {@code return b;}\n" +
-            "
" - val summaryCompare6 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (a < 0): False},\n" +
-            "    {@code (b < 0): False},\n" +
-            "    {@code (b == 10): False},\n" +
-            "    {@code (a > b): False},\n" +
-            "    {@code (a < b): False}\n" +
-            "returns from:\n" +
-            "    2nd return statement: {@code return c;}\n" +
-            "
" - @Test fun testCompare() { - checkTwoArguments( - ReturnExample::compare, - summaryKeys = listOf( - summaryCompare1, - summaryCompare2, - summaryCompare3, - summaryCompare4, - summaryCompare5, - summaryCompare6 - ), - displayNames = listOf( - "a < 0 : False -> return a", - "b < 0 : True -> return a", - "b == 10 : True -> return c", - "a < b : True -> return a", - "a > b : True -> return b", - "a < b : False -> return c" - ) + val summary1 = "Test executes conditions:\n" + + " (a < 0): True\n" + + "returns from:\n" + + " 1st return statement: return a;\n" + val summary2 = "Test executes conditions:\n" + + " (a < 0): False,\n" + + " (b < 0): True\n" + + "returns from:\n" + + " 1st return statement: return a;\n" + val summary3 = "Test executes conditions:\n" + + " (a < 0): False,\n" + + " (b < 0): False,\n" + + " (b == 10): True\n" + + "returns from:\n" + + " 1st return statement: return c;\n" + val summary4 = "Test executes conditions:\n" + + " (a < 0): False,\n" + + " (b < 0): False,\n" + + " (b == 10): False,\n" + + " (a > b): False,\n" + + " (a < b): True\n" + + "returns from:\n" + + " 2nd return statement: return a;\n" + val summary5 = "Test executes conditions:\n" + + " (a < 0): False,\n" + + " (b < 0): False,\n" + + " (b == 10): False,\n" + + " (a > b): False,\n" + + " (a < b): False\n" + + "returns from:\n" + + " 2nd return statement: return c;\n" + val summary6 = "Test executes conditions:\n" + + " (a < 0): False,\n" + + " (b < 0): False,\n" + + " (b == 10): False,\n" + + " (a > b): True\n" + + "returns from: return b;\n" + + val methodName1 = "testCompare_ALessThanZero" + val methodName2 = "testCompare_BLessThanZero" + val methodName3 = "testCompare_BEquals10" + val methodName4 = "testCompare_ALessThanB" + val methodName5 = "testCompare_AGreaterOrEqualB" + val methodName6 = "testCompare_AGreaterThanB" + + val displayName1 = "a < 0 : False -> return a" + val displayName2 = "b < 0 : True -> return a" + val displayName3 = "b == 10 : True -> return c" + val displayName4 = "a < b : True -> return a" + val displayName5 = "a < b : False -> return c" + val displayName6 = "a > b : True -> return b" + + val summaryKeys = listOf( + summary1, + summary2, + summary3, + summary4, + summary5, + summary6 ) - } - val summaryCompareChars1 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (n < 1): True}\n" +
-            "returns from: {@code return ' ';}\n" +
-            "
" - val summaryCompareChars2 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (n < 1): False}\n" +
-            "iterates the loop {@code for(int i = 0; i < n; i++)} once,\n" +
-            "    inside this loop, the test executes conditions:\n" +
-            "    {@code (Character.toChars(i)[0] == a): True}\n" +
-            "returns from: {@code return b;}\n" +
-            "
" - val summaryCompareChars3 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (n < 1): False}\n" +
-            "iterates the loop {@code for(int i = 0; i < n; i++)} once,\n" +
-            "    inside this loop, the test executes conditions:\n" +
-            "    {@code (Character.toChars(i)[0] == a): False},\n" +
-            "    {@code (Character.toChars(i)[0] == b): True}\n" +
-            "returns from:\n" +
-            "    1st return statement: {@code return a;}\n" +
-            "
" - val summaryCompareChars4 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (n < 1): False}\n" +
-            "iterates the loop {@code for(int i = 0; i < n; i++)} once,\n" +
-            "    inside this loop, the test executes conditions:\n" +
-            "    {@code (Character.toChars(i)[0] == a): False},\n" +
-            "    {@code (Character.toChars(i)[0] == b): False}"
+        val displayNames = listOf(
+            displayName1,
+            displayName2,
+            displayName3,
+            displayName4,
+            displayName5,
+            displayName6
+        )
+
+        val methodNames = listOf(
+            methodName1,
+            methodName2,
+            methodName3,
+            methodName4,
+            methodName5,
+            methodName6
+        )
+
+        val method = ReturnExample::compare
+        val mockStrategy = MockStrategyApi.NO_MOCKS
+        val coverage = DoNotCalculate
+
+        check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
+    }
 
     @Test
     fun testCompareChar() {
-        checkThreeArguments(
-            ReturnExample::compareChars,
-            summaryKeys = listOf(
-                summaryCompareChars1,
-                summaryCompareChars2,
-                summaryCompareChars3,
-                summaryCompareChars4
-            ),
-            displayNames = listOf(
-                "n < 1 : True -> return ' '",
-                "Character.toChars(i)[0] == a : True -> return b",
-                "Character.toChars(i)[0] == b : True -> return a",
-                "Character.toChars(i)[0] == b : False -> return a"
-            )
+        val summary1 = "Test executes conditions:\n" +
+                "    (n < 1): True\n" +
+                "returns from: return ' ';\n"
+        val summary2 = "Test executes conditions:\n" +
+                "    (n < 1): False\n" +
+                "iterates the loop for(int i = 0; i < n; i++) once,\n" +
+                "    inside this loop, the test executes conditions:\n" +
+                "    (Character.toChars(i)[0] == a): True\n" +
+                "returns from: return b;"
+        val summary3 = "Test executes conditions:\n" +
+                "    (n < 1): False\n" +
+                "iterates the loop for(int i = 0; i < n; i++) once,\n" +
+                "    inside this loop, the test executes conditions:\n" +
+                "    (Character.toChars(i)[0] == a): False,\n" +
+                "    (Character.toChars(i)[0] == b): True\n" +
+                "returns from:\n" +
+                "    1st return statement: return a;"
+        val summary4 = "Test executes conditions:\n" +
+                "    (n < 1): False\n" +
+                "iterates the loop for(int i = 0; i < n; i++) once,\n" +
+                "    inside this loop, the test executes conditions:\n" +
+                "    (Character.toChars(i)[0] == a): False,\n" +
+                "    (Character.toChars(i)[0] == b): False\n" +
+                "Test then returns from:\n" +
+                "    2nd return statement: return a;\n"
+
+        val methodName1 = "testCompareChars_NLessThan1"
+        val methodName2 = "testCompareChars_0OfCharactertoCharsiEqualsA" // TODO: a weird unclear naming
+        val methodName3 = "testCompareChars_0OfCharactertoCharsiEqualsB"
+        val methodName4 = "testCompareChars_0OfCharactertoCharsiNotEqualsB" // TODO: si -> is
+
+        val displayName1 = "n < 1 : True -> return ' '"
+        val displayName2 = "Character.toChars(i)[0] == a : True -> return b"
+        val displayName3 = "Character.toChars(i)[0] == b : True -> return a"
+        val displayName4 = "Character.toChars(i)[0] == b : False -> return a"
+
+        val summaryKeys = listOf(
+            summary1,
+            summary2,
+            summary3,
+            summary4
+        )
+
+        val displayNames = listOf(
+            displayName1,
+            displayName2,
+            displayName3,
+            displayName4
+        )
+
+        val methodNames = listOf(
+            methodName1,
+            methodName2,
+            methodName3,
+            methodName4
         )
-    }
 
-    val summaryVoidCompareChars1 = "
\n" +
-            "Test calls ReturnExample::compareChars,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code (n < 1): True}\n" +
-            "    returns from: {@code return ' ';}\n" +
-            "
" - val summaryVoidCompareChars2 = "
\n" +
-            "Test calls ReturnExample::compareChars,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code (n < 1): False}\n" +
-            "    iterates the loop {@code for(int i = 0; i < n; i++)} once,\n" +
-            "        inside this loop, the test executes conditions:\n" +
-            "        {@code (Character.toChars(i)[0] == a): True}\n" +
-            "    returns from: {@code return b;}\n" +
-            "
" - val summaryVoidCompareChars3 = "
\n" +
-            "Test calls ReturnExample::compareChars,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code (n < 1): False}\n" +
-            "    iterates the loop {@code for(int i = 0; i < n; i++)} once,\n" +
-            "        inside this loop, the test executes conditions:\n" +
-            "        {@code (Character.toChars(i)[0] == a): False},\n" +
-            "        {@code (Character.toChars(i)[0] == b): True}\n" +
-            "    returns from: {@code return a;}\n" +
-            "
" - val summaryVoidCompareChars4 = "Test calls ReturnExample::compareChars,\n" + - " there it executes conditions:\n" + - " {@code (n < 1): False}\n" + - " iterates the loop {@code for(int i = 0; i < n; i++)} once,\n" + - " inside this loop, the test executes conditions:\n" + - " {@code (Character.toChars(i)[0] == a): False},\n" + - " {@code (Character.toChars(i)[0] == b): False}" + val method = ReturnExample::compareChars + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testInnerVoidCompareChars() { - checkThreeArguments( - ReturnExample::innerVoidCompareChars, - summaryKeys = listOf( - summaryVoidCompareChars1, - summaryVoidCompareChars2, - summaryVoidCompareChars3, - summaryVoidCompareChars4 - ), - displayNames = listOf( - "n < 1 : True -> return ' '", - "Character.toChars(i)[0] == a : True -> return b", - "Character.toChars(i)[0] == b : True -> return a", - "Character.toChars(i)[0] == b : False -> return a" - ) + val summary1 = "Test calls ReturnExample::compareChars,\n" + + " there it executes conditions:\n" + + " (n < 1): True\n" + + " returns from: return ' ';\n" + + " " // TODO: generates empty String or \n a the end + val summary2 = "Test calls ReturnExample::compareChars,\n" + + " there it executes conditions:\n" + + " (n < 1): False\n" + + " iterates the loop for(int i = 0; i < n; i++) once,\n" + + " inside this loop, the test executes conditions:\n" + + " (Character.toChars(i)[0] == a): True\n" + + " returns from: return b;" + val summary3 = "Test calls ReturnExample::compareChars,\n" + + " there it executes conditions:\n" + + " (n < 1): False\n" + + " iterates the loop for(int i = 0; i < n; i++) once,\n" + + " inside this loop, the test executes conditions:\n" + + " (Character.toChars(i)[0] == a): False,\n" + + " (Character.toChars(i)[0] == b): False\n" + + " Test then returns from: return a;\n" + + " " // TODO: generates empty String or \n a the end + val summary4 = "Test calls ReturnExample::compareChars,\n" + + " there it executes conditions:\n" + + " (n < 1): False\n" + + " iterates the loop for(int i = 0; i < n; i++) once,\n" + + " inside this loop, the test executes conditions:\n" + + " (Character.toChars(i)[0] == a): False,\n" + + " (Character.toChars(i)[0] == b): True\n" + + " returns from: return a;" + + val methodName1 = "testInnerVoidCompareChars_NLessThan1" + val methodName2 = "testInnerVoidCompareChars_0OfCharactertoCharsiEqualsA" // TODO: a weird unclear naming + val methodName3 = "testInnerVoidCompareChars_0OfCharactertoCharsiNotEqualsB" + val methodName4 = "testInnerVoidCompareChars_0OfCharactertoCharsiEqualsB" // TODO: si -> is + + val displayName1 = "n < 1 : True -> return ' '" + val displayName2 = "Character.toChars(i)[0] == a : True -> return b" + val displayName3 = "Character.toChars(i)[0] == b : False -> return a" + val displayName4 = "Character.toChars(i)[0] == b : True -> return a" + + val summaryKeys = listOf( + summary1, + summary2, + summary3, + summary4 ) - } - val summaryInnerReturnCompareChars1 = "
\n" +
-            "Test calls ReturnExample::compareChars,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code (n < 1): True}\n" +
-            "    returns from: {@code return ' ';}"
-    val summaryInnerReturnCompareChars2 = "Test calls ReturnExample::compareChars,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code (n < 1): False}\n" +
-            "    iterates the loop {@code for(int i = 0; i < n; i++)} once,\n" +
-            "        inside this loop, the test executes conditions:\n" +
-            "        {@code (Character.toChars(i)[0] == a): True}\n" +
-            "    returns from: {@code return b;}"
-    val summaryInnerReturnCompareChars3 = "Test calls ReturnExample::compareChars,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code (n < 1): False}\n" +
-            "    iterates the loop {@code for(int i = 0; i < n; i++)} once,\n" +
-            "        inside this loop, the test executes conditions:\n" +
-            "        {@code (Character.toChars(i)[0] == a): False},\n" +
-            "        {@code (Character.toChars(i)[0] == b): True}\n" +
-            "    returns from: {@code return a;}"
-    val summaryInnerReturnCompareChars4 = "Test calls ReturnExample::compareChars,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code (n < 1): False}\n" +
-            "    iterates the loop {@code for(int i = 0; i < n; i++)} once,\n" +
-            "        inside this loop, the test executes conditions:\n" +
-            "        {@code (Character.toChars(i)[0] == a): False},\n" +
-            "        {@code (Character.toChars(i)[0] == b): False}"
+        val displayNames = listOf(
+            displayName1,
+            displayName2,
+            displayName3,
+            displayName4
+        )
+
+        val methodNames = listOf(
+            methodName1,
+            methodName2,
+            methodName3,
+            methodName4
+        )
+
+        val method = ReturnExample::innerVoidCompareChars
+        val mockStrategy = MockStrategyApi.NO_MOCKS
+        val coverage = DoNotCalculate
+
+        check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
+    }
 
     @Test
     fun testInnerReturnCompareChars() {
-        checkThreeArguments(
-            ReturnExample::innerReturnCompareChars,
-            summaryKeys = listOf(
-                summaryInnerReturnCompareChars1,
-                summaryInnerReturnCompareChars2,
-                summaryInnerReturnCompareChars3,
-                summaryInnerReturnCompareChars4
-            )
+        val summary1 = "Test calls ReturnExample::compareChars,\n" +
+                "    there it executes conditions:\n" +
+                "        (n < 1): True\n" +
+                "    returns from: return ' ';\n" +
+                "    \n" +
+                "Test later returns from: return compareChars(a, b, n);\n"
+        val summary2 = "Test calls ReturnExample::compareChars,\n" +
+                "    there it executes conditions:\n" +
+                "        (n < 1): False\n" +
+                "    iterates the loop for(int i = 0; i < n; i++) once,\n" +
+                "        inside this loop, the test executes conditions:\n" +
+                "        (Character.toChars(i)[0] == a): True\n" +
+                "    returns from: return b;\n" +
+                "Test later returns from: return compareChars(a, b, n);\n"
+        val summary3 = "Test calls ReturnExample::compareChars,\n" +
+                "    there it executes conditions:\n" +
+                "        (n < 1): False\n" +
+                "    iterates the loop for(int i = 0; i < n; i++) once,\n" +
+                "        inside this loop, the test executes conditions:\n" +
+                "        (Character.toChars(i)[0] == a): False,\n" +
+                "        (Character.toChars(i)[0] == b): False\n" +
+                "    Test then returns from: return a;\n" +
+                "    \n" + //
+                "Test afterwards returns from: return compareChars(a, b, n);\n"
+        val summary4 = "Test calls ReturnExample::compareChars,\n" +
+                "    there it executes conditions:\n" +
+                "        (n < 1): False\n" +
+                "    iterates the loop for(int i = 0; i < n; i++) once,\n" +
+                "        inside this loop, the test executes conditions:\n" +
+                "        (Character.toChars(i)[0] == a): False,\n" +
+                "        (Character.toChars(i)[0] == b): True\n" +
+                "    returns from: return a;\n" +
+                "Test afterwards returns from: return compareChars(a, b, n);\n"
+
+        val methodName1 = "testInnerReturnCompareChars_NLessThan1"
+        val methodName2 = "testInnerReturnCompareChars_0OfCharactertoCharsiEqualsA" // TODO: a weird unclear naming
+        val methodName3 = "testInnerReturnCompareChars_0OfCharactertoCharsiNotEqualsB"
+        val methodName4 = "testInnerReturnCompareChars_0OfCharactertoCharsiEqualsB" // TODO: si -> is
+
+        val displayName1 = "n < 1 : True -> return ' '"
+        val displayName2 = "Character.toChars(i)[0] == a : True -> return b"
+        val displayName3 = "Character.toChars(i)[0] == b : False -> return a"
+        val displayName4 = "Character.toChars(i)[0] == b : True -> return a"
+
+        val summaryKeys = listOf(
+            summary1,
+            summary2,
+            summary3,
+            summary4
+        )
+
+        val displayNames = listOf(
+            displayName1,
+            displayName2,
+            displayName3,
+            displayName4
         )
-    }
 
-    val summaryInnerVoidCompare1 = "
\n" +
-            "Test calls ReturnExample::compare,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code (a < 0): False},\n" +
-            "        {@code (b < 0): True}\n" +
-            "    returns from: {@code return a;}\n" +
-            "
" - val summaryInnerVoidCompare2 = "
\n" +
-            "Test calls ReturnExample::compare,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code (a < 0): False},\n" +
-            "        {@code (b < 0): False},\n" +
-            "        {@code (b == 10): True}\n" +
-            "    returns from: {@code return c;}\n" +
-            "
" - val summaryInnerVoidCompare3 = "
\n" +
-            "Test calls ReturnExample::compare,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code (a < 0): False},\n" +
-            "        {@code (b < 0): False},\n" +
-            "        {@code (b == 10): False},\n" +
-            "        {@code (a > b): False},\n" +
-            "        {@code (a < b): False}\n" +
-            "    returns from: {@code return c;}\n" +
-            "
" - val summaryInnerVoidCompare4 = "
\n" +
-            "Test calls ReturnExample::compare,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code (a < 0): False},\n" +
-            "        {@code (b < 0): False},\n" +
-            "        {@code (b == 10): False},\n" +
-            "        {@code (a > b): False},\n" +
-            "        {@code (a < b): True}\n" +
-            "    returns from: {@code return a;}\n" +
-            "
" - val summaryInnerVoidCompare5 = "
\n" +
-            "Test calls ReturnExample::compare,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code (a < 0): True}\n" +
-            "    returns from: {@code return a;}\n" +
-            "
" - val summaryInnerVoidCompare6 = "
\n" +
-            "Test calls ReturnExample::compare,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code (a < 0): False},\n" +
-            "        {@code (b < 0): False},\n" +
-            "        {@code (b == 10): False},\n" +
-            "        {@code (a > b): True}\n" +
-            "    returns from: {@code return b;}\n" +
-            "
" + val methodNames = listOf( + methodName1, + methodName2, + methodName3, + methodName4 + ) + + val method = ReturnExample::innerReturnCompareChars + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testInnerVoidCompare() { - checkTwoArguments( - ReturnExample::innerVoidCallCompare, - summaryKeys = listOf( - summaryInnerVoidCompare1, - summaryInnerVoidCompare2, - summaryInnerVoidCompare3, - summaryInnerVoidCompare4, - summaryInnerVoidCompare5, - summaryInnerVoidCompare6 - ), - displayNames = listOf( - "b < 0 : True -> return a", - "b == 10 : True -> return c", - "a < b : False -> return c", - "a < b : True -> return a", - "a < 0 : False -> return a", - "a > b : True -> return b" - ) + val summary1 = "Test calls ReturnExample::compare,\n" + + " there it executes conditions:\n" + + " (a < 0): False,\n" + + " (b < 0): True\n" + + " returns from: return a;\n" + + " " // TODO: remove blank line + val summary2 = "Test calls ReturnExample::compare,\n" + + " there it executes conditions:\n" + + " (a < 0): False,\n" + + " (b < 0): False,\n" + + " (b == 10): False,\n" + + " (a > b): True\n" + + " returns from: return b;\n" + + " " // TODO: remove blank line + val summary3 = "Test calls ReturnExample::compare,\n" + + " there it executes conditions:\n" + + " (a < 0): False,\n" + + " (b < 0): False,\n" + + " (b == 10): True\n" + + " returns from: return c;\n" + + " " // TODO: remove blank line + val summary4 = "Test calls ReturnExample::compare,\n" + + " there it executes conditions:\n" + + " (a < 0): True\n" + + " returns from: return a;\n" + + " " // TODO: remove blank line + val summary5 = "Test calls ReturnExample::compare,\n" + + " there it executes conditions:\n" + + " (a < 0): False,\n" + + " (b < 0): False,\n" + + " (b == 10): False,\n" + + " (a > b): False,\n" + + " (a < b): True\n" + + " returns from: return a;\n" + + " " // TODO: remove blank line + val summary6 = "Test calls ReturnExample::compare,\n" + + " there it executes conditions:\n" + + " (a < 0): False,\n" + + " (b < 0): False,\n" + + " (b == 10): False,\n" + + " (a > b): False,\n" + + " (a < b): False\n" + + " returns from: return c;\n" + + " " // TODO: remove blank line + + val methodName1 = "testInnerVoidCallCompare_BLessThanZero" + val methodName2 = "testInnerVoidCallCompare_AGreaterThanB" + val methodName3 = "testInnerVoidCallCompare_BEquals10" + val methodName4 = "testInnerVoidCallCompare_ALessThanZero" + val methodName5 = "testInnerVoidCallCompare_ALessThanB" + val methodName6 = "testInnerVoidCallCompare_AGreaterOrEqualB" + + val displayName1 = "b < 0 : True -> return a" + val displayName2 = "a > b : True -> return b" + val displayName3 = "b == 10 : True -> return c" + val displayName4 = "a < 0 : False -> return a" + val displayName5 = "a < b : True -> return a" + val displayName6 = "a < b : False -> return c" + + val summaryKeys = listOf( + summary1, + summary2, + summary3, + summary4, + summary5, + summary6 ) - } - val summaryInnerReturnCompare1 = "Test calls ReturnExample::compare,\n" + - " there it executes conditions:\n" + - " {@code (a < 0): False},\n" + - " {@code (b < 0): True}\n" + - " returns from: {@code return a;}" - val summaryInnerReturnCompare2 = "Test calls ReturnExample::compare,\n" + - " there it executes conditions:\n" + - " {@code (a < 0): False},\n" + - " {@code (b < 0): False},\n" + - " {@code (b == 10): True}\n" + - " returns from: {@code return c;}" - val summaryInnerReturnCompare3 = "Test calls ReturnExample::compare,\n" + - " there it executes conditions:\n" + - " {@code (a < 0): False},\n" + - " {@code (b < 0): False},\n" + - " {@code (b == 10): False},\n" + - " {@code (a > b): False},\n" + - " {@code (a < b): False}\n" + - " returns from: {@code return c;}" - val summaryInnerReturnCompare4 = "Test calls ReturnExample::compare,\n" + - " there it executes conditions:\n" + - " {@code (a < 0): False},\n" + - " {@code (b < 0): False},\n" + - " {@code (b == 10): False},\n" + - " {@code (a > b): False},\n" + - " {@code (a < b): True}\n" + - " returns from: {@code return a;}" - val summaryInnerReturnCompare5 = "Test calls ReturnExample::compare,\n" + - " there it executes conditions:\n" + - " {@code (a < 0): True}\n" + - " returns from: {@code return a;}" - val summaryInnerReturnCompare6 = "Test calls ReturnExample::compare,\n" + - " there it executes conditions:\n" + - " {@code (a < 0): False},\n" + - " {@code (b < 0): False},\n" + - " {@code (b == 10): False},\n" + - " {@code (a > b): True}\n" + - " returns from: {@code return b;}" + val displayNames = listOf( + displayName1, + displayName2, + displayName3, + displayName4, + displayName5, + displayName6 + ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3, + methodName4, + methodName5, + methodName6 + ) + + val method = ReturnExample::innerVoidCallCompare + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testInnerReturnCompare() { - checkTwoArguments( - ReturnExample::innerReturnCallCompare, - summaryKeys = listOf( - summaryInnerReturnCompare1, - summaryInnerReturnCompare2, - summaryInnerReturnCompare3, - summaryInnerReturnCompare4, - summaryInnerReturnCompare5, - summaryInnerReturnCompare6 - ), - displayNames = listOf( - "b < 0 : True -> return a", - "b == 10 : True -> return c", - "a < b : False -> return c", - "a < b : True -> return a", - "a < 0 : False -> return a", - "a > b : True -> return b" - ) + val summary1 = "Test calls ReturnExample::compare,\n" + + " there it executes conditions:\n" + + " (a < 0): False,\n" + + " (b < 0): True\n" + + " returns from: return a;\n" + + " \n" + + "Test then returns from: return compare(a, b);\n" + val summary2 = "Test calls ReturnExample::compare,\n" + + " there it executes conditions:\n" + + " (a < 0): False,\n" + + " (b < 0): False,\n" + + " (b == 10): False,\n" + + " (a > b): True\n" + + " returns from: return b;\n" + + " \n" + + "Test afterwards returns from: return compare(a, b);\n" + val summary3 = "Test calls ReturnExample::compare,\n" + + " there it executes conditions:\n" + + " (a < 0): False,\n" + + " (b < 0): False,\n" + + " (b == 10): True\n" + + " returns from: return c;\n" + + " \n" + + "Test then returns from: return compare(a, b);\n" + val summary4 = "Test calls ReturnExample::compare,\n" + + " there it executes conditions:\n" + + " (a < 0): True\n" + + " returns from: return a;\n" + + " \n" + + "Test next returns from: return compare(a, b);\n" + val summary5 = "Test calls ReturnExample::compare,\n" + + " there it executes conditions:\n" + + " (a < 0): False,\n" + + " (b < 0): False,\n" + + " (b == 10): False,\n" + + " (a > b): False,\n" + + " (a < b): True\n" + + " returns from: return a;\n" + + " \n" + + "Test afterwards returns from: return compare(a, b);\n" + val summary6 = "Test calls ReturnExample::compare,\n" + + " there it executes conditions:\n" + + " (a < 0): False,\n" + + " (b < 0): False,\n" + + " (b == 10): False,\n" + + " (a > b): False,\n" + + " (a < b): False\n" + + " returns from: return c;\n" + + " \n" + + "Test next returns from: return compare(a, b);\n" + + val methodName1 = "testInnerReturnCallCompare_BLessThanZero" + val methodName2 = "testInnerReturnCallCompare_AGreaterThanB" + val methodName3 = "testInnerReturnCallCompare_BEquals10" + val methodName4 = "testInnerReturnCallCompare_ALessThanZero" + val methodName5 = "testInnerReturnCallCompare_ALessThanB" + val methodName6 = "testInnerReturnCallCompare_AGreaterOrEqualB" + + val displayName1 = "b < 0 : True -> return a" // TODO: the same display names for many tests with different test names + val displayName2 = "a > b : True -> return b" + val displayName3 = "b == 10 : True -> return c" + val displayName4 = "a < 0 : False -> return a" + val displayName5 = "a < b : True -> return a" + val displayName6 = "a < b : False -> return c" + + val summaryKeys = listOf( + summary1, + summary2, + summary3, + summary4, + summary5, + summary6 + ) + + val displayNames = listOf( + displayName1, + displayName2, + displayName3, + displayName4, + displayName5, + displayName6 ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3, + methodName4, + methodName5, + methodName6 + ) + + val method = ReturnExample::innerReturnCallCompare + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) } } \ No newline at end of file diff --git a/utbot-summary-tests/src/test/kotlin/math/SummaryIntMath.kt b/utbot-summary-tests/src/test/kotlin/math/SummaryIntMath.kt index 2604ce0573..43b3520970 100644 --- a/utbot-summary-tests/src/test/kotlin/math/SummaryIntMath.kt +++ b/utbot-summary-tests/src/test/kotlin/math/SummaryIntMath.kt @@ -72,10 +72,10 @@ class SummaryIntMath : SummaryTestCaseGeneratorTest( val displayName1 = "switch(b) case: 2 -> return 1" val displayName2 = "k < Integer.SIZE : False -> return 0" val displayName3 = "k < Integer.SIZE : False -> return (k < Integer.SIZE) ? (1 << k) : 0" - val displayName4 = "-> return b * accum" + val displayName4 = "-> return b * accum" // TODO: weird display name with missed part before -> val displayName5 = "k < Integer.SIZE : True -> return (k < Integer.SIZE) ? (1 << k) : 0" val displayName6 = "k == 0 : False -> return (k == 0) ? 1 : 0" - val displayName7 = "-> return accum" + val displayName7 = "-> return accum" // TODO: weird display name with missed part before -> val displayName8 = "k == 0 : True -> return (k == 0) ? 1 : 0" val displayName9 = "(k & 1) == 0 : True -> return ((k & 1) == 0) ? (1 << k) : -(1 << k)" val displayName10 = "(k & 1) == 0 : False -> return ((k & 1) == 0) ? (1 << k) : -(1 << k)" @@ -84,10 +84,6 @@ class SummaryIntMath : SummaryTestCaseGeneratorTest( val displayName13 = "(k & 1) == 0 : False -> return b * accum" val displayName14 = "(k & 1) == 0 : True -> return b * accum" - val method = IntMath::pow - val mockStrategy = MockStrategyApi.NO_MOCKS - val coverage = DoNotCalculate - val summaryKeys = listOf( summary1, summary2, @@ -139,6 +135,10 @@ class SummaryIntMath : SummaryTestCaseGeneratorTest( methodName14 ) + val method = IntMath::pow + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) } } \ No newline at end of file From 1ba59c242133d185c76a98f0e9a4ab01e28024a0 Mon Sep 17 00:00:00 2001 From: amandelpie Date: Mon, 4 Jul 2022 10:38:31 +0300 Subject: [PATCH 3/4] Restored SummaryCycleTest.kt --- .../algorithms/SummaryReturnExampleTest.kt | 3 +- .../examples/controlflow/SummaryCycleTest.kt | 186 +++++++++++------- 2 files changed, 113 insertions(+), 76 deletions(-) diff --git a/utbot-summary-tests/src/test/kotlin/examples/algorithms/SummaryReturnExampleTest.kt b/utbot-summary-tests/src/test/kotlin/examples/algorithms/SummaryReturnExampleTest.kt index aa25b7f508..a12c2854e6 100644 --- a/utbot-summary-tests/src/test/kotlin/examples/algorithms/SummaryReturnExampleTest.kt +++ b/utbot-summary-tests/src/test/kotlin/examples/algorithms/SummaryReturnExampleTest.kt @@ -462,7 +462,8 @@ class SummaryReturnExampleTest : SummaryTestCaseGeneratorTest( val methodName5 = "testInnerReturnCallCompare_ALessThanB" val methodName6 = "testInnerReturnCallCompare_AGreaterOrEqualB" - val displayName1 = "b < 0 : True -> return a" // TODO: the same display names for many tests with different test names + val displayName1 = + "b < 0 : True -> return a" // TODO: the same display names for many tests with different test names val displayName2 = "a > b : True -> return b" val displayName3 = "b == 10 : True -> return c" val displayName4 = "a < 0 : False -> return a" diff --git a/utbot-summary-tests/src/test/kotlin/examples/controlflow/SummaryCycleTest.kt b/utbot-summary-tests/src/test/kotlin/examples/controlflow/SummaryCycleTest.kt index 80a7f05ba6..b4e3a6f3ba 100644 --- a/utbot-summary-tests/src/test/kotlin/examples/controlflow/SummaryCycleTest.kt +++ b/utbot-summary-tests/src/test/kotlin/examples/controlflow/SummaryCycleTest.kt @@ -6,92 +6,128 @@ import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Tag import org.utbot.examples.controlflow.Cycles import org.junit.jupiter.api.Test -@Disabled +import org.utbot.examples.DoNotCalculate +import org.utbot.examples.algorithms.ReturnExample +import org.utbot.framework.plugin.api.MockStrategyApi + class SummaryCycleTest : SummaryTestCaseGeneratorTest( Cycles::class, ) { - - val summaryLoopInsideLoop1 = "
\n" +
-            "Test iterates the loop {@code for(int i = x - 5; i < x; i++)} once,\n" +
-            "    inside this loop, the test executes conditions:\n" +
-            "    {@code (i < 0): True}\n" +
-            "returns from: {@code return 2;}\n" +
-            "
" - val summaryLoopInsideLoop2 = "
\n" +
-            "Test does not iterate {@code for(int i = x - 5; i < x; i++)}, {@code for(int j = i; j < x + i; j++)}, returns from: {@code return -1;}\n" +
-            "
" - val summaryLoopInsideLoop3 = "
\n" +
-            "Test iterates the loop {@code for(int i = x - 5; i < x; i++)} once,\n" +
-            "    inside this loop, the test executes conditions:\n" +
-            "    {@code (i < 0): False}\n" +
-            "iterates the loop {@code for(int j = i; j < x + i; j++)} once,\n" +
-            "        inside this loop, the test executes conditions:\n" +
-            "    {@code (j == 7): True}\n" +
-            "returns from: {@code return 1;}\n" +
-            "
" - val summaryLoopInsideLoop4 = "
\n" +
-            "Test iterates the loop {@code for(int i = x - 5; i < x; i++)} once,\n" +
-            "    inside this loop, the test executes conditions:\n" +
-            "    {@code (i < 0): False}\n" +
-            "iterates the loop {@code for(int j = i; j < x + i; j++)} twice,\n" +
-            "        inside this loop, the test executes conditions:\n" +
-            "    {@code (j == 7): False}\n" +
-            "    {@code (j == 7): True}\n" +
-            "returns from: {@code return 1;}\n" +
-            "
" - val summaryLoopInsideLoop5 = "
\n" +
-            "Test iterates the loop {@code for(int i = x - 5; i < x; i++)} 5 times."
-
     @Test
     fun testLoopInsideLoop() {
-        checkOneArgument(
-            Cycles::loopInsideLoop,
-            summaryKeys = listOf(
-                summaryLoopInsideLoop1,
-                summaryLoopInsideLoop2,
-                summaryLoopInsideLoop3,
-                summaryLoopInsideLoop4,
-                summaryLoopInsideLoop5
-            ),
-            displayNames = listOf(
-                "i < 0 : True -> return 2",
-                "-> return -1",
-                "i < 0 : False -> return 1",
-                "j == 7 : False -> return 1",
-                "-> return -1"
-            )
+        val summary1 = "Test iterates the loop for(int i = x - 5; i < x; i++) once,\n" +
+                "    inside this loop, the test executes conditions:\n" +
+                "    (i < 0): True\n" +
+                "returns from: return 2;"
+        val summary2 = "Test does not iterate for(int i = x - 5; i < x; i++), for(int j = i; j < x + i; j++), returns from: return -1;\n" // TODO: should it be formatted from the new string?
+        val summary3 = "Test iterates the loop for(int i = x - 5; i < x; i++) once,\n" +
+                "    inside this loop, the test executes conditions:\n" +
+                "    (i < 0): False\n" +
+                "iterates the loop for(int j = i; j < x + i; j++) once,\n" +
+                "        inside this loop, the test executes conditions:\n" +
+                "    (j == 7): True\n" +
+                "returns from: return 1;"
+        val summary4 = "Test iterates the loop for(int i = x - 5; i < x; i++) once,\n" +
+                "    inside this loop, the test executes conditions:\n" +
+                "    (i < 0): False\n" +
+                "iterates the loop for(int j = i; j < x + i; j++) twice,\n" +
+                "        inside this loop, the test executes conditions:\n" +
+                "    (j == 7): False\n" +
+                "    (j == 7): True\n" +
+                "returns from: return 1;"
+        val summary5 = "Test iterates the loop for(int i = x - 5; i < x; i++) 5 times. \n" +
+                "Test afterwards does not iterate for(int j = i; j < x + i; j++), returns from: return -1;\n" // TODO: should it be formatted with separation of code?
+
+        val methodName1 = "testLoopInsideLoop_ILessThanZero"
+        val methodName2 = "testLoopInsideLoop_ReturnNegative1"
+        val methodName3 = "testLoopInsideLoop_JEquals7"
+        val methodName4 = "testLoopInsideLoop_JNotEquals7"
+        val methodName5 = "testLoopInsideLoop_ReturnNegative1_1"
+
+
+        val displayName1 = "i < 0 : True -> return 2"
+        val displayName2 = "-> return -1" // TODO: add something before ->
+        val displayName3 = "i < 0 : False -> return 1"
+        val displayName4 = "j == 7 : False -> return 1"
+        val displayName5 = "-> return -1"
+
+
+        val summaryKeys = listOf(
+            summary1,
+            summary2,
+            summary3,
+            summary4,
+            summary5
+        )
+
+        val displayNames = listOf(
+            displayName1,
+            displayName2,
+            displayName3,
+            displayName4,
+            displayName5
+        )
+
+        val methodNames = listOf(
+            methodName1,
+            methodName2,
+            methodName3,
+            methodName4,
+            methodName5
         )
-    }
 
-    val summaryStructureLoop1 = "
\n" +
-            "Test does not iterate {@code for(int i = 0; i < x; i++)}, returns from: {@code return -1;}\n" +
-            "
" - val summaryStructureLoop2 = "
\n" +
-            "Test iterates the loop {@code for(int i = 0; i < x; i++)} once,\n" +
-            "    inside this loop, the test executes conditions:\n" +
-            "    {@code (i == 2): False}\n"
-    val summaryStructureLoop3 = "
\n" +
-            "Test iterates the loop {@code for(int i = 0; i < x; i++)} 3 times,\n" +
-            "    inside this loop, the test executes conditions:\n" +
-            "    {@code (i == 2): True}\n" +
-            "returns from: {@code return 1;}\n" +
-            "
" + val method = Cycles::loopInsideLoop + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testStructureLoop() { - checkOneArgument( - Cycles::structureLoop, - summaryKeys = listOf( - summaryStructureLoop1, - summaryStructureLoop2, - summaryStructureLoop3 - ), - displayNames = listOf( - "-> return -1", - "i == 2 : False -> return -1", - "i == 2 : True -> return 1" - ) + val summary1 = "Test does not iterate for(int i = 0; i < x; i++), returns from: return -1;\n" + val summary2 = "Test iterates the loop for(int i = 0; i < x; i++) once,\n" + + " inside this loop, the test executes conditions:\n" + + " (i == 2): False\n" + + "Test further returns from: return -1;\n" + val summary3 = "Test iterates the loop for(int i = 0; i < x; i++) 3 times,\n" + + " inside this loop, the test executes conditions:\n" + + " (i == 2): True\n" + + "returns from: return 1;" + + val methodName1 = "testStructureLoop_ReturnNegative1" + val methodName2 = "testStructureLoop_INotEquals2" + val methodName3 = "testStructureLoop_IEquals2" + + + val displayName1 = "-> return -1" + val displayName2 = "i == 2 : False -> return -1" + val displayName3 = "i == 2 : True -> return 1" + + + val summaryKeys = listOf( + summary1, + summary2, + summary3 ) + + val displayNames = listOf( + displayName1, + displayName2, + displayName3 + ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3 + ) + + val method = Cycles::structureLoop + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) } } \ No newline at end of file From 4b0550efde91ae6168de81bb7f3b0e8649a47656 Mon Sep 17 00:00:00 2001 From: amandelpie Date: Mon, 4 Jul 2022 12:54:33 +0300 Subject: [PATCH 4/4] Restored all the tests --- .../examples/inner/SummaryInnerCallsTest.kt | 1088 ++++++++++++----- .../examples/inner/SummaryNestedCallsTest.kt | 80 +- .../kotlin/examples/ternary/SummaryTernary.kt | 819 ++++++++----- 3 files changed, 1314 insertions(+), 673 deletions(-) diff --git a/utbot-summary-tests/src/test/kotlin/examples/inner/SummaryInnerCallsTest.kt b/utbot-summary-tests/src/test/kotlin/examples/inner/SummaryInnerCallsTest.kt index 19d077b972..005ff1d64c 100644 --- a/utbot-summary-tests/src/test/kotlin/examples/inner/SummaryInnerCallsTest.kt +++ b/utbot-summary-tests/src/test/kotlin/examples/inner/SummaryInnerCallsTest.kt @@ -1,413 +1,825 @@ package examples.inner import examples.SummaryTestCaseGeneratorTest +import guava.examples.math.Stats import org.junit.Ignore import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Tag import org.utbot.examples.inner.InnerCalls import org.junit.jupiter.api.Test +import org.utbot.examples.DoNotCalculate +import org.utbot.examples.controlflow.Cycles +import org.utbot.framework.plugin.api.MockStrategyApi -@Disabled class SummaryInnerCallsTest : SummaryTestCaseGeneratorTest( InnerCalls::class, ) { - - val keyCallLoopInsideLoop1 = "Test calls Cycles::loopInsideLoop,\n" + - " there it iterates the loop {@code for(int i = x - 5; i < x; i++)} once,\n" + - " inside this loop, the test executes conditions:\n" + - " {@code (i < 0): True}\n" + - " returns from: {@code return 2;}" - val keyCallLoopInsideLoop2 = "Test calls Cycles::loopInsideLoop,\n" + - " there it iterates the loop {@code for(int i = x - 5; i < x; i++)} once,\n" + - " inside this loop, the test executes conditions:\n" + - " {@code (i < 0): False}\n" + - " iterates the loop {@code for(int j = i; j < x + i; j++)} once,\n" + - " inside this loop, the test executes conditions:\n" + - " {@code (j == 7): True}\n" + - " returns from: {@code return 1;}" - val keyCallLoopInsideLoop3 = "Test calls Cycles::loopInsideLoop,\n" + - " there it does not iterate {@code for(int i = x - 5; i < x; i++)}, {@code for(int j = i; j < x + i; j++)}, returns from: {@code return -1;}" - val keyCallLoopInsideLoop4 = "Test calls Cycles::loopInsideLoop,\n" + - " there it iterates the loop {@code for(int i = x - 5; i < x; i++)} once,\n" + - " inside this loop, the test executes conditions:\n" + - " {@code (i < 0): False}\n" + - " iterates the loop {@code for(int j = i; j < x + i; j++)} twice,\n" + - " inside this loop, the test executes conditions:\n" + - " {@code (j == 7): False}\n" + - " {@code (j == 7): True}\n" + - " returns from: {@code return 1;}" - val keyCallLoopInsideLoop5 = "Test calls Cycles::loopInsideLoop,\n" + - " there it iterates the loop {@code for(int i = x - 5; i < x; i++)} 5 times. " - @Test fun testCallLoopInsideLoop() { - checkOneArgument( - InnerCalls::callLoopInsideLoop, - summaryKeys = listOf( - keyCallLoopInsideLoop1, - keyCallLoopInsideLoop2, - keyCallLoopInsideLoop3, - keyCallLoopInsideLoop4, - keyCallLoopInsideLoop5 - ), - displayNames = listOf( - "i < 0 : True -> return 2", - "i < 0 : False -> return 1", - "loopInsideLoop -> return -1", - "j == 7 : False -> return 1", - "loopInsideLoop -> return -1" - ) + val summary1 = "Test calls Cycles::loopInsideLoop,\n" + + " there it iterates the loop for(int i = x - 5; i < x; i++) once,\n" + + " inside this loop, the test executes conditions:\n" + + " (i < 0): False\n" + + " iterates the loop for(int j = i; j < x + i; j++) once,\n" + + " inside this loop, the test executes conditions:\n" + + " (j == 7): True\n" + + " returns from: return 1;\n" + + "Test afterwards returns from: return cycles.loopInsideLoop(x);\n" + val summary2 = "Test calls Cycles::loopInsideLoop,\n" + + " there it iterates the loop for(int i = x - 5; i < x; i++) once,\n" + + " inside this loop, the test executes conditions:\n" + + " (i < 0): True\n" + + " returns from: return 2;\n" + + "Test then returns from: return cycles.loopInsideLoop(x);\n" + val summary3 = "Test calls Cycles::loopInsideLoop,\n" + + " there it does not iterate for(int i = x - 5; i < x; i++), for(int j = i; j < x + i; j++), returns from: return -1;\n" + + " \n" + + "Test later returns from: return cycles.loopInsideLoop(x);\n" + val summary4 = "Test calls Cycles::loopInsideLoop,\n" + + " there it iterates the loop for(int i = x - 5; i < x; i++) once,\n" + + " inside this loop, the test executes conditions:\n" + + " (i < 0): False\n" + + " iterates the loop for(int j = i; j < x + i; j++) twice,\n" + + " inside this loop, the test executes conditions:\n" + + " (j == 7): False\n" + + " (j == 7): True\n" + + " returns from: return 1;\n" + + "Test later returns from: return cycles.loopInsideLoop(x);\n" + val summary5 = "Test calls Cycles::loopInsideLoop,\n" + + " there it iterates the loop for(int i = x - 5; i < x; i++) 5 times. \n" + + " Test further does not iterate for(int j = i; j < x + i; j++), returns from: return -1;\n" + + " \n" + + "Test then returns from: return cycles.loopInsideLoop(x);\n" + + val methodName1 = "testCallLoopInsideLoop_JEquals7" + val methodName2 = "testCallLoopInsideLoop_ILessThanZero" + val methodName3 = "testCallLoopInsideLoop_ReturnNegative1" + val methodName4 = "testCallLoopInsideLoop_JNotEquals7" + val methodName5 = "testCallLoopInsideLoop_ReturnNegative1_1" + + + val displayName1 = "i < 0 : False -> return 1" + val displayName2 = "i < 0 : True -> return 2" + val displayName3 = "loopInsideLoop -> return -1" + val displayName4 = "j == 7 : False -> return 1" + val displayName5 = "loopInsideLoop -> return -1" + + + val summaryKeys = listOf( + summary1, + summary2, + summary3, + summary4, + summary5 ) - } - val keyInnerCallLeftSearch1 = - "Test throws IllegalArgumentException in: return binarySearch.leftBinSearch(array, key);" - val keyInnerCallLeftSearch2 = "Test calls BinarySearch::leftBinSearch,\n" + - " there it invokes:\n" + - " BinarySearch::isUnsorted once\n" + - " triggers recursion of leftBinSearch once.\n" + - "Test throws NullPointerException in: return binarySearch.leftBinSearch(array, key);" - - val keyInnerCallLeftSearch3 = "Test calls BinarySearch::leftBinSearch,\n" + - " there it does not iterate {@code while(left < right - 1)}, executes conditions:\n" + - " {@code (found): False}" - val keyInnerCallLeftSearch4 = "Test calls BinarySearch::leftBinSearch,\n" + - " there it executes conditions:\n" + - " {@code (isUnsorted(array)): True}\n" + - "Test throws NullPointerException in: return binarySearch.leftBinSearch(array, key);" - - val keyInnerCallLeftSearch5 = "Test calls BinarySearch::leftBinSearch,\n" + - " there it iterates the loop {@code while(left < right - 1)} once,\n" + - " inside this loop, the test executes conditions:\n" + - " {@code (array[middle] == key): False},\n" + - " {@code (array[middle] < key): True}" - val keyInnerCallLeftSearch6 = "Test calls BinarySearch::leftBinSearch,\n" + - " there it iterates the loop {@code while(left < right - 1)} once,\n" + - " inside this loop, the test executes conditions:\n" + - " {@code (array[middle] == key): False},\n" + - " {@code (array[middle] < key): False}" - val keyInnerCallLeftSearch7 = "Test calls BinarySearch::leftBinSearch,\n" + - " there it iterates the loop {@code while(left < right - 1)} once,\n" + - " inside this loop, the test executes conditions:\n" + - " {@code (array[middle] == key): True},\n" + - " {@code (array[middle] < key): False}" + val displayNames = listOf( + displayName1, + displayName2, + displayName3, + displayName4, + displayName5 + ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3, + methodName4, + methodName5 + ) + + val method = InnerCalls::callLoopInsideLoop + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testCallLeftBinSearch() { - checkTwoArguments( - InnerCalls::callLeftBinSearch, - summaryKeys = listOf( - keyInnerCallLeftSearch1, - keyInnerCallLeftSearch2, - keyInnerCallLeftSearch3, - keyInnerCallLeftSearch4, - keyInnerCallLeftSearch5, - keyInnerCallLeftSearch6, - keyInnerCallLeftSearch7 - ) + //NOTE: 5 and 6 cases has different paths but throws the equal exception. + val summary1 = "Test calls BinarySearch::leftBinSearch,\n" + + " there it does not iterate while(left < right - 1), executes conditions:\n" + + " (found): False\n" + + " returns from: return -1;\n" + + " \n" + + "Test then returns from: return binarySearch.leftBinSearch(array, key);\n" + val summary2 = "Test calls BinarySearch::leftBinSearch,\n" + + " there it iterates the loop while(left < right - 1) once,\n" + + " inside this loop, the test executes conditions:\n" + + " (array[middle] == key): False,\n" + + " (array[middle] < key): True\n" + + " Test afterwards executes conditions:\n" + + " (found): False\n" + + " returns from: return -1;\n" + + " \n" + + "Test next returns from: return binarySearch.leftBinSearch(array, key);\n" + val summary3 = "Test calls BinarySearch::leftBinSearch,\n" + + " there it iterates the loop while(left < right - 1) once,\n" + + " inside this loop, the test executes conditions:\n" + + " (array[middle] == key): False,\n" + + " (array[middle] < key): False\n" + + " Test afterwards executes conditions:\n" + + " (found): False\n" + + " returns from: return -1;\n" + + " \n" + + "Test next returns from: return binarySearch.leftBinSearch(array, key);\n" + val summary4 = "Test calls BinarySearch::leftBinSearch,\n" + + " there it iterates the loop while(left < right - 1) once,\n" + + " inside this loop, the test executes conditions:\n" + + " (array[middle] == key): True,\n" + + " (array[middle] < key): False\n" + + " Test then executes conditions:\n" + + " (found): True\n" + + " returns from: return right + 1;\n" + + " \n" + + "Test further returns from: return binarySearch.leftBinSearch(array, key);\n" + val summary5 = "Test \n" + + "throws IllegalArgumentException in: return binarySearch.leftBinSearch(array, key);\n" + val summary6 = "Test \n" + + "throws IllegalArgumentException in: return binarySearch.leftBinSearch(array, key);\n" + val summary7 = "Test calls BinarySearch::leftBinSearch,\n" + + " there it invokes:\n" + + " BinarySearch::isUnsorted once\n" + + " triggers recursion of leftBinSearch once, \n" + + "Test throws NullPointerException in: return binarySearch.leftBinSearch(array, key);\n" + + val methodName1 = "testCallLeftBinSearch_NotFound" + val methodName2 = "testCallLeftBinSearch_MiddleOfArrayLessThanKey" + val methodName3 = "testCallLeftBinSearch_NotFound_1" + val methodName4 = "testCallLeftBinSearch_Found" + val methodName5 = "testCallLeftBinSearch_ThrowIllegalArgumentException" + val methodName6 = "testCallLeftBinSearch_ThrowIllegalArgumentException_1" + val methodName7 = "testCallLeftBinSearch_BinarySearchIsUnsorted" + + + val displayName1 = "found : False -> return -1" + val displayName2 = "array[middle] < key : True -> return -1" + val displayName3 = "while(left < right - 1) -> return -1" + val displayName4 = "array[middle] == key : True -> return right + 1" + val displayName5 = "return binarySearch.leftBinSearch(array, key) : True -> ThrowIllegalArgumentException" // TODO: probably return statement could be removed + val displayName6 = "return binarySearch.leftBinSearch(array, key) : True -> ThrowIllegalArgumentException" + val displayName7 = "return binarySearch.leftBinSearch(array, key) : True -> ThrowNullPointerException" + + + val summaryKeys = listOf( + summary1, + summary2, + summary3, + summary4, + summary5, + summary6, + summary7 + ) + + val displayNames = listOf( + displayName1, + displayName2, + displayName3, + displayName4, + displayName5, + displayName6, + displayName7 + ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3, + methodName4, + methodName5, + methodName6, + methodName7 ) - } - val keySummaryThreeDimensionalArray1 = "Test calls ArrayOfArrays::createNewThreeDimensionalArray,\n" + - " there it executes conditions:\n" + - " {@code (length != 2): True}\n" + - " returns from: {@code return new int[0][][];}" - val keySummaryThreeDimensionalArray2 = "Test calls ArrayOfArrays::createNewThreeDimensionalArray,\n" + - " there it executes conditions:\n" + - " {@code (length != 2): False}" + val method = InnerCalls::callLeftBinSearch + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } // TODO: SAT-1211 @Test fun testCallCreateNewThreeDimensionalArray() { - checkTwoArguments( - InnerCalls::callCreateNewThreeDimensionalArray, - summaryKeys = listOf( - keySummaryThreeDimensionalArray1, - keySummaryThreeDimensionalArray2 - ), - displayNames = listOf( - "length != 2 : True -> return new int[0][][]", - "length != 2 : False -> return matrix" - ) + val summary1 = "Test calls ArrayOfArrays::createNewThreeDimensionalArray,\n" + + " there it executes conditions:\n" + + " (length != 2): True\n" + + " returns from: return new int[0][][];\n" + + " " + val summary2 = "Test calls ArrayOfArrays::createNewThreeDimensionalArray,\n" + + " there it executes conditions:\n" + + " (length != 2): False\n" + + " iterates the loop for(int i = 0; i < length; i++) once,\n" + + " inside this loop, the test iterates the loop for(int j = 0; j < length; j++) once,\n" + + " inside this loop, the test iterates the loop for(int k = 0; k < length; k++)\n" + + " Test then returns from: return matrix;\n" + + " " + + val methodName1 = "testCallCreateNewThreeDimensionalArray_LengthNotEquals2" + val methodName2 = "testCallCreateNewThreeDimensionalArray_LengthEquals2" + + val displayName1 = "length != 2 : True -> return new int[0][][]" + val displayName2 = "length != 2 : False -> return matrix" + + val summaryKeys = listOf( + summary1, + summary2 + ) + + val displayNames = listOf( + displayName1, + displayName2 ) - } - val summaryCallInitExample1 = "Test calls ExceptionExamples::initAnArray,\n" + - " there it catches exception:\n" + - " {@code NegativeArraySizeException e}\n" + - " returns from: {@code return -2;}" - val summaryCallInitExample2 = "Test calls ExceptionExamples::initAnArray,\n" + - " there it catches exception:\n" + - " {@code IndexOutOfBoundsException e}\n" + - " returns from: {@code return -3;}" - val summaryCallInitExample3 = "Test calls ExceptionExamples::initAnArray,\n" + - " there it catches exception:\n" + - " {@code IndexOutOfBoundsException e}\n" + - " returns from: {@code return -3;}" - val summaryCallInitExample4 = "Test calls ExceptionExamples::initAnArray,\n" + - " there it returns from: {@code return a[n - 1] + a[n - 2];}" + val methodNames = listOf( + methodName1, + methodName2 + ) + + val method = InnerCalls::callCreateNewThreeDimensionalArray + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testCallInitExamples() { - checkOneArgument( - InnerCalls::callInitExamples, - summaryKeys = listOf( - summaryCallInitExample1, - summaryCallInitExample2, - summaryCallInitExample3, - summaryCallInitExample4 - ) + // NOTE: paths are different for test cases 1 and 2 + val summary1 = "Test calls ExceptionExamples::initAnArray,\n" + + " there it catches exception:\n" + + " IndexOutOfBoundsException e\n" + + " returns from: return -3;\n" + + " \n" + + "Test later returns from: return exceptionExamples.initAnArray(n);\n" + val summary2 = "Test calls ExceptionExamples::initAnArray,\n" + + " there it catches exception:\n" + + " IndexOutOfBoundsException e\n" + + " returns from: return -3;\n" + + " \n" + + "Test then returns from: return exceptionExamples.initAnArray(n);\n" + val summary3 = "Test calls ExceptionExamples::initAnArray,\n" + + " there it catches exception:\n" + + " NegativeArraySizeException e\n" + + " returns from: return -2;\n" + + " \n" + + "Test next returns from: return exceptionExamples.initAnArray(n);\n" + val summary4 = "Test calls ExceptionExamples::initAnArray,\n" + + " there it returns from: return a[n - 1] + a[n - 2];\n" + + " \n" + + "Test afterwards returns from: return exceptionExamples.initAnArray(n);\n" + + val methodName1 = "testCallInitExamples_CatchIndexOutOfBoundsException" + val methodName2 = "testCallInitExamples_CatchIndexOutOfBoundsException_1" + val methodName3 = "testCallInitExamples_CatchNegativeArraySizeException" + val methodName4 = "testCallInitExamples_ReturnN1OfAPlusN2OfA" + + val displayName1 = "Catch (IndexOutOfBoundsException e) -> return -3" + val displayName2 = "Catch (IndexOutOfBoundsException e) -> return -3" + val displayName3 = "Catch (NegativeArraySizeException e) -> return -2" + val displayName4 = "initAnArray -> return a[n - 1] + a[n - 2]" + + val method = InnerCalls::callInitExamples + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2, + summary3, + summary4 + ) + + val displayNames = listOf( + displayName1, + displayName2, + displayName3, + displayName4 + ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3, + methodName4 ) - } - val summaryCallFactorial1 = "Test calls Recursion::factorial,\n" + - " there it executes conditions:\n" + - " {@code (n == 0): True}\n" + - " returns from: {@code return 1;}" - val summaryCallFactorial2 = "Test calls Recursion::factorial,\n" + - " there it executes conditions:\n" + - " {@code (n < 0): True}\n" + - " triggers recursion of factorial once." - val summaryCallFactorial3 = "Test calls Recursion::factorial,\n" + - " there it executes conditions:\n" + - " {@code (n == 0): False}\n" + - " triggers recursion of factorial once, returns from: {@code return n * factorial(n - 1);}" + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testCallFactorial() { - checkOneArgument( - InnerCalls::callFactorial, - summaryKeys = listOf( - summaryCallFactorial1, - summaryCallFactorial2, - summaryCallFactorial3 - ), - displayNames = listOf( - "n == 0 : True -> return 1", - "n == 0 : False -> return n * factorial(n - 1)", - "return r.factorial(n) : True -> ThrowIllegalArgumentException" - ) + val summary1 = "Test calls Recursion::factorial,\n" + + " there it executes conditions:\n" + + " (n == 0): True\n" + + " returns from: return 1;\n" + + " \n" + + "Test next returns from: return r.factorial(n);\n" + val summary2 = "Test calls Recursion::factorial,\n" + + " there it executes conditions:\n" + + " (n == 0): False\n" + + " triggers recursion of factorial once, returns from: return n * factorial(n - 1);\n" + + " \n" + + "Test further returns from: return r.factorial(n);\n" + val summary3 = "Test calls Recursion::factorial,\n" + + " there it executes conditions:\n" + + " (n < 0): True\n" + + " triggers recursion of factorial once, \n" + + "Test throws IllegalArgumentException in: return r.factorial(n);\n" + + val methodName1 = "testCallFactorial_NEqualsZero" + val methodName2 = "testCallFactorial_NNotEqualsZero" + val methodName3 = "testCallFactorial_NLessThanZero" + + val displayName1 = "n == 0 : True -> return 1" + val displayName2 = "n == 0 : False -> return n * factorial(n - 1)" + val displayName3 = "return r.factorial(n) : True -> ThrowIllegalArgumentException" + + val method = InnerCalls::callFactorial + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2, + summary3 + ) + + val displayNames = listOf( + displayName1, + displayName2, + displayName3 + ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3 ) - } - val summaryCallSimpleInvoke1 = "Test calls InvokeExample::simpleFormula,\n" + - " there it executes conditions:\n" + - " {@code (fst < 100): True}" - val summaryCallSimpleInvoke2 = "Test calls InvokeExample::simpleFormula,\n" + - " there it executes conditions:\n" + - " {@code (fst < 100): False},\n" + - " {@code (snd < 100): True}" - val summaryCallSimpleInvoke3 = "Test calls InvokeExample::simpleFormula,\n" + - " there it executes conditions:\n" + - " {@code (fst < 100): False},\n" + - " {@code (snd < 100): False}\n" + - " invokes:\n" + - " InvokeExample::half once,\n" + - " InvokeExample::mult once" + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testCallSimpleInvoke() { - checkTwoArguments( - InnerCalls::callSimpleInvoke, - summaryKeys = listOf( - summaryCallSimpleInvoke1, - summaryCallSimpleInvoke2, - summaryCallSimpleInvoke3 - ) + val summary1 = "Test calls InvokeExample::simpleFormula,\n" + + " there it executes conditions:\n" + + " (fst < 100): False,\n" + + " (snd < 100): True\n" + + " \n" + + "Test throws IllegalArgumentException in: return invokeExample.simpleFormula(f, s);\n" + val summary2 = "Test calls InvokeExample::simpleFormula,\n" + + " there it executes conditions:\n" + + " (fst < 100): True\n" + + " \n" + + "Test throws IllegalArgumentException in: return invokeExample.simpleFormula(f, s);\n" + val summary3 = "Test calls InvokeExample::simpleFormula,\n" + + " there it executes conditions:\n" + + " (fst < 100): False,\n" + + " (snd < 100): False\n" + + " invokes:\n" + + " InvokeExample::half once,\n" + + " InvokeExample::mult once\n" + + " returns from: return mult(x, y);\n" + + " \n" + + "Test then returns from: return invokeExample.simpleFormula(f, s);\n" + + val methodName1 = "testCallSimpleInvoke_SndLessThan100" + val methodName2 = "testCallSimpleInvoke_FstLessThan100" + val methodName3 = "testCallSimpleInvoke_SndGreaterOrEqual100" + + val displayName1 = "return invokeExample.simpleFormula(f, s) : True -> ThrowIllegalArgumentException" + val displayName2 = "return invokeExample.simpleFormula(f, s) : True -> ThrowIllegalArgumentException" + val displayName3 = "fst < 100 : True -> return mult(x, y)" + + val method = InnerCalls::callSimpleInvoke + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2, + summary3 ) - } - val summaryCallStringExample1 = "Test calls StringExamples::indexOf,\n" + - " there it invokes:\n" + - " String::indexOf once" - val summaryCallStringExample2 = "Test calls StringExamples::indexOf,\n" + - " there it invokes:\n" + - " String::indexOf once" - val summaryCallStringExample3 = "Test calls StringExamples::indexOf,\n" + - " there it invokes:\n" + - " String::indexOf once" + val displayNames = listOf( + displayName1, + displayName2, + displayName3 + ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3 + ) + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testCallComplicatedMethod() { - checkTwoArguments( - InnerCalls::callStringExample, - summaryKeys = listOf( - summaryCallStringExample1, - summaryCallStringExample2, - summaryCallStringExample3 - ) + val summary1 = "Test calls StringExamples::indexOf,\n" + + " there it invokes:\n" + + " String::indexOf once\n" + + " triggers recursion of indexOf once, \n" + + "Test throws NullPointerException in: return stringExamples.indexOf(s, key);\n" + val summary2 = "Test calls StringExamples::indexOf,\n" + + " there it invokes:\n" + + " String::indexOf once\n" + + " \n" + + "Test throws NullPointerException \n" + val summary3 = "Test calls StringExamples::indexOf,\n" + + " there it executes conditions:\n" + + " (i > 0): False,\n" + + " (i == 0): True\n" + + " returns from: return i;\n" + + " \n" + + "Test further returns from: return stringExamples.indexOf(s, key);\n" + val summary4 = "Test calls StringExamples::indexOf,\n" + + " there it executes conditions:\n" + + " (i > 0): False,\n" + + " (i == 0): False\n" + + " returns from: return i;\n" + + " \n" + + "Test later returns from: return stringExamples.indexOf(s, key);\n" + val summary5 = "Test calls StringExamples::indexOf,\n" + + " there it executes conditions:\n" + + " (i > 0): True\n" + + " returns from: return i;\n" + + " \n" + + "Test afterwards returns from: return stringExamples.indexOf(s, key);\n" + + val methodName1 = "testCallStringExample_StringIndexOf" + val methodName2 = "testCallStringExample_StringIndexOf_1" + val methodName3 = "testCallStringExample_IEqualsZero" + val methodName4 = "testCallStringExample_INotEqualsZero" + val methodName5 = "testCallStringExample_IGreaterThanZero" + + val displayName1 = "return stringExamples.indexOf(s, key) : True -> ThrowNullPointerException" + val displayName2 = " -> ThrowNullPointerException" + val displayName3 = "i == 0 : True -> return i" + val displayName4 = "i == 0 : False -> return i" + val displayName5 = "i > 0 : True -> return i" + + val method = InnerCalls::callStringExample + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2, + summary3, + summary4, + summary5 ) - } - val summarySimpleSwitchCase1 = "Test calls Switch::simpleSwitch,\n" + - " there it activates switch case:" - val summarySimpleSwitchCase2 = "Test calls Switch::simpleSwitch,\n" + - " there it activates switch case: {@code 11}" - val summarySimpleSwitchCase3 = "Test calls Switch::simpleSwitch,\n" + - " there it activates switch case: {@code 12}" - val summarySimpleSwitchCase4 = "Test calls Switch::simpleSwitch,\n" + - " there it activates switch case: {@code 10}" - val summarySimpleSwitchCase5 = "Test calls Switch::simpleSwitch,\n" + - " there it activates switch case: {@code default}" + val displayNames = listOf( + displayName1, + displayName2, + displayName3, + displayName4, + displayName5 + ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3, + methodName4, + methodName5 + ) + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testCallSimpleSwitch() { - checkOneArgument( - InnerCalls::callSimpleSwitch, - summaryKeys = listOf( - summarySimpleSwitchCase1, - summarySimpleSwitchCase2, - summarySimpleSwitchCase3, - summarySimpleSwitchCase4, - summarySimpleSwitchCase5 - ), - displayNames = listOf( - "switch(x) case: 13 -> return 13", - "switch(x) case: 11 -> return 12", - "switch(x) case: 12 -> return 12", - "switch(x) case: 10 -> return 10", - "switch(x) case: Default -> return -1" - ) + val summary1 = "Test calls Switch::simpleSwitch,\n" + + " there it activates switch case: 12, returns from: return 12;\n" + + " " + val summary2 = "Test calls Switch::simpleSwitch,\n" + + " there it activates switch case: 13, returns from: return 13;\n" + + " " + val summary3 = "Test calls Switch::simpleSwitch,\n" + + " there it activates switch case: 10, returns from: return 10;\n" + + " " + val summary4 = "Test calls Switch::simpleSwitch,\n" + + " there it activates switch case: default, returns from: return -1;\n" + + " " + + val methodName1 = "testCallSimpleSwitch_Return12" + val methodName2 = "testCallSimpleSwitch_Return13" + val methodName3 = "testCallSimpleSwitch_Return10" + val methodName4 = "testCallSimpleSwitch_ReturnNegative1" + + val displayName1 = "switch(x) case: 12 -> return 12" + val displayName2 = "switch(x) case: 13 -> return 13" + val displayName3 = "switch(x) case: 10 -> return 10" + val displayName4 = "switch(x) case: Default -> return -1" + + val method = InnerCalls::callSimpleSwitch + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2, + summary3, + summary4 + ) + + val displayNames = listOf( + displayName1, + displayName2, + displayName3, + displayName4 ) - } - val summaryCallLookup1 = "Test calls Switch::lookupSwitch,\n" + - " there it activates switch case: {@code 30}" - val summaryCallLookup2 = "Test calls Switch::lookupSwitch,\n" + - " there it activates switch case: {@code 10}" - val summaryCallLookup3 = "Test calls Switch::lookupSwitch,\n" + - " there it activates switch case: {@code 20}" - val summaryCallLookup4 = "Test calls Switch::lookupSwitch,\n" + - " there it activates switch case: {@code 0}" - val summaryCallLookup5 = "Test calls Switch::lookupSwitch,\n" + - " there it activates switch case: {@code default}" + val methodNames = listOf( + methodName1, + methodName2, + methodName3, + methodName4 + ) + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testCallLookup() { - checkOneArgument( - InnerCalls::callLookup, - summaryKeys = listOf( - summaryCallLookup1, - summaryCallLookup2, - summaryCallLookup3, - summaryCallLookup4, - summaryCallLookup5 - ) + val summary1 = "Test calls Switch::lookupSwitch,\n" + + " there it activates switch case: 20, returns from: return 20;\n" + + " " + val summary2 = "Test calls Switch::lookupSwitch,\n" + + " there it activates switch case: 30, returns from: return 30;\n" + + " " + val summary3 = "Test calls Switch::lookupSwitch,\n" + + " there it activates switch case: 0, returns from: return 0;\n" + + " " + val summary4 = "Test calls Switch::lookupSwitch,\n" + + " there it activates switch case: default, returns from: return -1;\n" + + " " + + val methodName1 = "testCallLookup_Return20" + val methodName2 = "testCallLookup_Return30" + val methodName3 = "testCallLookup_ReturnZero" + val methodName4 = "testCallLookup_ReturnNegative1" + + val displayName1 = "switch(x) case: 20 -> return 20" + val displayName2 = "switch(x) case: 30 -> return 30" + val displayName3 = "switch(x) case: 0 -> return 0" + val displayName4 = "switch(x) case: Default -> return -1" + + val method = InnerCalls::callLookup + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2, + summary3, + summary4 ) - } - val summaryDoubleSimpleInvoke1 = "Test calls InnerCalls::callSimpleInvoke,\n" + - " there it calls InvokeExample::simpleFormula,\n" + - " there it executes conditions:\n" + - " {@code (fst < 100): True}" - val summaryDoubleSimpleInvoke2 = "Test calls InnerCalls::callSimpleInvoke,\n" + - " there it calls InvokeExample::simpleFormula,\n" + - " there it executes conditions:\n" + - " {@code (fst < 100): False},\n" + - " {@code (snd < 100): True}" - val summaryDoubleSimpleInvoke3 = "Test calls InnerCalls::callSimpleInvoke,\n" + - " there it calls InvokeExample::simpleFormula,\n" + - " there it executes conditions:\n" + - " {@code (fst < 100): False},\n" + - " {@code (snd < 100): False}\n" + - " invokes:\n" + - " InvokeExample::half once,\n" + - " InvokeExample::mult once\n" + - " returns from: {@code return mult(x, y);}" + val displayNames = listOf( + displayName1, + displayName2, + displayName3, + displayName4 + ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3, + methodName4 + ) + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testDoubleCall() { - checkTwoArguments( - InnerCalls::doubleSimpleInvoke, - summaryKeys = listOf( - summaryDoubleSimpleInvoke1, - summaryDoubleSimpleInvoke2, - summaryDoubleSimpleInvoke3 - ) + val summary1 = "Test calls InnerCalls::callSimpleInvoke,\n" + + " there it calls InvokeExample::simpleFormula,\n" + + " there it executes conditions:\n" + + " (fst < 100): True\n" + + " \n" + + "Test throws IllegalArgumentException in: callSimpleInvoke(f, s);\n" + val summary2 = "Test calls InnerCalls::callSimpleInvoke,\n" + + " there it calls InvokeExample::simpleFormula,\n" + + " there it executes conditions:\n" + + " (fst < 100): False,\n" + + " (snd < 100): True\n" + + " \n" + + "Test throws IllegalArgumentException in: callSimpleInvoke(f, s);\n" + val summary3 = "Test calls InnerCalls::callSimpleInvoke,\n" + + " there it calls InvokeExample::simpleFormula,\n" + + " there it executes conditions:\n" + + " (fst < 100): False,\n" + + " (snd < 100): False\n" + + " invokes:\n" + + " InvokeExample::half once,\n" + + " InvokeExample::mult once\n" + + " returns from: return mult(x, y);\n" + + " \n" + + " Test later returns from: return invokeExample.simpleFormula(f, s);\n" + + " " + + val methodName1 = "testDoubleSimpleInvoke_FstLessThan100" + val methodName2 = "testDoubleSimpleInvoke_SndLessThan100" + val methodName3 = "testDoubleSimpleInvoke_SndGreaterOrEqual100" + + val displayName1 = "callSimpleInvoke(f, s) : True -> ThrowIllegalArgumentException" + val displayName2 = "callSimpleInvoke(f, s) : True -> ThrowIllegalArgumentException" + val displayName3 = "fst < 100 : True -> return mult(x, y)" + + val method = InnerCalls::doubleSimpleInvoke + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2, + summary3 ) - } - val summaryDoubleCallLoopInsideLoop1 = "Test calls InnerCalls::callLoopInsideLoop,\n" + - " there it calls Cycles::loopInsideLoop,\n" + - " there it iterates the loop {@code for(int i = x - 5; i < x; i++)} once,\n" + - " inside this loop, the test executes conditions:\n" + - " {@code (i < 0): True}\n" + - " returns from: {@code return 2;}" - val summaryDoubleCallLoopInsideLoop2 = "Test calls InnerCalls::callLoopInsideLoop,\n" + - " there it calls Cycles::loopInsideLoop,\n" + - " there it iterates the loop {@code for(int i = x - 5; i < x; i++)} once,\n" + - " inside this loop, the test executes conditions:\n" + - " {@code (i < 0): False}\n" + - " iterates the loop {@code for(int j = i; j < x + i; j++)} once,\n" + - " inside this loop, the test executes conditions:\n" + - " {@code (j == 7): True}\n" + - " returns from: {@code return 1;}" - val summaryDoubleCallLoopInsideLoop3 = "Test calls InnerCalls::callLoopInsideLoop,\n" + - " there it calls Cycles::loopInsideLoop,\n" + - " there it does not iterate {@code for(int i = x - 5; i < x; i++)}, {@code for(int j = i; j < x + i; j++)}, returns from: {@code return -1;}" - val summaryDoubleCallLoopInsideLoop4 = "Test calls InnerCalls::callLoopInsideLoop,\n" + - " there it calls Cycles::loopInsideLoop,\n" + - " there it iterates the loop {@code for(int i = x - 5; i < x; i++)} once,\n" + - " inside this loop, the test executes conditions:\n" + - " {@code (i < 0): False}\n" + - " iterates the loop {@code for(int j = i; j < x + i; j++)} 3 times,\n" + - " inside this loop, the test executes conditions:\n" + - " {@code (j == 7): False}\n" + - " {@code (j == 7): True}\n" + - " returns from: {@code return 1;}" - val summaryDoubleCallLoopInsideLoop5 = "Test calls InnerCalls::callLoopInsideLoop,\n" + - " there it calls Cycles::loopInsideLoop,\n" + - " there it iterates the loop {@code for(int i = x - 5; i < x; i++)} 5 times." + val displayNames = listOf( + displayName1, + displayName2, + displayName3 + ) + val methodNames = listOf( + methodName1, + methodName2, + methodName3 + ) + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testDoubleCallLoopInsideLoop() { - checkOneArgument( - InnerCalls::doubleCallLoopInsideLoop, - summaryKeys = listOf( - summaryDoubleCallLoopInsideLoop1, - summaryDoubleCallLoopInsideLoop2, - summaryDoubleCallLoopInsideLoop3, - summaryDoubleCallLoopInsideLoop4, - summaryDoubleCallLoopInsideLoop5, - ) + val summary1 = "Test calls InnerCalls::callLoopInsideLoop,\n" + + " there it calls Cycles::loopInsideLoop,\n" + + " there it iterates the loop for(int i = x - 5; i < x; i++) once,\n" + + " inside this loop, the test executes conditions:\n" + + " (i < 0): True\n" + + " returns from: return 2;\n" + + " Test afterwards returns from: return cycles.loopInsideLoop(x);\n" + + " \n" + + "Test further returns from: return result;\n" + val summary2 = "Test calls InnerCalls::callLoopInsideLoop,\n" + + " there it calls Cycles::loopInsideLoop,\n" + + " there it does not iterate for(int i = x - 5; i < x; i++), for(int j = i; j < x + i; j++), returns from: return -1;\n" + + " \n" + + " Test next returns from: return cycles.loopInsideLoop(x);\n" + + " \n" + + "Test later returns from: return result;\n" + val summary3 = "Test calls InnerCalls::callLoopInsideLoop,\n" + + " there it calls Cycles::loopInsideLoop,\n" + + " there it iterates the loop for(int i = x - 5; i < x; i++) once,\n" + + " inside this loop, the test executes conditions:\n" + + " (i < 0): False\n" + + " iterates the loop for(int j = i; j < x + i; j++) once,\n" + + " inside this loop, the test executes conditions:\n" + + " (j == 7): True\n" + + " returns from: return 1;\n" + + " Test next returns from: return cycles.loopInsideLoop(x);\n" + + " \n" + + "Test further returns from: return result;\n" + val summary4 = "Test calls InnerCalls::callLoopInsideLoop,\n" + + " there it calls Cycles::loopInsideLoop,\n" + + " there it iterates the loop for(int i = x - 5; i < x; i++) once,\n" + + " inside this loop, the test executes conditions:\n" + + " (i < 0): False\n" + + " iterates the loop for(int j = i; j < x + i; j++) twice,\n" + + " inside this loop, the test executes conditions:\n" + + " (j == 7): False\n" + + " (j == 7): True\n" + + " returns from: return 1;\n" + + " Test further returns from: return cycles.loopInsideLoop(x);\n" + + " \n" + + "Test then returns from: return result;\n" + val summary5 = "Test calls InnerCalls::callLoopInsideLoop,\n" + + " there it calls Cycles::loopInsideLoop,\n" + + " there it iterates the loop for(int i = x - 5; i < x; i++) 5 times. \n" + + " Test later does not iterate for(int j = i; j < x + i; j++), returns from: return -1;\n" + + " \n" + + " Test afterwards returns from: return cycles.loopInsideLoop(x);\n" + + " \n" + + "Test then returns from: return result;\n" + + val methodName1 = "testDoubleCallLoopInsideLoop_ILessThanZero" + val methodName2 = "testDoubleCallLoopInsideLoop_ReturnNegative1" + val methodName3 = "testDoubleCallLoopInsideLoop_JEquals7" + val methodName4 = "testDoubleCallLoopInsideLoop_JNotEquals7" + val methodName5 = "testDoubleCallLoopInsideLoop_ReturnNegative1_1" + + val displayName1 = "i < 0 : True -> return 2" + val displayName2 = "loopInsideLoop -> return -1" + val displayName3 = "i < 0 : False -> return 1" + val displayName4 = "j == 7 : False -> return 1" + val displayName5 = "loopInsideLoop -> return -1" + + val method = InnerCalls::doubleCallLoopInsideLoop + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2, + summary3, + summary4, + summary5 + ) + + val displayNames = listOf( + displayName1, + displayName2, + displayName3, + displayName4, + displayName5 + ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3, + methodName4, + methodName5 ) - } - val summaryCallFib1 = "Test calls Recursion::fib,\n" + - " there it executes conditions:\n" + - " {@code (n == 0): True}" - val summaryCallFib2 = "Test calls Recursion::fib,\n" + - " there it executes conditions:\n" + - " {@code (n == 0): False},\n" + - " {@code (n == 1): True}" - val summaryCallFib3 = "Test calls Recursion::fib,\n" + - " there it executes conditions:\n" + - " {@code (n == 0): False},\n" + - " {@code (n == 1): False}\n" + - " triggers recursion of fib twice, returns from: {@code return fib(n - 1) + fib(n - 2);}" - val summaryCallFib4 = "Test calls Recursion::fib,\n" + - " there it executes conditions:\n" + - " {@code (n < 0): True}\n" + - " triggers recursion of fib once." + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testInnerCallFib() { - checkOneArgument( - InnerCalls::callFib, - summaryKeys = listOf( - summaryCallFib1, - summaryCallFib2, - summaryCallFib3, - summaryCallFib4 - ), - displayNames = listOf( - "n == 0 : True -> return 0", - "n == 1 : True -> return 1", - "n == 1 : False -> return fib(n - 1) + fib(n - 2)", - "return r.fib(n) : True -> ThrowIllegalArgumentException" - ) + val summary1 = "Test calls Recursion::fib,\n" + + " there it executes conditions:\n" + + " (n == 0): False,\n" + + " (n == 1): True\n" + + " returns from: return 1;\n" + + " \n" + + "Test next returns from: return r.fib(n);\n" + val summary2 = "Test calls Recursion::fib,\n" + + " there it executes conditions:\n" + + " (n == 0): True\n" + + " returns from: return 0;\n" + + " \n" + + "Test next returns from: return r.fib(n);\n" + val summary3 = "Test calls Recursion::fib,\n" + + " there it executes conditions:\n" + + " (n == 0): False,\n" + + " (n == 1): False\n" + + " triggers recursion of fib twice, returns from: return fib(n - 1) + fib(n - 2);\n" + + " \n" + + "Test next returns from: return r.fib(n);\n" + val summary4 = "Test calls Recursion::fib,\n" + + " there it executes conditions:\n" + + " (n < 0): True\n" + + " triggers recursion of fib once, \n" + + "Test throws IllegalArgumentException in: return r.fib(n);\n" + + val methodName1 = "testCallFib_NEquals1" + val methodName2 = "testCallFib_NEqualsZero" + val methodName3 = "testCallFib_NNotEquals1" + val methodName4 = "testCallFib_NLessThanZero" + + val displayName1 = "n == 1 : True -> return 1" + val displayName2 = "n == 0 : True -> return 0" + val displayName3 = "n == 1 : False -> return fib(n - 1) + fib(n - 2)" + val displayName4 = "return r.fib(n) : True -> ThrowIllegalArgumentException" + + val method = InnerCalls::callFib + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2, + summary3, + summary4 + ) + + val displayNames = listOf( + displayName1, + displayName2, + displayName3, + displayName4 ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3, + methodName4 + ) + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) } } \ No newline at end of file diff --git a/utbot-summary-tests/src/test/kotlin/examples/inner/SummaryNestedCallsTest.kt b/utbot-summary-tests/src/test/kotlin/examples/inner/SummaryNestedCallsTest.kt index e6e0eaa820..096aed7fc9 100644 --- a/utbot-summary-tests/src/test/kotlin/examples/inner/SummaryNestedCallsTest.kt +++ b/utbot-summary-tests/src/test/kotlin/examples/inner/SummaryNestedCallsTest.kt @@ -6,40 +6,62 @@ import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Tag import org.utbot.examples.inner.NestedCalls import org.junit.jupiter.api.Test -@Disabled +import org.utbot.examples.DoNotCalculate +import org.utbot.examples.inner.InnerCalls +import org.utbot.framework.plugin.api.MockStrategyApi + class SummaryNestedCallsTest : SummaryTestCaseGeneratorTest( NestedCalls::class, ) { - - val summaryNestedCall1 = "Test calls NestedCalls\$ExceptionExamples::initAnArray,\n" + - " there it catches exception:\n" + - " {@code NegativeArraySizeException e}" - val summaryNestedCall2 = "Test calls NestedCalls\$ExceptionExamples::initAnArray,\n" + - " there it catches exception:\n" + - " {@code IndexOutOfBoundsException e}" - val summaryNestedCall3 = "Test calls NestedCalls\$ExceptionExamples::initAnArray,\n" + - " there it catches exception:\n" + - " {@code IndexOutOfBoundsException e}" - val summaryNestedCall4 = "
\n" +
-            "Test calls NestedCalls\$ExceptionExamples::initAnArray,\n" +
-            "    there it returns from: {@code return a[n - 1] + a[n - 2];}"
-
     @Test
     fun testInvokeExample() {
-        checkOneArgument(
-            NestedCalls::callInitExamples,
-            summaryKeys = listOf(
-                summaryNestedCall1,
-                summaryNestedCall2,
-                summaryNestedCall3,
-                summaryNestedCall4,
-            ),
-            displayNames = listOf(
-                "Catch (NegativeArraySizeException e) -> return -2",
-                "Catch (IndexOutOfBoundsException e) -> return -3",
-                "Catch (IndexOutOfBoundsException e) -> return -3",
-                "initAnArray -> return a[n - 1] + a[n - 2]"
-            )
+        val summary1 = "Test calls NestedCalls\$ExceptionExamples::initAnArray,\n" +
+                "    there it catches exception:\n" +
+                "        IndexOutOfBoundsException e\n" +
+                "    returns from: return -3;\n" +
+                "    \n" +
+                "Test next returns from: return exceptionExamples.initAnArray(n);\n"
+        val summary2 = "Test calls NestedCalls\$ExceptionExamples::initAnArray,\n" +
+                "    there it catches exception:\n" +
+                "        NegativeArraySizeException e\n" +
+                "    returns from: return -2;\n" +
+                "    \n" +
+                "Test afterwards returns from: return exceptionExamples.initAnArray(n);"
+        val summary3 = "Test calls NestedCalls\$ExceptionExamples::initAnArray,\n" +
+                "    there it returns from: return a[n - 1] + a[n - 2];\n" +
+                "    \n" +
+                "Test next returns from: return exceptionExamples.initAnArray(n);\n"
+
+        val methodName1 = "testCallInitExamples_CatchIndexOutOfBoundsException"
+        val methodName2 = "testCallInitExamples_CatchNegativeArraySizeException"
+        val methodName3 = "testCallInitExamples_ReturnN1OfAPlusN2OfA"
+
+        val displayName1 = "Catch (IndexOutOfBoundsException e) -> return -3"
+        val displayName2 = "Catch (NegativeArraySizeException e) -> return -2"
+        val displayName3 = "initAnArray -> return a[n - 1] + a[n - 2]"
+
+        val method = NestedCalls::callInitExamples
+        val mockStrategy = MockStrategyApi.NO_MOCKS
+        val coverage = DoNotCalculate
+
+        val summaryKeys = listOf(
+            summary1,
+            summary2,
+            summary3
+        )
+
+        val displayNames = listOf(
+            displayName1,
+            displayName2,
+            displayName3
         )
+
+        val methodNames = listOf(
+            methodName1,
+            methodName2,
+            methodName3
+        )
+
+        check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
     }
 }
\ No newline at end of file
diff --git a/utbot-summary-tests/src/test/kotlin/examples/ternary/SummaryTernary.kt b/utbot-summary-tests/src/test/kotlin/examples/ternary/SummaryTernary.kt
index f5a3bfc4db..893b223665 100644
--- a/utbot-summary-tests/src/test/kotlin/examples/ternary/SummaryTernary.kt
+++ b/utbot-summary-tests/src/test/kotlin/examples/ternary/SummaryTernary.kt
@@ -6,379 +6,586 @@ import org.junit.jupiter.api.Disabled
 import org.utbot.examples.ternary.Ternary
 import org.junit.jupiter.api.Tag
 import org.junit.jupiter.api.Test
+import org.utbot.examples.DoNotCalculate
+import org.utbot.examples.inner.InnerCalls
+import org.utbot.examples.inner.NestedCalls
+import org.utbot.framework.plugin.api.MockStrategyApi
 
-@Disabled
 class SummaryTernary : SummaryTestCaseGeneratorTest(
     Ternary::class,
 ) {
-
-    val summaryMax1 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (val1 >= val2): False}\n" +
-            "returns from: {@code return val1 >= val2 ? val1 : val2;}\n" +
-            "
" - val summaryMax2 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (val1 >= val2): True}\n" +
-            "returns from: {@code return val1 >= val2 ? val1 : val2;}\n" +
-            "
" - @Test fun testMax() { - checkTwoArguments( - Ternary::max, - summaryKeys = listOf( - summaryMax1, - summaryMax2 - ), - displayNames = listOf( - "val1 >= val2 : False -> return val1 >= val2 ? val1 : val2", - "val1 >= val2 : True -> return val1 >= val2 ? val1 : val2" - ) + val summary1 = "Test executes conditions:\n" + + " (val1 >= val2): False\n" + + "returns from: return val1 >= val2 ? val1 : val2;\n" + val summary2 = "Test executes conditions:\n" + + " (val1 >= val2): True\n" + + "returns from: return val1 >= val2 ? val1 : val2;\n" + + val methodName1 = "testMax_Val1LessThanVal2" + val methodName2 = "testMax_Val1GreaterOrEqualVal2" + + val displayName1 = "val1 >= val2 : False -> return val1 >= val2 ? val1 : val2" + val displayName2 = "val1 >= val2 : True -> return val1 >= val2 ? val1 : val2" + + val method = Ternary::max + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2 + ) + + val displayNames = listOf( + displayName1, + displayName2 + ) + + val methodNames = listOf( + methodName1, + methodName2 ) - } - val summarySimpleOperation = "
\n" +
-            "Test returns from: {@code return result;}\n" +
-            "
" + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testSimpleOperation() { - checkTwoArguments( - Ternary::simpleOperation, - summaryKeys = listOf(summarySimpleOperation), - displayNames = listOf( - "-> return result" - ) + val summary1 = "Test returns from: return result;\n" + + val methodName1 = "testSimpleOperation_ReturnResult" + + val displayName1 = "-> return result" + + val method = Ternary::simpleOperation + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1 + ) + + val displayNames = listOf( + displayName1 + ) + + val methodNames = listOf( + methodName1 ) - } - val summaryStringExpr1 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num > 10): True}\n" +
-            "returns from: {@code return num > 10 ? \"Number is greater than 10\" : num > 5 ? \"Number is greater than 5\" : \"Number is less than equal to 5\";}\n" +
-            "
" - val summaryStringExpr2 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num > 10): False},\n" +
-            "    {@code (num > 5): False}\n" +
-            "returns from: {@code return num > 10 ? \"Number is greater than 10\" : num > 5 ? \"Number is greater than 5\" : \"Number is less than equal to 5\";}\n" +
-            "
" - val summaryStringExpr3 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num > 10): False},\n" +
-            "    {@code (num > 5): True}\n" +
-            "returns from: {@code return num > 10 ? \"Number is greater than 10\" : num > 5 ? \"Number is greater than 5\" : \"Number is less than equal to 5\";}\n" +
-            "
" + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testStringExpr() { - checkOneArgument( - Ternary::stringExpr, - summaryKeys = listOf( - summaryStringExpr1, - summaryStringExpr2, - summaryStringExpr3 - ) + val summary1 = "Test executes conditions:\n" + + " (num > 10): True\n" + + "returns from: return num > 10 ? \"Number is greater than 10\" : num > 5 ? \"Number is greater than 5\" : \"Number is less than equal to 5\";\n" + val summary2 = "Test executes conditions:\n" + + " (num > 10): False,\n" + + " (num > 5): False\n" + + "returns from: return num > 10 ? \"Number is greater than 10\" : num > 5 ? \"Number is greater than 5\" : \"Number is less than equal to 5\";\n" + val summary3 = "Test executes conditions:\n" + + " (num > 10): False,\n" + + " (num > 5): True\n" + + "returns from: return num > 10 ? \"Number is greater than 10\" : num > 5 ? \"Number is greater than 5\" : \"Number is less than equal to 5\";\n" + + val methodName1 = "testStringExpr_NumGreaterThan10" + val methodName2 = "testStringExpr_NumLessOrEqual5" + val methodName3 = "testStringExpr_NumGreaterThan5" + + val displayName1 = "num > 10 : True -> return num > 10 ? \"Number is greater than 10\" : num > 5 ? \"Number is greater than 5\" : \"Number is less than equal to 5\"" + val displayName2 = "num > 5 : False -> return num > 10 ? \"Number is greater than 10\" : num > 5 ? \"Number is greater than 5\" : \"Number is less than equal to 5\"" + val displayName3 = "num > 5 : True -> return num > 10 ? \"Number is greater than 10\" : num > 5 ? \"Number is greater than 5\" : \"Number is less than equal to 5\"" + + val method = Ternary::stringExpr + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2, + summary3 + ) + + val displayNames = listOf( + displayName1, + displayName2, + displayName3 ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3 + ) + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) } @Test - @Tag("slow") fun testParse() { - checkOneArgument( - Ternary::parse, - summaryKeys = listOf() + val summary1 = "Test executes conditions:\n" + + " (input == null || input.equals(\"\")): False\n" + + "returns from: return value;\n" + val summary2 = "Test executes conditions:\n" + + " (input == null || input.equals(\"\")): True\n" + + "invokes:\n" + + " String::equals once\n" + + "returns from: return value;\n" + val summary3 = "Test executes conditions:\n" + + " (input == null || input.equals(\"\")): True,\n" + + " (input == null || input.equals(\"\")): False\n" + + "invokes:\n" + + " Integer::parseInt once\n" + + "\n" + + "throws NumberFormatException in: Integer.parseInt(input)\n" + + val methodName1 = "testParse_InputEqualsNullOrInputEquals" + val methodName2 = "testParse_InputNotEqualsNullOrInputEquals" + val methodName3 = "testParse_InputEqualsNullOrInputEquals_1" + + val displayName1 = "input == null || input.equals(\"\") : False -> return value" + val displayName2 = "input == null || input.equals(\"\") : True -> return value" + val displayName3 = "Integer.parseInt(input) : True -> ThrowNumberFormatException" + + val method = Ternary::parse + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2, + summary3 ) - } - val summaryMinValue1 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code ((a < b)): False}\n" +
-            "returns from: {@code return (a < b) ? a : b;}\n" +
-            "
" - val summaryMinValue2 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code ((a < b)): True}\n" +
-            "returns from: {@code return (a < b) ? a : b;}\n" +
-            "
" + val displayNames = listOf( + displayName1, + displayName2, + displayName3 + ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3 + ) + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testMinValue() { - checkTwoArguments( - Ternary::minValue, - summaryKeys = listOf( - summaryMinValue1, - summaryMinValue2 - ), - displayNames = listOf( - "a < b : False -> return (a < b) ? a : b", - "a < b : True -> return (a < b) ? a : b" - ) + val summary1 = "Test executes conditions:\n" + + " ((a < b)): False\n" + + "returns from: return (a < b) ? a : b;\n" + val summary2 = "Test executes conditions:\n" + + " ((a < b)): True\n" + + "returns from: return (a < b) ? a : b;\n" + + val methodName1 = "testMinValue_AGreaterOrEqualB" + val methodName2 = "testMinValue_ALessThanB" + + val displayName1 = "a < b : False -> return (a < b) ? a : b" + val displayName2 = "a < b : True -> return (a < b) ? a : b" + + val method = Ternary::minValue + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2 + ) + + val displayNames = listOf( + displayName1, + displayName2 + ) + + val methodNames = listOf( + methodName1, + methodName2 ) - } - val summarySubDelay1 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (flag): False}\n" +
-            "returns from: {@code return flag ? 100 : 0;}\n" +
-            "
" - val summarySubDelay2 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (flag): True}\n" +
-            "returns from: {@code return flag ? 100 : 0;}\n" +
-            "
" + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testSubDelay() { - checkOneArgument( - Ternary::subDelay, - summaryKeys = listOf( - summarySubDelay1, - summarySubDelay2 - ), - displayNames = listOf( - "flag : False -> return flag ? 100 : 0", - "flag : True -> return flag ? 100 : 0" - ) + val summary1 = "Test executes conditions:\n" + + " (flag): False\n" + + "returns from: return flag ? 100 : 0;\n" + val summary2 = "Test executes conditions:\n" + + " (flag): True\n" + + "returns from: return flag ? 100 : 0;\n" + + val methodName1 = "testSubDelay_NotFlag" + val methodName2 = "testSubDelay_Flag" + + val displayName1 = "flag : False -> return flag ? 100 : 0" + val displayName2 = "flag : True -> return flag ? 100 : 0" + + val method = Ternary::subDelay + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2 + ) + + val displayNames = listOf( + displayName1, + displayName2 + ) + + val methodNames = listOf( + methodName1, + methodName2 ) - } - val summaryPlusOrMinus1 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code ((num1 > num2)): False}\n" +
-            "returns from: {@code return (num1 > num2) ? (num1 + num2) : (num1 - num2);}\n" +
-            "
" - val summaryPlusOrMinus2 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code ((num1 > num2)): True}\n" +
-            "returns from: {@code return (num1 > num2) ? (num1 + num2) : (num1 - num2);}\n" +
-            "
" + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testPlusOrMinus() { - checkTwoArguments( - Ternary::plusOrMinus, - summaryKeys = listOf( - summaryPlusOrMinus1, - summaryPlusOrMinus2 - ) + val summary1 = "Test executes conditions:\n" + + " ((num1 > num2)): False\n" + + "returns from: return (num1 > num2) ? (num1 + num2) : (num1 - num2);\n" + val summary2 = "Test executes conditions:\n" + + " ((num1 > num2)): True\n" + + "returns from: return (num1 > num2) ? (num1 + num2) : (num1 - num2);\n" + + val methodName1 = "testPlusOrMinus_Num1LessOrEqualNum2" + val methodName2 = "testPlusOrMinus_Num1GreaterThanNum2" + + val displayName1 = "num1 > num2 : False -> return (num1 > num2) ? (num1 + num2) : (num1 - num2)" + val displayName2 = "num1 > num2 : True -> return (num1 > num2) ? (num1 + num2) : (num1 - num2)" + + val method = Ternary::plusOrMinus + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2 + ) + + val displayNames = listOf( + displayName1, + displayName2 + ) + + val methodNames = listOf( + methodName1, + methodName2 ) - } - val summaryLongTernary1 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num1 > num2): True}\n" +
-            "returns from: {@code return num1 > num2 ? 1 : num1 == num2 ? 2 : 3;}\n" +
-            "
" - val summaryLongTernary2 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num1 > num2): False},\n" +
-            "    {@code (num1 == num2): True}\n" +
-            "returns from: {@code return num1 > num2 ? 1 : num1 == num2 ? 2 : 3;}\n" +
-            "
" - val summaryLongTernary3 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num1 > num2): False},\n" +
-            "    {@code (num1 == num2): False}\n" +
-            "returns from: {@code return num1 > num2 ? 1 : num1 == num2 ? 2 : 3;}\n" +
-            "
" + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testLongTernary() { - checkTwoArguments( - Ternary::longTernary, - summaryKeys = listOf( - summaryLongTernary1, - summaryLongTernary2, - summaryLongTernary3 - ) + val summary1 = "Test executes conditions:\n" + + " (num1 > num2): True\n" + + "returns from: return num1 > num2 ? 1 : num1 == num2 ? 2 : 3;\n" + val summary2 = "Test executes conditions:\n" + + " (num1 > num2): False,\n" + + " (num1 == num2): True\n" + + "returns from: return num1 > num2 ? 1 : num1 == num2 ? 2 : 3;\n" + val summary3 = "Test executes conditions:\n" + + " (num1 > num2): False,\n" + + " (num1 == num2): False\n" + + "returns from: return num1 > num2 ? 1 : num1 == num2 ? 2 : 3;\n" + + val methodName1 = "testLongTernary_Num1GreaterThanNum2" + val methodName2 = "testLongTernary_Num1EqualsNum2" + val methodName3 = "testLongTernary_Num1NotEqualsNum2" + + val displayName1 = "num1 > num2 : True -> return num1 > num2 ? 1 : num1 == num2 ? 2 : 3" + val displayName2 = "num1 == num2 : True -> return num1 > num2 ? 1 : num1 == num2 ? 2 : 3" + val displayName3 = "num1 == num2 : False -> return num1 > num2 ? 1 : num1 == num2 ? 2 : 3" + + val method = Ternary::longTernary + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2, + summary3 + ) + + val displayNames = listOf( + displayName1, + displayName2, + displayName3 + ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3 ) - } - val summaryVeryLongTernary1 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num1 > num2): True}\n" +
-            "returns from: {@code return num1 > num2 ? 1 : num1 == num2 ? 2 : num2 > num3 ? 3 : num2 == num3 ? 4 : 5;}\n" +
-            "
" - val summaryVeryLongTernary2 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num1 > num2): False},\n" +
-            "    {@code (num1 == num2): False},\n" +
-            "    {@code (num2 > num3): False},\n" +
-            "    {@code (num2 == num3): False}\n" +
-            "returns from: {@code return num1 > num2 ? 1 : num1 == num2 ? 2 : num2 > num3 ? 3 : num2 == num3 ? 4 : 5;}\n" +
-            "
" - val summaryVeryLongTernary3 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num1 > num2): False},\n" +
-            "    {@code (num1 == num2): True}\n" +
-            "returns from: {@code return num1 > num2 ? 1 : num1 == num2 ? 2 : num2 > num3 ? 3 : num2 == num3 ? 4 : 5;}\n" +
-            "
" - val summaryVeryLongTernary4 = "Test executes conditions:\n" + - " {@code (num1 > num2): False},\n" + - " {@code (num1 == num2): False},\n" + - " {@code (num2 > num3): False},\n" + - " {@code (num2 == num3): True}\n" + - "returns from: {@code return num1 > num2 ? 1 : num1 == num2 ? 2 : num2 > num3 ? 3 : num2 == num3 ? 4 : 5;}\n" + - "
" - val summaryVeryLongTernary5 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num1 > num2): False},\n" +
-            "    {@code (num1 == num2): False},\n" +
-            "    {@code (num2 > num3): True}\n" +
-            "returns from: {@code return num1 > num2 ? 1 : num1 == num2 ? 2 : num2 > num3 ? 3 : num2 == num3 ? 4 : 5;}\n" +
-            "
" + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testVeryLongTernary() { - checkThreeArguments( - Ternary::veryLongTernary, - summaryKeys = listOf( - summaryVeryLongTernary1, - summaryVeryLongTernary2, - summaryVeryLongTernary3, - summaryVeryLongTernary4, - summaryVeryLongTernary5 - ) + val summary1 = "Test executes conditions:\n" + + " (num1 > num2): True\n" + + "returns from: return num1 > num2 ? 1 : num1 == num2 ? 2 : num2 > num3 ? 3 : num2 == num3 ? 4 : 5;\n" + val summary2 = "Test executes conditions:\n" + + " (num1 > num2): False,\n" + + " (num1 == num2): False,\n" + + " (num2 > num3): False,\n" + + " (num2 == num3): False\n" + + "returns from: return num1 > num2 ? 1 : num1 == num2 ? 2 : num2 > num3 ? 3 : num2 == num3 ? 4 : 5;\n" + val summary3 = "Test executes conditions:\n" + + " (num1 > num2): False,\n" + + " (num1 == num2): True\n" + + "returns from: return num1 > num2 ? 1 : num1 == num2 ? 2 : num2 > num3 ? 3 : num2 == num3 ? 4 : 5;\n" + val summary4 = "Test executes conditions:\n" + + " (num1 > num2): False,\n" + + " (num1 == num2): False,\n" + + " (num2 > num3): False,\n" + + " (num2 == num3): True\n" + + "returns from: return num1 > num2 ? 1 : num1 == num2 ? 2 : num2 > num3 ? 3 : num2 == num3 ? 4 : 5;\n" + val summary5 = "Test executes conditions:\n" + + " (num1 > num2): False,\n" + + " (num1 == num2): False,\n" + + " (num2 > num3): True\n" + + "returns from: return num1 > num2 ? 1 : num1 == num2 ? 2 : num2 > num3 ? 3 : num2 == num3 ? 4 : 5;\n" + + val methodName1 = "testVeryLongTernary_Num1GreaterThanNum2" + val methodName2 = "testVeryLongTernary_Num2NotEqualsNum3" + val methodName3 = "testVeryLongTernary_Num1EqualsNum2" + val methodName4 = "testVeryLongTernary_Num2EqualsNum3" + val methodName5 = "testVeryLongTernary_Num2GreaterThanNum3" + + val displayName1 = "num1 > num2 : True -> return num1 > num2 ? 1 : num1 == num2 ? 2 : num2 > num3 ? 3 : num2 == num3 ? 4 : 5" + val displayName2 = "num2 == num3 : False -> return num1 > num2 ? 1 : num1 == num2 ? 2 : num2 > num3 ? 3 : num2 == num3 ? 4 : 5" + val displayName3 = "num1 == num2 : True -> return num1 > num2 ? 1 : num1 == num2 ? 2 : num2 > num3 ? 3 : num2 == num3 ? 4 : 5" + val displayName4 = "num2 == num3 : True -> return num1 > num2 ? 1 : num1 == num2 ? 2 : num2 > num3 ? 3 : num2 == num3 ? 4 : 5" + val displayName5 = "num2 > num3 : True -> return num1 > num2 ? 1 : num1 == num2 ? 2 : num2 > num3 ? 3 : num2 == num3 ? 4 : 5" + + val method = Ternary::veryLongTernary + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2, + summary3, + summary4, + summary5 + ) + + val displayNames = listOf( + displayName1, + displayName2, + displayName3, + displayName4, + displayName5 + ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3, + methodName4, + methodName5 ) - } - val summaryMinMax1 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num1 > num2): False}\n" +
-            "calls Ternary::minValue,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code ((a < b)): True}\n" +
-            "    returns from: {@code return (a < b) ? a : b;}"
-    val summaryMinMax2 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num1 > num2): True}\n" +
-            "calls Ternary::max,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code (val1 >= val2): True}\n" +
-            "    returns from: {@code return val1 >= val2 ? val1 : val2;}"
-    val summaryMinMax3 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num1 > num2): False}\n" +
-            "calls Ternary::minValue,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code ((a < b)): False}\n" +
-            "    returns from: {@code return (a < b) ? a : b;}"
+        check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
+    }
 
     @Test
     fun testMinMax() {
-        checkTwoArguments(
-            Ternary::minMax,
-            summaryKeys = listOf(
-                summaryMinMax1,
-                summaryMinMax2,
-                summaryMinMax3
-            )
+        val summary1 = "Test executes conditions:\n" +
+                "    (num1 > num2): False\n" +
+                "calls Ternary::minValue,\n" +
+                "    there it executes conditions:\n" +
+                "        ((a < b)): True\n" +
+                "    returns from: return (a < b) ? a : b;\n" +
+                "    \n" +
+                "Test then returns from: return a;\n"
+        val summary2 = "Test executes conditions:\n" +
+                "    (num1 > num2): True\n" +
+                "calls Ternary::max,\n" +
+                "    there it executes conditions:\n" +
+                "        (val1 >= val2): True\n" +
+                "    returns from: return val1 >= val2 ? val1 : val2;\n" +
+                "    \n" +
+                "Test further returns from: return a;\n"
+        val summary3 = "Test executes conditions:\n" +
+                "    (num1 > num2): False\n" +
+                "calls Ternary::minValue,\n" +
+                "    there it executes conditions:\n" +
+                "        ((a < b)): False\n" +
+                "    returns from: return (a < b) ? a : b;\n" +
+                "    \n" +
+                "Test next returns from: return a;\n"
+
+        val methodName1 = "testMinMax_ALessThanB"
+        val methodName2 = "testMinMax_Val1GreaterOrEqualVal2"
+        val methodName3 = "testMinMax_AGreaterOrEqualB"
+
+        val displayName1 = "a < b : True -> return (a < b) ? a : b"
+        val displayName2 = "val1 >= val2 : True -> return val1 >= val2 ? val1 : val2"
+        val displayName3 = "a < b : False -> return (a < b) ? a : b"
+
+        val method = Ternary::minMax
+        val mockStrategy = MockStrategyApi.NO_MOCKS
+        val coverage = DoNotCalculate
+
+        val summaryKeys = listOf(
+            summary1,
+            summary2,
+            summary3
+        )
+
+        val displayNames = listOf(
+            displayName1,
+            displayName2,
+            displayName3
         )
+
+        val methodNames = listOf(
+            methodName1,
+            methodName2,
+            methodName3
+        )
+
+        check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
     }
 
-    val summaryIncFunc1 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num1 > num2): False}\n" +
-            "invokes:\n" +
-            "    Ternary::intFunc2 once\n" +
-            "returns from: {@code return num1 > num2 ? intFunc1() : intFunc2();}\n" +
-            "
" - val summaryIncFunc2 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num1 > num2): True}\n" +
-            "invokes:\n" +
-            "    Ternary::intFunc1 once\n" +
-            "returns from: {@code return num1 > num2 ? intFunc1() : intFunc2();}\n" +
-            "
" @Test fun testIntFunc() { - checkTwoArguments( - Ternary::intFunc, - summaryKeys = listOf( - summaryIncFunc1, - summaryIncFunc2 - ), - displayNames = listOf( - "num1 > num2 : False -> return num1 > num2 ? intFunc1() : intFunc2()", - "num1 > num2 : True -> return num1 > num2 ? intFunc1() : intFunc2()" - ) + val summary1 = "Test executes conditions:\n" + + " (num1 > num2): True\n" + + "invokes:\n" + + " Ternary::intFunc1 once\n" + + "returns from: return num1 > num2 ? intFunc1() : intFunc2();\n" + val summary2 = "Test executes conditions:\n" + + " (num1 > num2): False\n" + + "invokes:\n" + + " Ternary::intFunc2 once\n" + + "returns from: return num1 > num2 ? intFunc1() : intFunc2();\n" + + val methodName1 = "testIntFunc_Num1GreaterThanNum2" + val methodName2 = "testIntFunc_Num1LessOrEqualNum2" + + val displayName1 = "num1 > num2 : True -> return num1 > num2 ? intFunc1() : intFunc2()" + val displayName2 = "num1 > num2 : False -> return num1 > num2 ? intFunc1() : intFunc2()" + + val method = Ternary::intFunc + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2 ) - } - val summaryTernaryInTheMiddle1 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num2 > num3): True}\n" +
-            "calls Ternary::max,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code (val1 >= val2): False}\n" +
-            "    returns from: {@code return val1 >= val2 ? val1 : val2;}"
-    val summaryTernaryInTheMiddle2 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num2 > num3): False}\n" +
-            "calls Ternary::max,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code (val1 >= val2): False}\n" +
-            "    returns from: {@code return val1 >= val2 ? val1 : val2;}"
-    val summaryTernaryInTheMiddle3 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num2 > num3): False}\n" +
-            "calls Ternary::max,\n" +
-            "    there it executes conditions:\n" +
-            "        {@code (val1 >= val2): True}\n" +
-            "    returns from: {@code return val1 >= val2 ? val1 : val2;}"
+        val displayNames = listOf(
+            displayName1,
+            displayName2
+        )
+
+        val methodNames = listOf(
+            methodName1,
+            methodName2
+        )
+
+        check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
+    }
 
     @Test
     fun testTernaryInTheMiddle() {
-        checkThreeArguments(
-            Ternary::ternaryInTheMiddle,
-            summaryKeys = listOf(
-                summaryTernaryInTheMiddle1,
-                summaryTernaryInTheMiddle2,
-                summaryTernaryInTheMiddle3
-            ),
-            displayNames = listOf(
-                "val1 >= val2 : False -> return val1 >= val2 ? val1 : val2",
-                "val2 : False -> return val1 >= val2 ? val1 : val2",
-                "val1 >= val2 : True -> return val1 >= val2 ? val1 : val2"
-            )
+        val summary1 = "Test executes conditions:\n" +
+                "    (num2 > num3): True\n" +
+                "returns from: return max(num1 + 228, num2 > num3 ? num2 + 1 : num3 + 2) + 4;\n"
+        val summary2 = "Test executes conditions:\n" +
+                "    (num2 > num3): False\n" +
+                "returns from: return max(num1 + 228, num2 > num3 ? num2 + 1 : num3 + 2) + 4;\n"
+
+        val methodName1 = "testTernaryInTheMiddle_Num2GreaterThanNum3"
+        val methodName2 = "testTernaryInTheMiddle_Num2LessOrEqualNum3"
+
+        val displayName1 = "num2 > num3 : True -> return max(num1 + 228, num2 > num3 ? num2 + 1 : num3 + 2) + 4"
+        val displayName2 = "num2 > num3 : False -> return max(num1 + 228, num2 > num3 ? num2 + 1 : num3 + 2) + 4"
+
+        val method = Ternary::ternaryInTheMiddle
+        val mockStrategy = MockStrategyApi.NO_MOCKS
+        val coverage = DoNotCalculate
+
+        val summaryKeys = listOf(
+            summary1,
+            summary2
+        )
+
+        val displayNames = listOf(
+            displayName1,
+            displayName2
         )
-    }
 
-    val summaryTwoIfsOneLine1 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num1 > num2): False}\n" +
-            "returns from: {@code return a;}\n" +
-            "
" - val summaryTwoIfsOneLine2 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num1 > num2): True},\n" +
-            "    {@code ((num1 - 10) > 0): False}\n" +
-            "returns from: {@code return a;}\n" +
-            "
" - val summaryTwoIfsOneLine3 = "
\n" +
-            "Test executes conditions:\n" +
-            "    {@code (num1 > num2): True},\n" +
-            "    {@code ((num1 - 10) > 0): True}\n" +
-            "returns from: {@code return a;}\n" +
-            "
" + val methodNames = listOf( + methodName1, + methodName2 + ) + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } @Test fun testTwoIfsOneLine() { - checkTwoArguments( - Ternary::twoIfsOneLine, - summaryKeys = listOf( - summaryTwoIfsOneLine1, - summaryTwoIfsOneLine2, - summaryTwoIfsOneLine3 - ), - displayNames = listOf( - "num1 > num2 : False -> return a", - "(num1 - 10) > 0 : False -> return a", - "(num1 - 10) > 0 : True -> return a" - ) + val summary1 = "Test executes conditions:\n" + + " (num1 > num2): False\n" + + "returns from: return a;\n" + val summary2 = "Test executes conditions:\n" + + " (num1 > num2): True,\n" + + " ((num1 - 10) > 0): False\n" + + "returns from: return a;\n" + val summary3 = "Test executes conditions:\n" + + " (num1 > num2): True,\n" + + " ((num1 - 10) > 0): True\n" + + "returns from: return a;\n" + + val methodName1 = "testTwoIfsOneLine_Num1LessOrEqualNum2" + val methodName2 = "testTwoIfsOneLine_Num1Minus10LessOrEqualZero" + val methodName3 = "testTwoIfsOneLine_Num1Minus10GreaterThanZero" + + val displayName1 = "num1 > num2 : False -> return a" + val displayName2 = "(num1 - 10) > 0 : False -> return a" + val displayName3 = "(num1 - 10) > 0 : True -> return a" + + val method = Ternary::twoIfsOneLine + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + val summaryKeys = listOf( + summary1, + summary2, + summary3 + ) + + val displayNames = listOf( + displayName1, + displayName2, + displayName3 + ) + + val methodNames = listOf( + methodName1, + methodName2, + methodName3 ) + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) } } \ No newline at end of file