@@ -13,7 +13,7 @@ class SummarySwitchTest : SummaryTestCaseGeneratorTest(
1313 Switch : :class
1414) {
1515 @Test
16- fun testDifferentExceptions () {
16+ fun testSimpleSwitch () {
1717 val summary1 = " @utbot.classUnderTest {@link Switch}\n " +
1818 " @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#simpleSwitch(int)}\n " +
1919 " @utbot.activatesSwitch {@code case 10}\n " +
@@ -68,4 +68,101 @@ class SummarySwitchTest : SummaryTestCaseGeneratorTest(
6868
6969 summaryCheck(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
7070 }
71+
72+ @Test
73+ fun testCharToIntSwitch () {
74+ val summary1 = " @utbot.classUnderTest {@link Switch}\n " +
75+ " @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#charToIntSwitch(char)}\n " +
76+ " @utbot.activatesSwitch {@code case 'C'}\n " +
77+ " @utbot.returnsFrom {@code return 100;}\n "
78+ val summary2 = " @utbot.classUnderTest {@link Switch}\n " +
79+ " @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#charToIntSwitch(char)}\n " +
80+ " @utbot.activatesSwitch {@code case 'V'}\n " +
81+ " @utbot.returnsFrom {@code return 5;}\n "
82+ val summary3 = " @utbot.classUnderTest {@link Switch}\n " +
83+ " @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#charToIntSwitch(char)}\n " +
84+ " @utbot.activatesSwitch {@code case 'I'}\n " +
85+ " @utbot.returnsFrom {@code return 1;}\n "
86+ val summary4 = " @utbot.classUnderTest {@link Switch}\n " +
87+ " @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#charToIntSwitch(char)}\n " +
88+ " @utbot.activatesSwitch {@code case 'X'}\n " +
89+ " @utbot.returnsFrom {@code return 10;}\n "
90+ val summary5 = " @utbot.classUnderTest {@link Switch}\n " +
91+ " @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#charToIntSwitch(char)}\n " +
92+ " @utbot.activatesSwitch {@code case 'M'}\n " +
93+ " @utbot.returnsFrom {@code return 1000;}\n "
94+ val summary6 = " @utbot.classUnderTest {@link Switch}\n " +
95+ " @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#charToIntSwitch(char)}\n " +
96+ " @utbot.activatesSwitch {@code case 'D'}\n " +
97+ " @utbot.returnsFrom {@code return 500;}\n "
98+ val summary7 = " @utbot.classUnderTest {@link Switch}\n " +
99+ " @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#charToIntSwitch(char)}\n " +
100+ " @utbot.activatesSwitch {@code case 'L'}\n " +
101+ " @utbot.returnsFrom {@code return 50;}\n "
102+ val summary8 = " @utbot.classUnderTest {@link Switch}\n " +
103+ " @utbot.methodUnderTest {@link org.utbot.examples.controlflow.Switch#charToIntSwitch(char)}\n " +
104+ " @utbot.invokes {@link java.lang.StringBuilder#append(java.lang.String)}\n " +
105+ " @utbot.invokes {@link java.lang.StringBuilder#append(char)}\n " +
106+ " @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 "
110+
111+ val methodName1 = " testCharToIntSwitch_Return100"
112+ val methodName2 = " testCharToIntSwitch_Return5"
113+ val methodName3 = " testCharToIntSwitch_Return1"
114+ val methodName4 = " testCharToIntSwitch_Return10"
115+ val methodName5 = " testCharToIntSwitch_Return1000"
116+ val methodName6 = " testCharToIntSwitch_Return500"
117+ val methodName7 = " testCharToIntSwitch_Return50"
118+ val methodName8 = " testCharToIntSwitch_StringBuilderToString"
119+
120+ val displayName1 = " switch(c) case: 'C' -> return 100"
121+ val displayName2 = " switch(c) case: 'V' -> return 5"
122+ val displayName3 = " switch(c) case: 'I' -> return 1"
123+ val displayName4 = " switch(c) case: 'X' -> return 10"
124+ val displayName5 = " switch(c) case: 'M' -> return 1000"
125+ val displayName6 = " switch(c) case: 'D' -> return 500"
126+ val displayName7 = " switch(c) case: 'L' -> return 50"
127+ val displayName8 = """ default: throw new IllegalArgumentException("Unrecognized symbol: " + c) -> ThrowIllegalArgumentException"""
128+
129+ val summaryKeys = listOf (
130+ summary1,
131+ summary2,
132+ summary3,
133+ summary4,
134+ summary5,
135+ summary6,
136+ summary7,
137+ summary8,
138+ )
139+
140+ val displayNames = listOf (
141+ displayName1,
142+ displayName2,
143+ displayName3,
144+ displayName4,
145+ displayName5,
146+ displayName6,
147+ displayName7,
148+ displayName8,
149+ )
150+
151+ val methodNames = listOf (
152+ methodName1,
153+ methodName2,
154+ methodName3,
155+ methodName4,
156+ methodName5,
157+ methodName6,
158+ methodName7,
159+ methodName8,
160+ )
161+
162+ val method = Switch ::charToIntSwitch
163+ val mockStrategy = MockStrategyApi .NO_MOCKS
164+ val coverage = DoNotCalculate
165+
166+ summaryCheck(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames)
167+ }
71168}
0 commit comments