• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021, 2022, 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 package test.jdk.internal.math.ToDecimal;
25 
26 import jdk.internal.math.FloatToDecimalChecker;
27 import jdk.test.lib.RandomFactory;
28 
29 /*
30  * @test
31  * @key randomness
32  *
33  * @modules java.base/jdk.internal.math
34  * @library /test/lib
35  * @library java.base
36  * @build jdk.test.lib.RandomFactory
37  * @build java.base/jdk.internal.math.*
38  * @run main FloatToDecimalTest 100_000
39  */
40 public class FloatToDecimalTest {
41 
42     private static final int RANDOM_COUNT = 100_000;
43 
main(String[] args)44     public static void main(String[] args) {
45         if (args.length == 0) {
46             FloatToDecimalChecker.test(RANDOM_COUNT, RandomFactory.getRandom());
47         } else if (args[0].equals("all")) {
48             FloatToDecimalChecker.testAll();
49         } else if (args[0].equals("positive")) {
50             FloatToDecimalChecker.testPositive();
51         } else {
52             try {
53                 int count = Integer.parseInt(args[0].replace("_", ""));
54                 FloatToDecimalChecker.test(count, RandomFactory.getRandom());
55             } catch (NumberFormatException ignored) {
56                 FloatToDecimalChecker.test(RANDOM_COUNT, RandomFactory.getRandom());
57             }
58         }
59     }
60 
61 }
62