test/tools/doclint/OptionTest.java

changeset 1455
75ab654b5cd5
child 1465
a22f23fb7abf
equal deleted inserted replaced
1454:02a18f209ab3 1455:75ab654b5cd5
1
2 import com.sun.tools.doclint.DocLint;
3
4 /*
5 * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
6 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 *
8 * This code is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License version 2 only, as
10 * published by the Free Software Foundation.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 * or visit www.oracle.com if you need additional information or have any
24 * questions.
25 */
26
27 /*
28 * @test
29 */
30 public class OptionTest {
31 public static void main(String... args) throws Exception {
32 new OptionTest().run();
33 }
34
35 String[] positiveTests = {
36 "-Xmsgs",
37 "-Xmsgs:all",
38 "-Xmsgs:none",
39 "-Xmsgs:accessibility",
40 "-Xmsgs:html",
41 "-Xmsgs:missing",
42 "-Xmsgs:reference",
43 "-Xmsgs:syntax",
44 "-Xmsgs:html/public",
45 "-Xmsgs:html/protected",
46 "-Xmsgs:html/package",
47 "-Xmsgs:html/private",
48 "-Xmsgs:-html/public",
49 "-Xmsgs:-html/protected",
50 "-Xmsgs:-html/package",
51 "-Xmsgs:-html/private",
52 "-Xmsgs:html,syntax",
53 "-Xmsgs:html,-syntax",
54 "-Xmsgs:-html,syntax",
55 "-Xmsgs:-html,-syntax",
56 "-Xmsgs:html/public,syntax",
57 "-Xmsgs:html,syntax/public",
58 "-Xmsgs:-html/public,syntax/public"
59 };
60
61 String[] negativeTests = {
62 "-typo",
63 "-Xmsgs:-all",
64 "-Xmsgs:-none",
65 "-Xmsgs:typo",
66 "-Xmsgs:html/typo",
67 "-Xmsgs:html/public,typo",
68 "-Xmsgs:html/public,syntax/typo",
69 };
70
71 void run() throws Exception {
72 test(positiveTests, true);
73 test(negativeTests, false);
74
75 if (errors > 0)
76 throw new Exception(errors + " errors occurred");
77 }
78
79 void test(String[] tests, boolean expect) {
80 for (String test: tests) {
81 System.err.println("test: " + test);
82 boolean found = DocLint.isValidOption(test);
83 if (found != expect)
84 error("Unexpected result: " + found + ",expected: " + expect);
85 }
86 }
87
88 void error(String msg) {
89 System.err.println("Error: " + msg);
90 errors++;
91 }
92
93 int errors;
94 }

mercurial