package com.puppycrawl.tools.checkstyle;

import com.puppycrawl.tools.checkstyle.checks.ConstantNameCheck;

public class ConstantNameCheckTest
    extends BaseCheckTestCase
{
    public void testDefault()
        throws Exception
    {
        final CheckConfiguration checkConfig = new CheckConfiguration();
        checkConfig.setClassname(ConstantNameCheck.class.getName());
        final Checker c = createChecker(checkConfig);
        final String fname = getPath("InputSimple.java");
        final String[] expected = {
            "25:29: Name 'badConstant' must match pattern '^[A-Z](_?[A-Z0-9]+)*$'.",
            "142:30: Name 'BAD__NAME' must match pattern '^[A-Z](_?[A-Z0-9]+)*$'."
        };
        verify(c, fname, expected);
    }

    public void testInterface()
        throws Exception
    {
        final CheckConfiguration checkConfig = new CheckConfiguration();
        checkConfig.setClassname(ConstantNameCheck.class.getName());
        final Checker c = createChecker(checkConfig);
        final String fname = getPath("InputInner.java");
        final String[] expected = {
            "24:16: Name 'data' must match pattern '^[A-Z](_?[A-Z0-9]+)*$'."
        };
        verify(c, fname, expected);
    }
}

@@ -168,16 +168,450 @@
 tCase%0A%7B%0A
+    public void testIllegalRegexp()%0A        throws Exception%0A    %7B%0A        final CheckConfiguration checkConfig = new CheckConfiguration();%0A        checkConfig.setClassname(ConstantNameCheck.class.getName());%0A        checkConfig.addProperty(%22format%22, %22%5C%5C%22);%0A        try %7B%0A            createChecker(checkConfig);%0A            fail();%0A        %7D%0A        catch (CheckstyleException ex) %7B%0A            // expected exception%0A        %7D%0A    %7D%0A%0A
     publ

improve test coverage of AbstractFormatCheck