andreachild commented on code in PR #3117:
URL: https://github.com/apache/tinkerpop/pull/3117#discussion_r2082127871


##########
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/NumberHelperTest.java:
##########
@@ -460,22 +484,68 @@ public void testMinMaxCompare() {
         }
     }
 
+    @Test
+    public void shouldPromoteFloatToDoubleForSum() {
+        Number value = add(Float.MAX_VALUE, Float.MAX_VALUE);
+        assertTrue(value instanceof Double);
+        assertFalse(Double.isInfinite(value.doubleValue()));
+    }
+
+    @Test
+    public void shouldPromoteDoubleToInfiniteForSum() {
+        Number value = add(Double.MAX_VALUE, Double.MAX_VALUE);
+        assertTrue(value instanceof Double);
+        assertTrue(Double.isInfinite(value.doubleValue()));
+    }
+
+    @Test
+    public void shouldPromoteFloatToDoubleForMul() {
+        Number value = mul(Float.MAX_VALUE, 2F);
+        assertTrue(value instanceof Double);
+        assertFalse(Double.isInfinite(value.doubleValue()));
+    }
+
+    @Test
+    public void shouldPromoteDoubleToInfiniteForMul() {
+        Number value = mul(Double.MAX_VALUE, 2F);
+        assertTrue(value instanceof Double);
+        assertTrue(Double.isInfinite(value.doubleValue()));
+    }
+
     @Test
     public void shouldThrowArithmeticExceptionOnOverflow() {
-        for (final Triplet<Number, Number, String> q : OVERFLOW_CASES) {
+        for (final Quartet<Number, Number, String, Boolean> q : 
OVERFLOW_CASES) {
+            if (!q.getValue3()) {
+                continue;
+            }
+            try {
+                if (q.getValue2().equals("sub")) {
+                    sub(q.getValue0(), q.getValue1());
+                }
+                fail("ArithmeticException expected");
+            }
+            catch (ArithmeticException ex) {
+                // expected
+            }
+        }
+    }
+
+    @Test
+    public void shouldNotThrowArithmeticExceptionOnOverflow() {
+        for (final Quartet<Number, Number, String, Boolean> q : 
OVERFLOW_CASES) {
+            if (q.getValue3()) {
+                continue;
+            }
             try {
                 switch (q.getValue2()) {
                     case "add":
                         add(q.getValue0(), q.getValue1());

Review Comment:
   We should be verifying the expected result type as well.



-- 
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]

Reply via email to