test/java/lang/Math/RoundTests.java

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 6430675 8010430
  27  * @summary Check for correct implementation of {Math, StrictMath}.round



  28  */
  29 public class RoundTests {
  30     public static void main(String... args) {
  31         int failures = 0;
  32 
  33         failures += testNearFloatHalfCases();
  34         failures += testNearDoubleHalfCases();
  35         failures += testUnityULPCases();
  36         failures += testSpecialCases();
  37 
  38         if (failures > 0) {
  39             System.err.println("Testing {Math, StrictMath}.round incurred "
  40                                + failures + " failures.");
  41             throw new RuntimeException();
  42         }
  43     }
  44 
  45     private static int testNearDoubleHalfCases() {
  46         int failures = 0;
  47         double [][] testCases = {




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 6430675 8010430
  27  * @summary Check for correct implementation of {Math, StrictMath}.round
  28  * @library /lib/testlibrary
  29  * @build jdk.testlibrary.DoubleUtils jdk.testlibrary.FloatUtils
  30  * @run main RoundTests
  31  */
  32 public class RoundTests {
  33     public static void main(String... args) {
  34         int failures = 0;
  35 
  36         failures += testNearFloatHalfCases();
  37         failures += testNearDoubleHalfCases();
  38         failures += testUnityULPCases();
  39         failures += testSpecialCases();
  40 
  41         if (failures > 0) {
  42             System.err.println("Testing {Math, StrictMath}.round incurred "
  43                                + failures + " failures.");
  44             throw new RuntimeException();
  45         }
  46     }
  47 
  48     private static int testNearDoubleHalfCases() {
  49         int failures = 0;
  50         double [][] testCases = {