1
1
package org.utbot.examples.controlflow
2
2
3
- import org.utbot.framework.plugin.api.DocCodeStmt
4
- import org.utbot.framework.plugin.api.DocPreTagStatement
5
- import org.utbot.framework.plugin.api.DocRegularStmt
6
- import org.utbot.framework.plugin.api.DocStatement
7
3
import org.junit.jupiter.api.Test
8
4
import org.utbot.testcheckers.eq
9
5
import org.utbot.testing.UtValueTestCaseChecker
10
6
import org.utbot.testing.atLeast
11
7
import org.utbot.testing.between
12
8
import org.utbot.testing.ignoreExecutionsNumber
13
9
import org.utbot.testing.isException
14
- import org.utbot.testing.keyContain
15
- import org.utbot.testing.keyMatch
16
10
17
11
internal class CyclesTest : UtValueTestCaseChecker (testClass = Cycles : :class) {
18
12
@Test
@@ -28,40 +22,12 @@ internal class CyclesTest : UtValueTestCaseChecker(testClass = Cycles::class) {
28
22
29
23
@Test
30
24
fun testForCycleFour () {
31
- val cycleSummary = listOf<DocStatement >(
32
- DocPreTagStatement (
33
- listOf (
34
- DocRegularStmt (" Test " ),
35
- DocRegularStmt (" does not iterate " ),
36
- DocCodeStmt (" for(int i = 0; i < x; i++)" ),
37
- DocRegularStmt (" , " ),
38
- DocRegularStmt (" returns from: " ),
39
- DocCodeStmt (" return -1;" ),
40
- DocRegularStmt (" \n " ),
41
- )
42
- )
43
- )
44
25
check(
45
26
Cycles ::forCycleFour,
46
27
eq(3 ),
47
28
{ x, r -> x <= 0 && r == - 1 },
48
29
{ x, r -> x in 1 .. 4 && r == - 1 },
49
- { x, r -> x > 4 && r == 1 },
50
- summaryTextChecks = listOf (
51
- keyContain(DocCodeStmt (" (i > 4): True" )),
52
- keyContain(DocCodeStmt (" (i > 4): False" )),
53
- keyMatch(cycleSummary)
54
- ),
55
- summaryNameChecks = listOf (
56
- keyMatch(" testForCycleFour_IGreaterThan4" ),
57
- keyMatch(" testForCycleFour_ILessOrEqual4" ),
58
- keyMatch(" testForCycleFour_ReturnNegative1" )
59
- ),
60
- summaryDisplayNameChecks = listOf (
61
- keyContain(" i > 4 : True" ),
62
- keyContain(" i > 4 : False" ),
63
- keyContain(" return -1" )
64
- )
30
+ { x, r -> x > 4 && r == 1 }
65
31
)
66
32
}
67
33
@@ -100,101 +66,18 @@ internal class CyclesTest : UtValueTestCaseChecker(testClass = Cycles::class) {
100
66
check(
101
67
Cycles ::callInnerWhile,
102
68
between(1 .. 2 ),
103
- { x, r -> x >= 42 && r == Cycles ().callInnerWhile(x) },
104
- summaryTextChecks = listOf (
105
- keyContain(DocCodeStmt (" return innerWhile(value, 42);" )),
106
- ),
107
- summaryNameChecks = listOf (
108
- keyMatch(" testCallInnerWhile_IterateWhileLoop" )
109
- )
69
+ { x, r -> x >= 42 && r == Cycles ().callInnerWhile(x) }
110
70
)
111
71
}
112
72
113
73
@Test
114
74
fun testInnerLoop () {
115
- val innerLoopSummary1 = arrayOf(
116
- DocRegularStmt (" Test " ),
117
- DocRegularStmt (" calls " ),
118
- DocRegularStmt (" CycleDependedCondition::twoCondition" ),
119
- DocRegularStmt (" ,\n there it " ),
120
- DocRegularStmt (" iterates the loop " ),
121
- DocRegularStmt (" " ),
122
- DocCodeStmt (" for(int i = 0; i < x; i++)" ),
123
- DocRegularStmt (" " ),
124
- DocRegularStmt (" once" ),
125
- DocRegularStmt (" " ),
126
- DocRegularStmt (" . " ),
127
- DocRegularStmt (" \n Test " ),
128
- // DocRegularStmt("afterwards "),
129
- DocRegularStmt (" returns from: " ),
130
- DocCodeStmt (" return 0;" ),
131
- DocRegularStmt (" \n " ),
132
- DocRegularStmt (" \n Test " ),
133
- // DocRegularStmt("afterwards "),
134
- DocRegularStmt (" returns from: " ),
135
- DocCodeStmt (" return cycleDependedCondition.twoCondition(value);" ),
136
- DocRegularStmt (" \n " ),
137
- )
138
- val innerLoopSummary2 = arrayOf(
139
- DocRegularStmt (" Test " ),
140
- DocRegularStmt (" calls " ),
141
- DocRegularStmt (" CycleDependedCondition::twoCondition" ),
142
- DocRegularStmt (" ,\n there it " ),
143
- DocRegularStmt (" iterates the loop " ),
144
- DocRegularStmt (" " ),
145
- DocCodeStmt (" for(int i = 0; i < x; i++)" ),
146
- DocRegularStmt (" " ),
147
- DocRegularStmt (" 4 times" ),
148
- DocRegularStmt (" " ),
149
- DocRegularStmt (" ,\n " ),
150
- DocRegularStmt (" " ),
151
- DocRegularStmt (" inside this loop, the test " ),
152
- DocRegularStmt (" executes conditions:\n " ),
153
- DocRegularStmt (" " ),
154
- DocCodeStmt (" (i > 2): True" ),
155
- DocRegularStmt (" ,\n " ),
156
- DocCodeStmt (" (x == 4): True" ),
157
- DocRegularStmt (" \n returns from: " ),
158
- DocCodeStmt (" return 1;" ),
159
- DocRegularStmt (" \n Test " ),
160
- // DocRegularStmt("afterwards "),
161
- DocRegularStmt (" returns from: " ),
162
- DocCodeStmt (" return cycleDependedCondition.twoCondition(value);" ),
163
- DocRegularStmt (" \n " ),
164
- )
165
- val innerLoopSummary3 = arrayOf(
166
- DocRegularStmt (" Test " ),
167
- DocRegularStmt (" calls " ),
168
- DocRegularStmt (" CycleDependedCondition::twoCondition" ),
169
- DocRegularStmt (" ,\n there it " ),
170
- DocRegularStmt (" iterates the loop " ),
171
- DocCodeStmt (" for(int i = 0; i < x; i++)" ),
172
- DocRegularStmt (" 5 times" ),
173
- DocRegularStmt (" inside this loop, the test " ),
174
- DocRegularStmt (" executes conditions:\n " ),
175
- DocCodeStmt (" (x == 4): False" ),
176
- DocRegularStmt (" \n Test " ),
177
- DocRegularStmt (" returns from: " ),
178
- DocCodeStmt (" return 0;" ),
179
- DocCodeStmt (" return cycleDependedCondition.twoCondition(value);" ),
180
- )
181
75
check(
182
76
Cycles ::innerLoop,
183
77
ignoreExecutionsNumber,
184
78
{ x, r -> x in 1 .. 3 && r == 0 },
185
79
{ x, r -> x == 4 && r == 1 },
186
- { x, r -> x >= 5 && r == 0 },
187
- // TODO JIRA:1442
188
- /* summaryTextChecks = listOf(
189
- keyContain(*innerLoopSummary1),
190
- keyContain(*innerLoopSummary2),
191
- keyContain(*innerLoopSummary3)
192
- ),
193
- summaryNameChecks = listOf(
194
- keyMatch("testInnerLoop_ReturnZero"),
195
- keyMatch("testInnerLoop_XEquals4"),
196
- keyMatch("testInnerLoop_XNotEquals4")
197
- )*/
80
+ { x, r -> x >= 5 && r == 0 }
198
81
)
199
82
}
200
83
0 commit comments