@Test
    public void shouldNotThrowArithmeticExceptionOnOverflow() {
        for (final Quartet<Number, Number, String, String> q : NO_OVERFLOW_CASES) {
            try {
                Number result = 0;
                switch (q.getValue2()) {
                    case "add":
                        result = add(q.getValue0(), q.getValue1());
                        break;
                    case "sub":
                        result = sub(q.getValue0(), q.getValue1());
                        break;
                    case "mul":
                        result = mul(q.getValue0(), q.getValue1());
                        break;
                    case "div":
                        result = div(q.getValue0(), q.getValue1());
                        break;
                    default:
                        fail("Unexpected math operation '" + q.getValue2() + "'");
                }
                String classValue = result.getClass().toString();
                switch (q.getValue3()) {
                    case "s":
                        assertEquals("class java.lang.Short", classValue);
                        break;
                    case "i":
                        assertEquals("class java.lang.Integer", classValue);
                        break;
                    case "l":
                        assertEquals("class java.lang.Long", classValue);
                        break;
                    case "f":
                        assertEquals("class java.lang.Float", classValue);
                        break;
                    case "d":
                        assertEquals("class java.lang.Double", classValue);
                        break;
                    default:
                        fail("Unexpected class type '" + q.getValue3() + "'");
                }
            }
            catch (ArithmeticException ex) {
                fail("ArithmeticException bot expected");
            }
        }
    }
@author Daniel Kuppitz (http://gremlin.guru)
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/util/NumberHelperTest.java