andreachild commented on code in PR #3121:
URL: https://github.com/apache/tinkerpop/pull/3121#discussion_r2105450364
##########
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/NumberHelperTest.java:
##########
@@ -99,20 +114,36 @@ public class NumberHelperTest {
);
private final static List<Triplet<Number, Number, String>> OVERFLOW_CASES
= Arrays.asList(
- new Triplet<>(Integer.MAX_VALUE, 1, "add"),
- new Triplet<>(Integer.MIN_VALUE, 1, "sub"),
- new Triplet<>(Integer.MAX_VALUE, Integer.MAX_VALUE, "mul"),
new Triplet<>(Long.MAX_VALUE, 1L, "add"),
new Triplet<>(Long.MIN_VALUE, 1L, "sub"),
- new Triplet<>(Long.MAX_VALUE, Integer.MAX_VALUE, "mul"),
- new Triplet<>(Byte.MAX_VALUE, (byte)100, "add"),
- new Triplet<>(Byte.MIN_VALUE, (byte)100, "sub"),
- new Triplet<>((byte)100, (byte)100, "mul"),
- new Triplet<>(Short.MAX_VALUE, (short)100, "add"),
- new Triplet<>(Short.MIN_VALUE, (short)100, "sub"),
- new Triplet<>(Short.MAX_VALUE, (short)100, "mul")
+ new Triplet<>(Long.MAX_VALUE, Integer.MAX_VALUE, "mul")
Review Comment:
These two test cases should be added to overflow scenarios:
```
new Triplet<>(Long.MIN_VALUE, -1L, "mul"),
new Triplet<>(Long.MIN_VALUE, -1L, "div")
```
and actually the `div` case fails because `Math.divideExact` was not added
until Java 18 or 19, which means we have to add extra handling around the
single scenario in which division causes overflow.
See
https://docs.oracle.com/en/java/javase/19/docs/api/java.base/java/lang/Math.html#divideExact(int,int)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]