Skip to content

Commit 1728ec0

Browse files
authored
Removed unformatted symbols from code descriptions (#318)
1 parent ab5b875 commit 1728ec0

File tree

3 files changed

+138
-1
lines changed

3 files changed

+138
-1
lines changed

utbot-summary-tests/src/test/kotlin/examples/SummaryTestCaseGeneratorTest.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ open class SummaryTestCaseGeneratorTest(
9999
val utMethod = UtMethod.from(method)
100100
val testCase = executionsModel(utMethod, mockStrategy)
101101
testCase.summarize(searchDirectory)
102+
102103
testCase.executions.checkMatchersWithTextSummary(summaryKeys)
103104
testCase.executions.checkMatchersWithMethodNames(methodNames)
104105
testCase.executions.checkMatchersWithDisplayNames(displayNames)

utbot-summary-tests/src/test/kotlin/math/SummaryOfMath.kt

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,140 @@ class SummaryOfMath : SummaryTestCaseGeneratorTest(
7676

7777
check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
7878
}
79+
80+
@Test
81+
fun testOfDoubles() {
82+
val summary1 = "Test calls StatsAccumulator::addAll,\n" +
83+
" there it triggers recursion of addAll once, \n" +
84+
"Test throws NullPointerException in: acummulator.addAll(values);\n"
85+
val summary2 = "Test calls StatsAccumulator::addAll,\n" +
86+
" there it does not iterate for(double value: values), \n" +
87+
"Test next calls StatsAccumulator::snapshot,\n" +
88+
" there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n" +
89+
" \n" +
90+
"Test later returns from: return acummulator.snapshot();\n"
91+
val summary3 = "Test calls StatsAccumulator::addAll,\n" +
92+
" there it iterates the loop for(double value: values) twice,\n" +
93+
" inside this loop, the test calls StatsAccumulator::add,\n" +
94+
" there it executes conditions:\n" +
95+
" (count == 0): True\n" +
96+
" (!isFinite(value)): True\n" +
97+
" calls StatsAccumulator::add,\n" +
98+
" there it executes conditions:\n" +
99+
" (count == 0): False\n" +
100+
" (isFinite(value) && isFinite(mean)): True\n" +
101+
" (if (isFinite(value) && isFinite(mean)) {\n" +
102+
" double delta = value - mean;\n" +
103+
" mean += delta / count;\n" +
104+
" sumOfSquaresOfDeltas += delta * (value - mean);\n" +
105+
"} else {\n" +
106+
" mean = calculateNewMeanNonFinite(mean, value);\n" +
107+
" sumOfSquaresOfDeltas = NaN;\n" +
108+
"}): False\n" +
109+
"Test afterwards calls StatsAccumulator::snapshot,\n" +
110+
" there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n" +
111+
" \n" +
112+
"Test afterwards returns from: return acummulator.snapshot();\n"
113+
val summary4 = "Test calls StatsAccumulator::addAll,\n" +
114+
" there it iterates the loop for(double value: values) twice,\n" +
115+
" inside this loop, the test calls StatsAccumulator::add,\n" +
116+
" there it executes conditions:\n" +
117+
" (!isFinite(value)): False\n" +
118+
"Test next calls StatsAccumulator::snapshot,\n" +
119+
" there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n" +
120+
" \n" +
121+
"Test then returns from: return acummulator.snapshot();\n"
122+
val summary5 = "Test calls StatsAccumulator::addAll,\n" +
123+
" there it iterates the loop for(double value: values) twice,\n" +
124+
" inside this loop, the test calls StatsAccumulator::add,\n" +
125+
" there it executes conditions:\n" +
126+
" (count == 0): True\n" +
127+
" (!isFinite(value)): False\n" +
128+
" calls StatsAccumulator::add,\n" +
129+
" there it executes conditions:\n" +
130+
" (count == 0): False\n" +
131+
" (isFinite(value) && isFinite(mean)): True\n" +
132+
" (if (isFinite(value) && isFinite(mean)) {\n" +
133+
" double delta = value - mean;\n" +
134+
" mean += delta / count;\n" +
135+
" sumOfSquaresOfDeltas += delta * (value - mean);\n" +
136+
"} else {\n" +
137+
" mean = calculateNewMeanNonFinite(mean, value);\n" +
138+
" sumOfSquaresOfDeltas = NaN;\n" +
139+
"}): True\n" +
140+
"Test later calls StatsAccumulator::snapshot,\n" +
141+
" there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n" +
142+
" \n" +
143+
"Test then returns from: return acummulator.snapshot();\n"
144+
val summary6 = "Test calls StatsAccumulator::addAll,\n" +
145+
" there it iterates the loop for(double value: values) twice,\n" +
146+
" inside this loop, the test calls StatsAccumulator::add,\n" +
147+
" there it executes conditions:\n" +
148+
" (!isFinite(value)): True\n" +
149+
"Test afterwards calls StatsAccumulator::snapshot,\n" +
150+
" there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n" +
151+
" \n" +
152+
"Test then returns from: return acummulator.snapshot();\n"
153+
val summary7 = "Test calls StatsAccumulator::addAll,\n" +
154+
" there it iterates the loop for(double value: values) twice,\n" +
155+
" inside this loop, the test calls StatsAccumulator::add,\n" +
156+
" there it executes conditions:\n" +
157+
" (!isFinite(value)): True\n" +
158+
"Test later calls StatsAccumulator::snapshot,\n" +
159+
" there it returns from: return new Stats(count, mean, sumOfSquaresOfDeltas, min, max);\n" +
160+
" \n" +
161+
"Test further returns from: return acummulator.snapshot();\n"
162+
163+
val methodName1 = "testOfDoubles_StatsAccumulatorAddAll"
164+
val methodName2 = "testOfDoubles_snapshot"
165+
val methodName3 = "testOfDoubles_IsFiniteAndIsFinite"
166+
val methodName4 = "testOfDoubles_IsFinite"
167+
val methodName5 = "testOfDoubles_IsFiniteAndIsFinite_1"
168+
val methodName6 = "testOfDoubles_NotIsFinite"
169+
val methodName7 = "testOfDoubles_NotIsFinite_1"
170+
171+
val displayName1 = "acummulator.addAll(values) : True -> ThrowNullPointerException"
172+
val displayName2 = "snapshot -> return new Stats(count, mean, sumOfSquaresOfDeltas, min, max)"
173+
val displayName3 = "!isFinite(value) : True -> StatsAccumulatorCalculateNewMeanNonFinite"
174+
val displayName4 = "add -> !isFinite(value) : False"
175+
val displayName5 = "!isFinite(value) : False -> isFinite(value) && isFinite(mean)"
176+
val displayName6 = "add -> !isFinite(value) : True"
177+
val displayName7 = "add -> !isFinite(value) : True"
178+
179+
val method = Stats::ofDoubles
180+
val mockStrategy = MockStrategyApi.NO_MOCKS
181+
val coverage = DoNotCalculate
182+
183+
val summaryKeys = listOf(
184+
summary1,
185+
summary2,
186+
summary3,
187+
summary4,
188+
summary5,
189+
summary6,
190+
summary7
191+
)
192+
193+
val displayNames = listOf(
194+
displayName1,
195+
displayName2,
196+
displayName3,
197+
displayName4,
198+
displayName5,
199+
displayName6,
200+
displayName7
201+
)
202+
203+
val methodNames = listOf(
204+
methodName1,
205+
methodName2,
206+
methodName3,
207+
methodName4,
208+
methodName5,
209+
methodName6,
210+
methodName7
211+
)
212+
213+
check(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
214+
}
79215
}

utbot-summary/src/main/kotlin/org/utbot/summary/comment/SimpleSentenceBlock.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ data class SquashedStmtTexts(
433433
for (i in 0 until stmtTexts.size) {
434434
val stmtText = stmtTexts[i]
435435
if ((tab + stmtText.prefix).isNotEmpty()) stmts += DocRegularStmt(tab + stmtText.prefix)
436-
stmts += DocCodeStmt(stmtText.description)
436+
stmts += DocCodeStmt(stmtText.description.replace(CARRIAGE_RETURN, ""))
437437

438438
if (i != stmtTexts.lastIndex) {
439439
if (separation.isNotEmpty()) stmts += DocRegularStmt(separation)

0 commit comments

Comments
 (0)