@@ -5,6 +5,7 @@ import examples.SummaryTestCaseGeneratorTest
5
5
import org.junit.jupiter.api.Test
6
6
import org.junit.jupiter.api.extension.ExtendWith
7
7
import org.utbot.examples.controlflow.Switch
8
+ import org.utbot.examples.exceptions.ExceptionExamples
8
9
import org.utbot.framework.plugin.api.MockStrategyApi
9
10
import org.utbot.testing.DoNotCalculate
10
11
@@ -16,19 +17,19 @@ class SummarySwitchTest : SummaryTestCaseGeneratorTest(
16
17
fun testSimpleSwitch () {
17
18
val summary1 = " @utbot.classUnderTest {@link Switch}\n " +
18
19
" @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#simpleSwitch(int)}\n " +
19
- " @utbot.activatesSwitch {@code case 10}\n " +
20
+ " @utbot.activatesSwitch {@code switch(x) case: 10}\n " +
20
21
" @utbot.returnsFrom {@code return 10;}"
21
22
val summary2 = " @utbot.classUnderTest {@link Switch}\n " +
22
23
" @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#simpleSwitch(int)}\n " +
23
- " @utbot.activatesSwitch {@code case default}\n " +
24
+ " @utbot.activatesSwitch {@code switch(x) case: default}\n " +
24
25
" @utbot.returnsFrom {@code return -1;}"
25
26
val summary3 = " @utbot.classUnderTest {@link Switch}\n " +
26
27
" @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#simpleSwitch(int)}\n " +
27
- " @utbot.activatesSwitch {@code case 12}\n " +
28
+ " @utbot.activatesSwitch {@code switch(x) case: 12}\n " +
28
29
" @utbot.returnsFrom {@code return 12;}"
29
30
val summary4 = " @utbot.classUnderTest {@link Switch}\n " +
30
31
" @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#simpleSwitch(int)}\n " +
31
- " @utbot.activatesSwitch {@code case 13}\n " +
32
+ " @utbot.activatesSwitch {@code switch(x) case: 13}\n " +
32
33
" @utbot.returnsFrom {@code return 13;}"
33
34
34
35
val methodName1 = " testSimpleSwitch_Return10"
@@ -37,7 +38,7 @@ class SummarySwitchTest : SummaryTestCaseGeneratorTest(
37
38
val methodName4 = " testSimpleSwitch_Return13"
38
39
39
40
val displayName1 = " switch(x) case: 10 -> return 10"
40
- val displayName2 = " switch(x) case: Default -> return -1"
41
+ val displayName2 = " switch(x) case: default -> return -1"
41
42
val displayName3 = " switch(x) case: 12 -> return 12"
42
43
val displayName4 = " switch(x) case: 13 -> return 13"
43
44
@@ -73,40 +74,39 @@ class SummarySwitchTest : SummaryTestCaseGeneratorTest(
73
74
fun testCharToIntSwitch () {
74
75
val summary1 = " @utbot.classUnderTest {@link Switch}\n " +
75
76
" @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#charToIntSwitch(char)}\n " +
76
- " @utbot.activatesSwitch {@code case 'C'}\n " +
77
+ " @utbot.activatesSwitch {@code switch(c) case: 'C'}\n " +
77
78
" @utbot.returnsFrom {@code return 100;}\n "
78
79
val summary2 = " @utbot.classUnderTest {@link Switch}\n " +
79
80
" @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#charToIntSwitch(char)}\n " +
80
- " @utbot.activatesSwitch {@code case 'V'}\n " +
81
+ " @utbot.activatesSwitch {@code switch(c) case: 'V'}\n " +
81
82
" @utbot.returnsFrom {@code return 5;}\n "
82
83
val summary3 = " @utbot.classUnderTest {@link Switch}\n " +
83
84
" @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#charToIntSwitch(char)}\n " +
84
- " @utbot.activatesSwitch {@code case 'I'}\n " +
85
+ " @utbot.activatesSwitch {@code switch(c) case: 'I'}\n " +
85
86
" @utbot.returnsFrom {@code return 1;}\n "
86
87
val summary4 = " @utbot.classUnderTest {@link Switch}\n " +
87
88
" @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#charToIntSwitch(char)}\n " +
88
- " @utbot.activatesSwitch {@code case 'X'}\n " +
89
+ " @utbot.activatesSwitch {@code switch(c) case: 'X'}\n " +
89
90
" @utbot.returnsFrom {@code return 10;}\n "
90
91
val summary5 = " @utbot.classUnderTest {@link Switch}\n " +
91
92
" @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#charToIntSwitch(char)}\n " +
92
- " @utbot.activatesSwitch {@code case 'M'}\n " +
93
+ " @utbot.activatesSwitch {@code switch(c) case: 'M'}\n " +
93
94
" @utbot.returnsFrom {@code return 1000;}\n "
94
95
val summary6 = " @utbot.classUnderTest {@link Switch}\n " +
95
96
" @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#charToIntSwitch(char)}\n " +
96
- " @utbot.activatesSwitch {@code case 'D'}\n " +
97
+ " @utbot.activatesSwitch {@code switch(c) case: 'D'}\n " +
97
98
" @utbot.returnsFrom {@code return 500;}\n "
98
99
val summary7 = " @utbot.classUnderTest {@link Switch}\n " +
99
100
" @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#charToIntSwitch(char)}\n " +
100
- " @utbot.activatesSwitch {@code case 'L'}\n " +
101
+ " @utbot.activatesSwitch {@code switch(c) case: 'L'}\n " +
101
102
" @utbot.returnsFrom {@code return 50;}\n "
102
103
val summary8 = " @utbot.classUnderTest {@link Switch}\n " +
103
104
" @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#charToIntSwitch(char)}\n " +
104
105
" @utbot.invokes {@link java.lang.StringBuilder#append(java.lang.String)}\n " +
105
106
" @utbot.invokes {@link java.lang.StringBuilder#append(char)}\n " +
106
107
" @utbot.invokes {@link java.lang.StringBuilder#toString()}\n " +
107
- " @utbot.activatesSwitch {@code case default}\n " +
108
- " @utbot.throwsException {@link java.lang.IllegalArgumentException} in: default:\n " +
109
- " throw new IllegalArgumentException(\" Unrecognized symbol: \" + c);\n "
108
+ " @utbot.activatesSwitch {@code switch(c) case: default}\n " +
109
+ " @utbot.throwsException {@link java.lang.IllegalArgumentException} when: switch(c) case: default\n "
110
110
111
111
val methodName1 = " testCharToIntSwitch_Return100"
112
112
val methodName2 = " testCharToIntSwitch_Return5"
@@ -115,7 +115,7 @@ class SummarySwitchTest : SummaryTestCaseGeneratorTest(
115
115
val methodName5 = " testCharToIntSwitch_Return1000"
116
116
val methodName6 = " testCharToIntSwitch_Return500"
117
117
val methodName7 = " testCharToIntSwitch_Return50"
118
- val methodName8 = " testCharToIntSwitch_StringBuilderToString "
118
+ val methodName8 = " testCharToIntSwitch_ThrowIllegalArgumentException "
119
119
120
120
val displayName1 = " switch(c) case: 'C' -> return 100"
121
121
val displayName2 = " switch(c) case: 'V' -> return 5"
@@ -124,7 +124,7 @@ class SummarySwitchTest : SummaryTestCaseGeneratorTest(
124
124
val displayName5 = " switch(c) case: 'M' -> return 1000"
125
125
val displayName6 = " switch(c) case: 'D' -> return 500"
126
126
val displayName7 = " switch(c) case: 'L' -> return 50"
127
- val displayName8 = """ default: throw new IllegalArgumentException("Unrecognized symbol: " + c) -> ThrowIllegalArgumentException"" "
127
+ val displayName8 = " switch( c) case: default -> ThrowIllegalArgumentException"
128
128
129
129
val summaryKeys = listOf (
130
130
summary1,
@@ -165,4 +165,34 @@ class SummarySwitchTest : SummaryTestCaseGeneratorTest(
165
165
166
166
summaryCheck(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
167
167
}
168
- }
168
+
169
+ @Test
170
+ fun testThrowExceptionInSwitchArgument () {
171
+ val summary1 = " @utbot.classUnderTest {@link Switch}\n " +
172
+ " @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#throwExceptionInSwitchArgument()}\n " +
173
+ " @utbot.invokes org.utbot.examples.controlflow.Switch#getChar()\n " +
174
+ " @utbot.throwsException {@link java.lang.RuntimeException} in: switch(getChar())\n "
175
+
176
+ val methodName1 = " testThrowExceptionInSwitchArgument_ThrowRuntimeException"
177
+
178
+ val displayName1 = " switch(getChar()) -> ThrowRuntimeException"
179
+
180
+ val summaryKeys = listOf (
181
+ summary1,
182
+ )
183
+
184
+ val displayNames = listOf (
185
+ displayName1,
186
+ )
187
+
188
+ val methodNames = listOf (
189
+ methodName1,
190
+ )
191
+
192
+ val method = Switch ::throwExceptionInSwitchArgument
193
+ val mockStrategy = MockStrategyApi .NO_MOCKS
194
+ val coverage = DoNotCalculate
195
+
196
+ summaryCheck(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
197
+ }
198
+ }
0 commit comments