Search in sources :

Example 1 with MSG_KEY

use of com.puppycrawl.tools.checkstyle.checks.AvoidEscapedUnicodeCharactersCheck.MSG_KEY in project checkstyle by checkstyle.

the class AvoidEscapedUnicodeCharactersCheckTest method testAllowEscapesForControlCharacterSetForAllCharacters.

@Test
public void testAllowEscapesForControlCharacterSetForAllCharacters() throws Exception {
    final DefaultConfiguration checkConfig = createCheckConfig(AvoidEscapedUnicodeCharactersCheck.class);
    checkConfig.addAttribute("allowEscapesForControlCharacters", "true");
    final int indexOfStartLineInInputFile = 6;
    final String message = getCheckMessage(MSG_KEY);
    final String[] expected = IntStream.rangeClosed(0, 0xffff).parallel().filter(val -> !isControlCharacter(val)).mapToObj(msg -> indexOfStartLineInInputFile + msg + ": " + message).toArray(String[]::new);
    verify(checkConfig, getPath("InputAllEscapedUnicodeCharacters.java"), expected);
}
Also used : IntStream(java.util.stream.IntStream) TokenTypes(com.puppycrawl.tools.checkstyle.api.TokenTypes) Arrays(java.util.Arrays) BaseCheckTestSupport(com.puppycrawl.tools.checkstyle.BaseCheckTestSupport) Assert.assertArrayEquals(org.junit.Assert.assertArrayEquals) DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) IOException(java.io.IOException) Test(org.junit.Test) MSG_KEY(com.puppycrawl.tools.checkstyle.checks.AvoidEscapedUnicodeCharactersCheck.MSG_KEY) File(java.io.File) DefaultConfiguration(com.puppycrawl.tools.checkstyle.DefaultConfiguration) Test(org.junit.Test)

Aggregations

BaseCheckTestSupport (com.puppycrawl.tools.checkstyle.BaseCheckTestSupport)1 DefaultConfiguration (com.puppycrawl.tools.checkstyle.DefaultConfiguration)1 TokenTypes (com.puppycrawl.tools.checkstyle.api.TokenTypes)1 MSG_KEY (com.puppycrawl.tools.checkstyle.checks.AvoidEscapedUnicodeCharactersCheck.MSG_KEY)1 File (java.io.File)1 IOException (java.io.IOException)1 Arrays (java.util.Arrays)1 IntStream (java.util.stream.IntStream)1 Assert.assertArrayEquals (org.junit.Assert.assertArrayEquals)1 Test (org.junit.Test)1