langtools/test/tools/doclint/CoverageExtras.java
author jjg
Mon, 21 Jan 2013 10:00:46 -0800
changeset 15370 c1c9a9e11b26
child 30730 d3ce7619db2c
permissions -rw-r--r--
8006263: Supplementary test cases needed for doclint Reviewed-by: mcimadamore Contributed-by: peter.jensen@oracle.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15370
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
     1
/*
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
     2
 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
     4
 *
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
     7
 * published by the Free Software Foundation.
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
     8
 *
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    13
 * accompanied this code).
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    14
 *
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    18
 *
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    21
 * questions.
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    22
 */
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    23
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    24
/**
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    25
 * @test
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    26
 * @bug 8006263
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    27
 * @summary Supplementary test cases needed for doclint
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    28
 */
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    29
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    30
import com.sun.tools.doclint.Checker;
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    31
import com.sun.tools.doclint.Entity;
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    32
import com.sun.tools.doclint.HtmlTag;
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    33
import com.sun.tools.doclint.Messages;
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    34
import java.util.Objects;
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    35
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    36
public class CoverageExtras {
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    37
    public static void main(String... args) {
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    38
        new CoverageExtras().run();
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    39
    }
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    40
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    41
    void run() {
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    42
        check(HtmlTag.A, HtmlTag.valueOf("A"), HtmlTag.values());
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    43
        check(HtmlTag.Attr.ABBR, HtmlTag.Attr.valueOf("ABBR"), HtmlTag.Attr.values());
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    44
        check(HtmlTag.AttrKind.INVALID, HtmlTag.AttrKind.valueOf("INVALID"), HtmlTag.AttrKind.values());
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    45
        check(HtmlTag.BlockType.BLOCK, HtmlTag.BlockType.valueOf("BLOCK"), HtmlTag.BlockType.values());
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    46
        check(HtmlTag.EndKind.NONE, HtmlTag.EndKind.valueOf("NONE"), HtmlTag.EndKind.values());
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    47
        check(HtmlTag.Flag.EXPECT_CONTENT, HtmlTag.Flag.valueOf("EXPECT_CONTENT"), HtmlTag.Flag.values());
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    48
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    49
        check(Checker.Flag.TABLE_HAS_CAPTION, Checker.Flag.valueOf("TABLE_HAS_CAPTION"), Checker.Flag.values());
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    50
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    51
        check(Entity.nbsp, Entity.valueOf("nbsp"), Entity.values());
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    52
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    53
        check(Messages.Group.ACCESSIBILITY, Messages.Group.valueOf("ACCESSIBILITY"), Messages.Group.values());
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    54
    }
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    55
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    56
    <T extends Enum<T>> void check(T expect, T value, T[] values) {
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    57
        if (!Objects.equals(expect, value)) {
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    58
            error("Mismatch: '" + expect + "', '" + value + "'");
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    59
        }
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    60
        if (!Objects.equals(expect, values[0])) {
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    61
            error("Mismatch: '" + expect + "', '" + values[0] + "'");
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    62
        }
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    63
    }
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    64
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    65
    void error(String msg) {
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    66
        System.err.println("Error: " + msg);
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    67
        errors++;
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    68
    }
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    69
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    70
    int errors;
c1c9a9e11b26 8006263: Supplementary test cases needed for doclint
jjg
parents:
diff changeset
    71
}