< prev index next >

test/jdk/java/lang/Math/ExactArithTests.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -54,12 +54,12 @@
         errors++;
         System.err.println(message);
     }
 
     /**
-     * Test Math.addExact, multiplyExact, subtractExact, toIntValue methods
-     * with {@code int} arguments.
+     * Test Math.addExact, multiplyExact, subtractExact, incrementExact,
+     * decrementExact, negateExact methods with {@code int} arguments.
      */
     static void testIntegerExact() {
         testIntegerExact(0, 0);
         testIntegerExact(1, 1);
         testIntegerExact(1, -1);

@@ -74,11 +74,10 @@
         testIntegerExact(Integer.MAX_VALUE, 2);
         testIntegerExact(Integer.MIN_VALUE, -1);
         testIntegerExact(Integer.MAX_VALUE, -1);
         testIntegerExact(Integer.MIN_VALUE, -2);
         testIntegerExact(Integer.MAX_VALUE, -2);
-
     }
 
     /**
      * Test exact arithmetic by comparing with the same operations using long
      * and checking that the result is the same as the integer truncation.

@@ -99,11 +98,10 @@
             }
         } catch (ArithmeticException ex) {
             long sum2 = (long) x + (long) y;
             if ((int) sum2 == sum2) {
                 fail("FAIL: int Math.addExact(" + x + " + " + y + ")" + "; Unexpected exception: " + ex);
-
             }
         }
 
         try {
             // Test subtractExact

@@ -145,11 +143,10 @@
             }
         } catch (ArithmeticException ex) {
             long inc2 = (long) x + 1L;
             if ((int) inc2 == inc2) {
                 fail("FAIL: int Math.incrementExact(" + x + ")" + "; Unexpected exception: " + ex);
-
             }
         }
 
         try {
             // Test decrementExact

@@ -162,11 +159,10 @@
             }
         } catch (ArithmeticException ex) {
             long dec2 = (long) x - 1L;
             if ((int) dec2 == dec2) {
                 fail("FAIL: int Math.decrementExact(" + x + ")" + "; Unexpected exception: " + ex);
-
             }
         }
 
         try {
             // Test negateExact

@@ -179,18 +175,17 @@
             }
         } catch (ArithmeticException ex) {
             long neg2 = (long) x - 1L;
             if ((int) neg2 == neg2) {
                 fail("FAIL: int Math.negateExact(" + x + ")" + "; Unexpected exception: " + ex);
-
             }
         }
     }
 
     /**
-     * Test Math.addExact, multiplyExact, subtractExact, toIntExact methods
-     * with {@code long} arguments.
+     * Test Math.addExact, multiplyExact, subtractExact, incrementExact,
+     * decrementExact, negateExact, toIntExact methods with {@code long} arguments.
      */
     static void testLongExact() {
         testLongExactTwice(0, 0);
         testLongExactTwice(1, 1);
         testLongExactTwice(1, -1);

@@ -213,11 +208,10 @@
         testLongExactTwice(Integer.MAX_VALUE+1, Integer.MAX_VALUE+1);
         testLongExactTwice(Integer.MAX_VALUE+1, -Integer.MAX_VALUE+1);
         testLongExactTwice(Integer.MIN_VALUE-1, Integer.MIN_VALUE-1);
         testLongExactTwice(Integer.MIN_VALUE-1, -Integer.MIN_VALUE-1);
         testLongExactTwice(Integer.MIN_VALUE/2, 2);
-
     }
 
     /**
      * Test each of the exact operations with the arguments and
      * with the arguments reversed.

@@ -317,11 +311,10 @@
         } catch (ArithmeticException ex) {
             if (resultBig.bitLength() <= 32) {
                 fail("FAIL: long Math.toIntExact(" + x + ")" + "; Unexpected exception: " + ex);
             }
         }
-
     }
 
     /**
      * Compare the expected and actual results.
      * @param message message for the error
< prev index next >