1 /*
2 * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
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 4347132 4939441
27 * @summary Tests for {Math, StrictMath}.cbrt
28 * @author Joseph D. Darcy
29 */
30
31 public class CubeRootTests {
32 private CubeRootTests(){}
33
34 static final double infinityD = Double.POSITIVE_INFINITY;
35 static final double NaNd = Double.NaN;
36
37 // Initialize shared random number generator
38 static java.util.Random rand = new java.util.Random();
39
40 static int testCubeRootCase(double input, double expected) {
41 int failures=0;
42
43 double minus_input = -input;
44 double minus_expected = -expected;
45
46 failures+=Tests.test("Math.cbrt(double)", input,
47 Math.cbrt(input), expected);
48 failures+=Tests.test("Math.cbrt(double)", minus_input,
49 Math.cbrt(minus_input), minus_expected);
50 failures+=Tests.test("StrictMath.cbrt(double)", input,
51 StrictMath.cbrt(input), expected);
52 failures+=Tests.test("StrictMath.cbrt(double)", minus_input,
53 StrictMath.cbrt(minus_input), minus_expected);
54
55 return failures;
56 }
57
58 static int testCubeRoot() {
|
1 /*
2 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
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 * @library ..
27 * @bug 4347132 4939441 8078672
28 * @summary Tests for {Math, StrictMath}.cbrt (use -Dseed=X to set PRNG seed)
29 * @author Joseph D. Darcy
30 */
31
32 public class CubeRootTests {
33 private CubeRootTests(){}
34
35 static final double infinityD = Double.POSITIVE_INFINITY;
36 static final double NaNd = Double.NaN;
37
38 // Initialize shared random number generator
39 static java.util.Random rand = RandomFactory.getRandom();
40
41 static int testCubeRootCase(double input, double expected) {
42 int failures=0;
43
44 double minus_input = -input;
45 double minus_expected = -expected;
46
47 failures+=Tests.test("Math.cbrt(double)", input,
48 Math.cbrt(input), expected);
49 failures+=Tests.test("Math.cbrt(double)", minus_input,
50 Math.cbrt(minus_input), minus_expected);
51 failures+=Tests.test("StrictMath.cbrt(double)", input,
52 StrictMath.cbrt(input), expected);
53 failures+=Tests.test("StrictMath.cbrt(double)", minus_input,
54 StrictMath.cbrt(minus_input), minus_expected);
55
56 return failures;
57 }
58
59 static int testCubeRoot() {
|