Skip to content

Commit 47ca38f

Browse files
committed
Correct tests
1 parent 132cecd commit 47ca38f

File tree

1 file changed

+33
-32
lines changed

1 file changed

+33
-32
lines changed

utbot-framework-test/src/test/kotlin/org/utbot/examples/math/OverflowAsErrorTest.kt

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package org.utbot.examples.math
22

33
import org.junit.jupiter.api.Disabled
44
import org.junit.jupiter.api.Test
5+
import org.utbot.engine.OverflowDetectionError
56
import org.utbot.examples.algorithms.Sort
67
import org.utbot.framework.plugin.api.CodegenLanguage
78
import org.utbot.testcheckers.eq
@@ -31,8 +32,8 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
3132
checkWithException(
3233
OverflowExamples::intOverflow,
3334
eq(5),
34-
{ x, _, r -> x * x * x <= 0 && x > 0 && r.isException<ArithmeticException>() }, // through overflow
35-
{ x, _, r -> x * x * x <= 0 && x > 0 && r.isException<ArithmeticException>() }, // through overflow (2nd '*')
35+
{ x, _, r -> x * x * x <= 0 && x > 0 && r.isException<OverflowDetectionError>() }, // through overflow
36+
{ x, _, r -> x * x * x <= 0 && x > 0 && r.isException<OverflowDetectionError>() }, // through overflow (2nd '*')
3637
{ x, _, r -> x * x * x >= 0 && x >= 0 && r.getOrNull() == 0 },
3738
{ x, y, r -> x * x * x > 0 && x > 0 && y == 10 && r.getOrNull() == 1 },
3839
{ x, y, r -> x * x * x > 0 && x > 0 && y != 10 && r.getOrNull() == 0 },
@@ -47,11 +48,11 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
4748
checkWithException(
4849
OverflowExamples::byteAddOverflow,
4950
eq(2),
50-
{ _, _, r -> !r.isException<ArithmeticException>() },
51+
{ _, _, r -> !r.isException<OverflowDetectionError>() },
5152
{ x, y, r ->
5253
val negOverflow = ((x + y).toByte() >= 0 && x < 0 && y < 0)
5354
val posOverflow = ((x + y).toByte() <= 0 && x > 0 && y > 0)
54-
(negOverflow || posOverflow) && r.isException<ArithmeticException>()
55+
(negOverflow || posOverflow) && r.isException<OverflowDetectionError>()
5556
}, // through overflow
5657
)
5758
}
@@ -63,11 +64,11 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
6364
checkWithException(
6465
OverflowExamples::byteSubOverflow,
6566
eq(2),
66-
{ _, _, r -> !r.isException<ArithmeticException>() },
67+
{ _, _, r -> !r.isException<OverflowDetectionError>() },
6768
{ x, y, r ->
6869
val negOverflow = ((x - y).toByte() >= 0 && x < 0 && y > 0)
6970
val posOverflow = ((x - y).toByte() <= 0 && x > 0 && y < 0)
70-
(negOverflow || posOverflow) && r.isException<ArithmeticException>()
71+
(negOverflow || posOverflow) && r.isException<OverflowDetectionError>()
7172
}, // through overflow
7273
)
7374
}
@@ -79,8 +80,8 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
7980
checkWithException(
8081
OverflowExamples::byteMulOverflow,
8182
eq(2),
82-
{ _, _, r -> !r.isException<ArithmeticException>() },
83-
{ _, _, r -> r.isException<ArithmeticException>() }, // through overflow
83+
{ _, _, r -> !r.isException<OverflowDetectionError>() },
84+
{ _, _, r -> r.isException<OverflowDetectionError>() }, // through overflow
8485
)
8586
}
8687
}
@@ -91,11 +92,11 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
9192
checkWithException(
9293
OverflowExamples::shortAddOverflow,
9394
eq(2),
94-
{ _, _, r -> !r.isException<ArithmeticException>() },
95+
{ _, _, r -> !r.isException<OverflowDetectionError>() },
9596
{ x, y, r ->
9697
val negOverflow = ((x + y).toShort() >= 0 && x < 0 && y < 0)
9798
val posOverflow = ((x + y).toShort() <= 0 && x > 0 && y > 0)
98-
(negOverflow || posOverflow) && r.isException<ArithmeticException>()
99+
(negOverflow || posOverflow) && r.isException<OverflowDetectionError>()
99100
}, // through overflow
100101
)
101102
}
@@ -107,11 +108,11 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
107108
checkWithException(
108109
OverflowExamples::shortSubOverflow,
109110
eq(2),
110-
{ _, _, r -> !r.isException<ArithmeticException>() },
111+
{ _, _, r -> !r.isException<OverflowDetectionError>() },
111112
{ x, y, r ->
112113
val negOverflow = ((x - y).toShort() >= 0 && x < 0 && y > 0)
113114
val posOverflow = ((x - y).toShort() <= 0 && x > 0 && y < 0)
114-
(negOverflow || posOverflow) && r.isException<ArithmeticException>()
115+
(negOverflow || posOverflow) && r.isException<OverflowDetectionError>()
115116
}, // through overflow
116117
)
117118
}
@@ -123,8 +124,8 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
123124
checkWithException(
124125
OverflowExamples::shortMulOverflow,
125126
eq(2),
126-
{ _, _, r -> !r.isException<ArithmeticException>() },
127-
{ _, _, r -> r.isException<ArithmeticException>() }, // through overflow
127+
{ _, _, r -> !r.isException<OverflowDetectionError>() },
128+
{ _, _, r -> r.isException<OverflowDetectionError>() }, // through overflow
128129
)
129130
}
130131
}
@@ -135,11 +136,11 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
135136
checkWithException(
136137
OverflowExamples::intAddOverflow,
137138
eq(2),
138-
{ _, _, r -> !r.isException<ArithmeticException>() },
139+
{ _, _, r -> !r.isException<OverflowDetectionError>() },
139140
{ x, y, r ->
140141
val negOverflow = ((x + y) >= 0 && x < 0 && y < 0)
141142
val posOverflow = ((x + y) <= 0 && x > 0 && y > 0)
142-
(negOverflow || posOverflow) && r.isException<ArithmeticException>()
143+
(negOverflow || posOverflow) && r.isException<OverflowDetectionError>()
143144
}, // through overflow
144145
)
145146
}
@@ -151,11 +152,11 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
151152
checkWithException(
152153
OverflowExamples::intSubOverflow,
153154
eq(2),
154-
{ _, _, r -> !r.isException<ArithmeticException>() },
155+
{ _, _, r -> !r.isException<OverflowDetectionError>() },
155156
{ x, y, r ->
156157
val negOverflow = ((x - y) >= 0 && x < 0 && y > 0)
157158
val posOverflow = ((x - y) <= 0 && x > 0 && y < 0)
158-
(negOverflow || posOverflow) && r.isException<ArithmeticException>()
159+
(negOverflow || posOverflow) && r.isException<OverflowDetectionError>()
159160
}, // through overflow
160161
)
161162
}
@@ -171,8 +172,8 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
171172
checkWithException(
172173
OverflowExamples::intMulOverflow,
173174
eq(2),
174-
{ _, _, r -> !r.isException<ArithmeticException>() },
175-
{ _, _, r -> r.isException<ArithmeticException>() }, // through overflow
175+
{ _, _, r -> !r.isException<OverflowDetectionError>() },
176+
{ _, _, r -> r.isException<OverflowDetectionError>() }, // through overflow
176177
)
177178
}
178179
}
@@ -184,11 +185,11 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
184185
checkWithException(
185186
OverflowExamples::longAddOverflow,
186187
eq(2),
187-
{ _, _, r -> !r.isException<ArithmeticException>() },
188+
{ _, _, r -> !r.isException<OverflowDetectionError>() },
188189
{ x, y, r ->
189190
val negOverflow = ((x + y) >= 0 && x < 0 && y < 0)
190191
val posOverflow = ((x + y) <= 0 && x > 0 && y > 0)
191-
(negOverflow || posOverflow) && r.isException<ArithmeticException>()
192+
(negOverflow || posOverflow) && r.isException<OverflowDetectionError>()
192193
}, // through overflow
193194
)
194195
}
@@ -200,11 +201,11 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
200201
checkWithException(
201202
OverflowExamples::longSubOverflow,
202203
eq(2),
203-
{ _, _, r -> !r.isException<ArithmeticException>() },
204+
{ _, _, r -> !r.isException<OverflowDetectionError>() },
204205
{ x, y, r ->
205206
val negOverflow = ((x - y) >= 0 && x < 0 && y > 0)
206207
val posOverflow = ((x - y) <= 0 && x > 0 && y < 0)
207-
(negOverflow || posOverflow) && r.isException<ArithmeticException>()
208+
(negOverflow || posOverflow) && r.isException<OverflowDetectionError>()
208209
}, // through overflow
209210
)
210211
}
@@ -221,8 +222,8 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
221222
checkWithException(
222223
OverflowExamples::longMulOverflow,
223224
eq(2),
224-
{ _, _, r -> !r.isException<ArithmeticException>() },
225-
{ _, _, r -> r.isException<ArithmeticException>() }, // through overflow
225+
{ _, _, r -> !r.isException<OverflowDetectionError>() },
226+
{ _, _, r -> r.isException<OverflowDetectionError>() }, // through overflow
226227
)
227228
}
228229
}
@@ -234,8 +235,8 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
234235
checkWithException(
235236
OverflowExamples::incOverflow,
236237
eq(2),
237-
{ _, r -> !r.isException<ArithmeticException>() },
238-
{ _, r -> r.isException<ArithmeticException>() }, // through overflow
238+
{ _, r -> !r.isException<OverflowDetectionError>() },
239+
{ _, r -> r.isException<OverflowDetectionError>() }, // through overflow
239240
)
240241
}
241242
}
@@ -251,8 +252,8 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
251252
// Can't use abs(x) below, because abs(Int.MIN_VALUE) == Int.MIN_VALUE.
252253
// (Int.MAX_VALUE shr 16) is the border of square overflow and cube overflow.
253254
// Int.MAX_VALUE.toDouble().pow(1/3.toDouble())
254-
{ x, r -> (x > -sqrtIntMax && x < sqrtIntMax) && r.isException<ArithmeticException>() }, // through overflow
255-
{ x, r -> (x <= -sqrtIntMax || x >= sqrtIntMax) && r.isException<ArithmeticException>() }, // through overflow
255+
{ x, r -> (x > -sqrtIntMax && x < sqrtIntMax) && r.isException<OverflowDetectionError>() }, // through overflow
256+
{ x, r -> (x <= -sqrtIntMax || x >= sqrtIntMax) && r.isException<OverflowDetectionError>() }, // through overflow
256257
)
257258
}
258259
}
@@ -265,8 +266,8 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
265266
checkWithException(
266267
Sort::quickSort,
267268
ignoreExecutionsNumber,
268-
{ _, _, _, r -> !r.isException<ArithmeticException>() },
269-
{ _, _, _, r -> r.isException<ArithmeticException>() }, // through overflow
269+
{ _, _, _, r -> !r.isException<OverflowDetectionError>() },
270+
{ _, _, _, r -> r.isException<OverflowDetectionError>() }, // through overflow
270271
)
271272
}
272273
}

0 commit comments

Comments
 (0)