From 80f061e3bf1ced4a75e291c1c31f222426b5e6bd Mon Sep 17 00:00:00 2001 From: amandelpie Date: Mon, 27 Jun 2022 14:44:21 +0300 Subject: [PATCH] Removed unformatted symbols from code descriptions --- .../examples/SummaryTestCaseGeneratorTest.kt | 1 + .../src/test/kotlin/math/SummaryOfMath.kt | 136 ++++++++++++++++++ .../summary/comment/SimpleSentenceBlock.kt | 2 +- 3 files changed, 138 insertions(+), 1 deletion(-) diff --git a/utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt b/utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt index 443bee938e..c83195eb5e 100644 --- a/utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt +++ b/utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt @@ -101,6 +101,7 @@ open class SummaryTestCaseGeneratorTest( val utMethod = UtMethod.from(method) val testCase = executionsModel(utMethod, mockStrategy) testCase.summarize(searchDirectory) + testCase.executions.checkMatchersWithTextSummary(summaryKeys) testCase.executions.checkMatchersWithMethodNames(methodNames) testCase.executions.checkMatchersWithDisplayNames(displayNames) diff --git a/utbot-summary-tests/src/test/kotlin/math/SummaryOfMath.kt b/utbot-summary-tests/src/test/kotlin/math/SummaryOfMath.kt index 22260a231c..322cf5ff4f 100644 --- a/utbot-summary-tests/src/test/kotlin/math/SummaryOfMath.kt +++ b/utbot-summary-tests/src/test/kotlin/math/SummaryOfMath.kt @@ -76,4 +76,140 @@ class SummaryOfMath : SummaryTestCaseGeneratorTest( check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) } + + @Test + fun testOfDoubles() { + val summary1 = "Test calls StatsAccumulator::addAll,\n" + + " there it triggers recursion of addAll once, \n" + + "Test throws NullPointerException in: acummulator.addAll(values);\n" + val summary2 = "Test calls StatsAccumulator::addAll,\n" + + " there it does not iterate for(double value: values), \n" + + "Test next calls StatsAccumulator::snapshot,\n" + + " there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n" + + " \n" + + "Test later returns from: return acummulator.snapshot();\n" + val summary3 = "Test calls StatsAccumulator::addAll,\n" + + " there it iterates the loop for(double value: values) twice,\n" + + " inside this loop, the test calls StatsAccumulator::add,\n" + + " there it executes conditions:\n" + + " (count == 0): True\n" + + " (!isFinite(value)): True\n" + + " calls StatsAccumulator::add,\n" + + " there it executes conditions:\n" + + " (count == 0): False\n" + + " (isFinite(value) && isFinite(mean)): True\n" + + " (if (isFinite(value) && isFinite(mean)) {\n" + + " double delta = value - mean;\n" + + " mean += delta / count;\n" + + " sumOfSquaresOfDeltas += delta * (value - mean);\n" + + "} else {\n" + + " mean = calculateNewMeanNonFinite(mean, value);\n" + + " sumOfSquaresOfDeltas = NaN;\n" + + "}): False\n" + + "Test afterwards calls StatsAccumulator::snapshot,\n" + + " there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n" + + " \n" + + "Test afterwards returns from: return acummulator.snapshot();\n" + val summary4 = "Test calls StatsAccumulator::addAll,\n" + + " there it iterates the loop for(double value: values) twice,\n" + + " inside this loop, the test calls StatsAccumulator::add,\n" + + " there it executes conditions:\n" + + " (!isFinite(value)): False\n" + + "Test next calls StatsAccumulator::snapshot,\n" + + " there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n" + + " \n" + + "Test then returns from: return acummulator.snapshot();\n" + val summary5 = "Test calls StatsAccumulator::addAll,\n" + + " there it iterates the loop for(double value: values) twice,\n" + + " inside this loop, the test calls StatsAccumulator::add,\n" + + " there it executes conditions:\n" + + " (count == 0): True\n" + + " (!isFinite(value)): False\n" + + " calls StatsAccumulator::add,\n" + + " there it executes conditions:\n" + + " (count == 0): False\n" + + " (isFinite(value) && isFinite(mean)): True\n" + + " (if (isFinite(value) && isFinite(mean)) {\n" + + " double delta = value - mean;\n" + + " mean += delta / count;\n" + + " sumOfSquaresOfDeltas += delta * (value - mean);\n" + + "} else {\n" + + " mean = calculateNewMeanNonFinite(mean, value);\n" + + " sumOfSquaresOfDeltas = NaN;\n" + + "}): True\n" + + "Test later calls StatsAccumulator::snapshot,\n" + + " there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n" + + " \n" + + "Test then returns from: return acummulator.snapshot();\n" + val summary6 = "Test calls StatsAccumulator::addAll,\n" + + " there it iterates the loop for(double value: values) twice,\n" + + " inside this loop, the test calls StatsAccumulator::add,\n" + + " there it executes conditions:\n" + + " (!isFinite(value)): True\n" + + "Test afterwards calls StatsAccumulator::snapshot,\n" + + " there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n" + + " \n" + + "Test then returns from: return acummulator.snapshot();\n" + val summary7 = "Test calls StatsAccumulator::addAll,\n" + + " there it iterates the loop for(double value: values) twice,\n" + + " inside this loop, the test calls StatsAccumulator::add,\n" + + " there it executes conditions:\n" + + " (!isFinite(value)): True\n" + + "Test later calls StatsAccumulator::snapshot,\n" + + " there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n" + + " \n" + + "Test further returns from: return acummulator.snapshot();\n" + + val methodName1 = "testOfDoubles_StatsAccumulatorAddAll" + val methodName2 = "testOfDoubles_snapshot" + val methodName3 = "testOfDoubles_IsFiniteAndIsFinite" + val methodName4 = "testOfDoubles_IsFinite" + val methodName5 = "testOfDoubles_IsFiniteAndIsFinite_1" + val methodName6 = "testOfDoubles_NotIsFinite" + val methodName7 = "testOfDoubles_NotIsFinite_1" + + val displayName1 = "acummulator.addAll(values) : True -> ThrowNullPointerException" + val displayName2 = "snapshot -> return new Stats(count, mean, sumOfSquaresOfDeltas, min, max)" + val displayName3 = "!isFinite(value) : True -> StatsAccumulatorCalculateNewMeanNonFinite" + val displayName4 = "add -> !isFinite(value) : False" + val displayName5 = "!isFinite(value) : False -> isFinite(value) && isFinite(mean)" + val displayName6 = "add -> !isFinite(value) : True" + val displayName7 = "add -> !isFinite(value) : True" + + val method = Stats::ofDoubles + val mockStrategy = MockStrategyApi.NO_MOCKS + val coverage = DoNotCalculate + + 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 + ) + + check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) + } } \ No newline at end of file diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/SimpleSentenceBlock.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/SimpleSentenceBlock.kt index 2b0129a264..0caa0eaf42 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/comment/SimpleSentenceBlock.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/comment/SimpleSentenceBlock.kt @@ -433,7 +433,7 @@ data class SquashedStmtTexts( for (i in 0 until stmtTexts.size) { val stmtText = stmtTexts[i] if ((tab + stmtText.prefix).isNotEmpty()) stmts += DocRegularStmt(tab + stmtText.prefix) - stmts += DocCodeStmt(stmtText.description) + stmts += DocCodeStmt(stmtText.description.replace(CARRIAGE_RETURN, "")) if (i != stmtTexts.lastIndex) { if (separation.isNotEmpty()) stmts += DocRegularStmt(separation)