@@ -2,6 +2,7 @@ package org.utbot.examples.math
2
2
3
3
import org.junit.jupiter.api.Disabled
4
4
import org.junit.jupiter.api.Test
5
+ import org.utbot.engine.OverflowDetectionError
5
6
import org.utbot.examples.algorithms.Sort
6
7
import org.utbot.framework.plugin.api.CodegenLanguage
7
8
import org.utbot.testcheckers.eq
@@ -31,8 +32,8 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
31
32
checkWithException(
32
33
OverflowExamples ::intOverflow,
33
34
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 '*')
36
37
{ x, _, r -> x * x * x >= 0 && x >= 0 && r.getOrNull() == 0 },
37
38
{ x, y, r -> x * x * x > 0 && x > 0 && y == 10 && r.getOrNull() == 1 },
38
39
{ x, y, r -> x * x * x > 0 && x > 0 && y != 10 && r.getOrNull() == 0 },
@@ -47,11 +48,11 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
47
48
checkWithException(
48
49
OverflowExamples ::byteAddOverflow,
49
50
eq(2 ),
50
- { _, _, r -> ! r.isException<ArithmeticException >() },
51
+ { _, _, r -> ! r.isException<OverflowDetectionError >() },
51
52
{ x, y, r ->
52
53
val negOverflow = ((x + y).toByte() >= 0 && x < 0 && y < 0 )
53
54
val posOverflow = ((x + y).toByte() <= 0 && x > 0 && y > 0 )
54
- (negOverflow || posOverflow) && r.isException<ArithmeticException >()
55
+ (negOverflow || posOverflow) && r.isException<OverflowDetectionError >()
55
56
}, // through overflow
56
57
)
57
58
}
@@ -63,11 +64,11 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
63
64
checkWithException(
64
65
OverflowExamples ::byteSubOverflow,
65
66
eq(2 ),
66
- { _, _, r -> ! r.isException<ArithmeticException >() },
67
+ { _, _, r -> ! r.isException<OverflowDetectionError >() },
67
68
{ x, y, r ->
68
69
val negOverflow = ((x - y).toByte() >= 0 && x < 0 && y > 0 )
69
70
val posOverflow = ((x - y).toByte() <= 0 && x > 0 && y < 0 )
70
- (negOverflow || posOverflow) && r.isException<ArithmeticException >()
71
+ (negOverflow || posOverflow) && r.isException<OverflowDetectionError >()
71
72
}, // through overflow
72
73
)
73
74
}
@@ -79,8 +80,8 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
79
80
checkWithException(
80
81
OverflowExamples ::byteMulOverflow,
81
82
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
84
85
)
85
86
}
86
87
}
@@ -91,11 +92,11 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
91
92
checkWithException(
92
93
OverflowExamples ::shortAddOverflow,
93
94
eq(2 ),
94
- { _, _, r -> ! r.isException<ArithmeticException >() },
95
+ { _, _, r -> ! r.isException<OverflowDetectionError >() },
95
96
{ x, y, r ->
96
97
val negOverflow = ((x + y).toShort() >= 0 && x < 0 && y < 0 )
97
98
val posOverflow = ((x + y).toShort() <= 0 && x > 0 && y > 0 )
98
- (negOverflow || posOverflow) && r.isException<ArithmeticException >()
99
+ (negOverflow || posOverflow) && r.isException<OverflowDetectionError >()
99
100
}, // through overflow
100
101
)
101
102
}
@@ -107,11 +108,11 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
107
108
checkWithException(
108
109
OverflowExamples ::shortSubOverflow,
109
110
eq(2 ),
110
- { _, _, r -> ! r.isException<ArithmeticException >() },
111
+ { _, _, r -> ! r.isException<OverflowDetectionError >() },
111
112
{ x, y, r ->
112
113
val negOverflow = ((x - y).toShort() >= 0 && x < 0 && y > 0 )
113
114
val posOverflow = ((x - y).toShort() <= 0 && x > 0 && y < 0 )
114
- (negOverflow || posOverflow) && r.isException<ArithmeticException >()
115
+ (negOverflow || posOverflow) && r.isException<OverflowDetectionError >()
115
116
}, // through overflow
116
117
)
117
118
}
@@ -123,8 +124,8 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
123
124
checkWithException(
124
125
OverflowExamples ::shortMulOverflow,
125
126
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
128
129
)
129
130
}
130
131
}
@@ -135,11 +136,11 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
135
136
checkWithException(
136
137
OverflowExamples ::intAddOverflow,
137
138
eq(2 ),
138
- { _, _, r -> ! r.isException<ArithmeticException >() },
139
+ { _, _, r -> ! r.isException<OverflowDetectionError >() },
139
140
{ x, y, r ->
140
141
val negOverflow = ((x + y) >= 0 && x < 0 && y < 0 )
141
142
val posOverflow = ((x + y) <= 0 && x > 0 && y > 0 )
142
- (negOverflow || posOverflow) && r.isException<ArithmeticException >()
143
+ (negOverflow || posOverflow) && r.isException<OverflowDetectionError >()
143
144
}, // through overflow
144
145
)
145
146
}
@@ -151,11 +152,11 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
151
152
checkWithException(
152
153
OverflowExamples ::intSubOverflow,
153
154
eq(2 ),
154
- { _, _, r -> ! r.isException<ArithmeticException >() },
155
+ { _, _, r -> ! r.isException<OverflowDetectionError >() },
155
156
{ x, y, r ->
156
157
val negOverflow = ((x - y) >= 0 && x < 0 && y > 0 )
157
158
val posOverflow = ((x - y) <= 0 && x > 0 && y < 0 )
158
- (negOverflow || posOverflow) && r.isException<ArithmeticException >()
159
+ (negOverflow || posOverflow) && r.isException<OverflowDetectionError >()
159
160
}, // through overflow
160
161
)
161
162
}
@@ -171,8 +172,8 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
171
172
checkWithException(
172
173
OverflowExamples ::intMulOverflow,
173
174
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
176
177
)
177
178
}
178
179
}
@@ -184,11 +185,11 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
184
185
checkWithException(
185
186
OverflowExamples ::longAddOverflow,
186
187
eq(2 ),
187
- { _, _, r -> ! r.isException<ArithmeticException >() },
188
+ { _, _, r -> ! r.isException<OverflowDetectionError >() },
188
189
{ x, y, r ->
189
190
val negOverflow = ((x + y) >= 0 && x < 0 && y < 0 )
190
191
val posOverflow = ((x + y) <= 0 && x > 0 && y > 0 )
191
- (negOverflow || posOverflow) && r.isException<ArithmeticException >()
192
+ (negOverflow || posOverflow) && r.isException<OverflowDetectionError >()
192
193
}, // through overflow
193
194
)
194
195
}
@@ -200,11 +201,11 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
200
201
checkWithException(
201
202
OverflowExamples ::longSubOverflow,
202
203
eq(2 ),
203
- { _, _, r -> ! r.isException<ArithmeticException >() },
204
+ { _, _, r -> ! r.isException<OverflowDetectionError >() },
204
205
{ x, y, r ->
205
206
val negOverflow = ((x - y) >= 0 && x < 0 && y > 0 )
206
207
val posOverflow = ((x - y) <= 0 && x > 0 && y < 0 )
207
- (negOverflow || posOverflow) && r.isException<ArithmeticException >()
208
+ (negOverflow || posOverflow) && r.isException<OverflowDetectionError >()
208
209
}, // through overflow
209
210
)
210
211
}
@@ -221,8 +222,8 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
221
222
checkWithException(
222
223
OverflowExamples ::longMulOverflow,
223
224
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
226
227
)
227
228
}
228
229
}
@@ -234,8 +235,8 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
234
235
checkWithException(
235
236
OverflowExamples ::incOverflow,
236
237
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
239
240
)
240
241
}
241
242
}
@@ -251,8 +252,8 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
251
252
// Can't use abs(x) below, because abs(Int.MIN_VALUE) == Int.MIN_VALUE.
252
253
// (Int.MAX_VALUE shr 16) is the border of square overflow and cube overflow.
253
254
// 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
256
257
)
257
258
}
258
259
}
@@ -265,8 +266,8 @@ internal class OverflowAsErrorTest : UtValueTestCaseChecker(
265
266
checkWithException(
266
267
Sort ::quickSort,
267
268
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
270
271
)
271
272
}
272
273
}
0 commit comments