Refactored UTs, whitespace package, issue #537

This commit is contained in:
alexkravin 2015-02-20 16:59:34 +04:00
parent 2935730a7a
commit 4596d0b4c5
28 changed files with 576 additions and 337 deletions

View File

@ -33,6 +33,31 @@ import com.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck;
abstract class AbstractParenPadCheck
extends AbstractOptionCheck<PadOption>
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String WS_FOLLOWED = "ws.followed";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String WS_NOT_FOLLOWED = "ws.notFollowed";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String WS_PRECEDED = "ws.preceded";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String WS_NOT_PRECEDED = "ws.notPreceded";
/**
* Sets the paren pad option to nospace.
*/
@ -53,13 +78,13 @@ abstract class AbstractParenPadCheck
if ((PadOption.NOSPACE == getAbstractOption())
&& (Character.isWhitespace(line.charAt(after))))
{
log(ast.getLineNo(), after, "ws.followed", "(");
log(ast.getLineNo(), after, WS_FOLLOWED, "(");
}
else if ((PadOption.SPACE == getAbstractOption())
&& !Character.isWhitespace(line.charAt(after))
&& (line.charAt(after) != ')'))
{
log(ast.getLineNo(), after, "ws.notFollowed", "(");
log(ast.getLineNo(), after, WS_NOT_FOLLOWED, "(");
}
}
}
@ -77,14 +102,14 @@ abstract class AbstractParenPadCheck
&& Character.isWhitespace(line.charAt(before))
&& !Utils.whitespaceBefore(before, line))
{
log(ast.getLineNo(), before, "ws.preceded", ")");
log(ast.getLineNo(), before, WS_PRECEDED, ")");
}
else if ((PadOption.SPACE == getAbstractOption())
&& !Character.isWhitespace(line.charAt(before))
&& (line.charAt(before) != '('))
{
log(ast.getLineNo(), ast.getColumnNo(),
"ws.notPreceded", ")");
WS_NOT_PRECEDED, ")");
}
}
}

View File

@ -50,6 +50,19 @@ for (
public class EmptyForInitializerPadCheck
extends AbstractOptionCheck<PadOption>
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_PRECEDED = "ws.preceded";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_NOT_PRECEDED = "ws.notPreceded";
/**
* Sets the paren pad otion to nospace.
*/
@ -87,12 +100,12 @@ public class EmptyForInitializerPadCheck
if ((PadOption.NOSPACE == option)
&& (Character.isWhitespace(line.charAt(before))))
{
log(semi.getLineNo(), before, "ws.preceded", ";");
log(semi.getLineNo(), before, MSG_PRECEDED, ";");
}
else if ((PadOption.SPACE == option)
&& !Character.isWhitespace(line.charAt(before)))
{
log(semi.getLineNo(), before, "ws.notPreceded", ";");
log(semi.getLineNo(), before, MSG_NOT_PRECEDED, ";");
}
}
}

View File

@ -50,6 +50,19 @@ for (Iterator foo = very.long.line.iterator();
public class EmptyForIteratorPadCheck
extends AbstractOptionCheck<PadOption>
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String WS_FOLLOWED = "ws.followed";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String WS_NOT_FOLLOWED = "ws.notFollowed";
/**
* Sets the paren pad otion to nospace.
*/
@ -85,12 +98,12 @@ public class EmptyForIteratorPadCheck
if ((PadOption.NOSPACE == getAbstractOption())
&& (Character.isWhitespace(line.charAt(after))))
{
log(semi.getLineNo(), after, "ws.followed", ";");
log(semi.getLineNo(), after, WS_FOLLOWED, ";");
}
else if ((PadOption.SPACE == getAbstractOption())
&& !Character.isWhitespace(line.charAt(after)))
{
log(semi.getLineNo(), after, "ws.notFollowed", ";");
log(semi.getLineNo(), after, WS_NOT_FOLLOWED, ";");
}
}
}

View File

@ -28,6 +28,19 @@ import java.util.List;
*/
public class FileTabCharacterCheck extends AbstractFileSetCheck
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String CONTAINS_TAB = "containsTab";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String FILE_CONTAINS_TAB = "file.containsTab";
/** Indicates whether to report once per file, or for each line. */
private boolean eachLine;
@ -40,10 +53,10 @@ public class FileTabCharacterCheck extends AbstractFileSetCheck
final int tabPosition = line.indexOf('\t');
if (tabPosition != -1) {
if (eachLine) {
log(lineNum, tabPosition + 1, "containsTab");
log(lineNum, tabPosition + 1, CONTAINS_TAB);
}
else {
log(lineNum, tabPosition + 1, "file.containsTab");
log(lineNum, tabPosition + 1, FILE_CONTAINS_TAB);
break;
}
}

View File

@ -66,6 +66,31 @@ import com.puppycrawl.tools.checkstyle.api.Utils;
*/
public class GenericWhitespaceCheck extends Check
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String WS_PRECEDED = "ws.preceded";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String WS_FOLLOWED = "ws.followed";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String WS_NOT_PRECEDED = "ws.notPreceded";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String WS_ILLEGAL_FOLLOW = "ws.illegalFollow";
/** Used to count the depth of a Generic expression. */
private int depth;
@ -115,7 +140,7 @@ public class GenericWhitespaceCheck extends Check
if ((0 <= before) && Character.isWhitespace(line.charAt(before))
&& !Utils.whitespaceBefore(before, line))
{
log(ast.getLineNo(), before, "ws.preceded", ">");
log(ast.getLineNo(), before, WS_PRECEDED, ">");
}
if (after < line.length()) {
@ -136,7 +161,7 @@ public class GenericWhitespaceCheck extends Check
== TokenTypes.METHOD_CALL))
{
if (Character.isWhitespace(charAfter)) {
log(ast.getLineNo(), after, "ws.followed", ">");
log(ast.getLineNo(), after, WS_FOLLOWED, ">");
}
}
else if (!Character.isWhitespace(charAfter)
@ -144,7 +169,7 @@ public class GenericWhitespaceCheck extends Check
&& (',' != charAfter) && ('[' != charAfter)
&& ('.' != charAfter) && (':' != charAfter))
{
log(ast.getLineNo(), after, "ws.illegalFollow", ">");
log(ast.getLineNo(), after, WS_ILLEGAL_FOLLOW, ">");
}
}
else {
@ -161,14 +186,14 @@ public class GenericWhitespaceCheck extends Check
&& whitespaceBetween(after, indexOfAmp, line))
{
if (indexOfAmp - after == 0) {
log(ast.getLineNo(), after, "ws.notPreceded", "&");
log(ast.getLineNo(), after, WS_NOT_PRECEDED, "&");
}
else if (indexOfAmp - after != 1) {
log(ast.getLineNo(), after, "ws.followed", ">");
log(ast.getLineNo(), after, WS_FOLLOWED, ">");
}
}
else if (line.charAt(after) == ' ') {
log(ast.getLineNo(), after, "ws.followed", ">");
log(ast.getLineNo(), after, WS_FOLLOWED, ">");
}
}
}
@ -200,21 +225,21 @@ public class GenericWhitespaceCheck extends Check
{
// Require whitespace
if (!Character.isWhitespace(line.charAt(before))) {
log(ast.getLineNo(), before, "ws.notPreceded", "<");
log(ast.getLineNo(), before, WS_NOT_PRECEDED, "<");
}
}
// Whitespace not required
else if (Character.isWhitespace(line.charAt(before))
&& !Utils.whitespaceBefore(before, line))
{
log(ast.getLineNo(), before, "ws.preceded", "<");
log(ast.getLineNo(), before, WS_PRECEDED, "<");
}
}
if ((after < line.length())
&& Character.isWhitespace(line.charAt(after)))
{
log(ast.getLineNo(), after, "ws.followed", "<");
log(ast.getLineNo(), after, WS_FOLLOWED, "<");
}
}

View File

@ -65,6 +65,25 @@ import com.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck;
public class MethodParamPadCheck
extends AbstractOptionCheck<PadOption>
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String LINE_PREVIOUS = "line.previous";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String WS_PRECEDED = "ws.preceded";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String WS_NOT_PRECEDED = "ws.notPreceded";
/**
* Sets the pad option to nospace.
*/
@ -119,7 +138,7 @@ public class MethodParamPadCheck
final String line = getLines()[parenAST.getLineNo() - 1];
if (Utils.whitespaceBefore(parenAST.getColumnNo(), line)) {
if (!allowLineBreaks) {
log(parenAST, "line.previous", parenAST.getText());
log(parenAST, LINE_PREVIOUS, parenAST.getText());
}
}
else {
@ -127,12 +146,12 @@ public class MethodParamPadCheck
if ((PadOption.NOSPACE == getAbstractOption())
&& (Character.isWhitespace(line.charAt(before))))
{
log(parenAST , "ws.preceded", parenAST.getText());
log(parenAST , WS_PRECEDED, parenAST.getText());
}
else if ((PadOption.SPACE == getAbstractOption())
&& !Character.isWhitespace(line.charAt(before)))
{
log(parenAST, "ws.notPreceded", parenAST.getText());
log(parenAST, WS_NOT_PRECEDED, parenAST.getText());
}
}
}

View File

@ -66,6 +66,12 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
public class NoLineWrapCheck extends Check
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_KEY = "no.line.wrap";
@Override
public int[] getDefaultTokens()
{
@ -90,7 +96,7 @@ public class NoLineWrapCheck extends Check
public void visitToken(DetailAST ast)
{
if (ast.getLineNo() != ast.getLastChild().getLineNo()) {
log(ast.getLineNo(), "no.line.wrap", ast.getText());
log(ast.getLineNo(), MSG_KEY, ast.getText());
}
}
}

View File

@ -65,6 +65,13 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
*/
public class NoWhitespaceAfterCheck extends Check
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_KEY = "ws.followed";
/** Whether whitespace is allowed if the AST is at a linebreak */
private boolean allowLineBreaks = true;
@ -118,7 +125,7 @@ public class NoWhitespaceAfterCheck extends Check
&& hasRedundantWhitespace(line, after))
{
log(astNode.getLineNo(), after,
"ws.followed", astNode.getText());
MSG_KEY, astNode.getText());
}
}

View File

@ -61,6 +61,13 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
public class NoWhitespaceBeforeCheck
extends Check
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String MSG_KEY = "ws.preceded";
/** Whether whitespace is allowed if the AST is at a linebreak */
private boolean allowLineBreaks;
@ -112,7 +119,7 @@ public class NoWhitespaceBeforeCheck
}
}
if (flag) {
log(ast.getLineNo(), before, "ws.preceded", ast.getText());
log(ast.getLineNo(), before, MSG_KEY, ast.getText());
}
}
}

View File

@ -90,6 +90,19 @@ import com.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck;
public class OperatorWrapCheck
extends AbstractOptionCheck<WrapOption>
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String LINE_NEW = "line.new";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String LINE_PREVIOUS = "line.previous";
/**
* Sets the operator wrap option to new line.
*/
@ -199,12 +212,12 @@ public class OperatorWrapCheck
&& (currentLine.substring(colNo + text.length())
.trim().length() == 0))
{
log(lineNo, colNo, "line.new", text);
log(lineNo, colNo, LINE_NEW, text);
}
else if ((wOp == WrapOption.EOL)
&& Utils.whitespaceBefore(colNo - 1, currentLine))
{
log(lineNo, colNo, "line.previous", text);
log(lineNo, colNo, LINE_PREVIOUS, text);
}
}
}

View File

@ -80,6 +80,19 @@ import com.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck;
public class SeparatorWrapCheck
extends AbstractOptionCheck<WrapOption>
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String LINE_PREVIOUS = "line.previous";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String LINE_NEW = "line.new";
/**
* Sets the comma wrap option to end of the line.
*/
@ -131,12 +144,12 @@ public class SeparatorWrapCheck
if (wSp == WrapOption.EOL
&& (substringBeforeToken.length() == 0))
{
log(lineNo, colNo, "line.previous", text);
log(lineNo, colNo, LINE_PREVIOUS, text);
}
else if (wSp == WrapOption.NL
&& substringAfterToken.length() == 0)
{
log(lineNo, colNo, "line.new", text);
log(lineNo, colNo, LINE_NEW, text);
}
}
}

View File

@ -55,6 +55,13 @@ import com.puppycrawl.tools.checkstyle.api.DetailAST;
public class WhitespaceAfterCheck
extends Check
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String WS_NOT_FOLLOWED = "ws.notFollowed";
@Override
public int[] getDefaultTokens()
{
@ -115,7 +122,7 @@ public class WhitespaceAfterCheck
}
log(targetAST.getLineNo(),
targetAST.getColumnNo() + targetAST.getText().length(),
"ws.notFollowed",
WS_NOT_FOLLOWED,
message);
}
}

View File

@ -157,6 +157,19 @@ import com.puppycrawl.tools.checkstyle.api.TokenTypes;
*/
public class WhitespaceAroundCheck extends Check
{
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String WS_NOT_PRECEDED = "ws.notPreceded";
/**
* A key is pointing to the warning message text in "messages.properties"
* file.
*/
public static final String WS_NOT_FOLLOWED = "ws.notFollowed";
/** Whether or not empty constructor bodies are allowed. */
private boolean allowEmptyCtors;
/** Whether or not empty method bodies are allowed. */
@ -390,7 +403,7 @@ public class WhitespaceAroundCheck extends Check
if ((before >= 0) && !Character.isWhitespace(line.charAt(before))) {
log(ast.getLineNo(), ast.getColumnNo(),
"ws.notPreceded", ast.getText());
WS_NOT_PRECEDED, ast.getText());
}
if (after >= line.length()) {
@ -410,7 +423,7 @@ public class WhitespaceAroundCheck extends Check
|| (nextChar == '.'))))
{
log(ast.getLineNo(), ast.getColumnNo() + ast.getText().length(),
"ws.notFollowed", ast.getText());
WS_NOT_FOLLOWED, ast.getText());
}
}

View File

@ -23,6 +23,11 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Before;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitializerPadCheck
.MSG_NOT_PRECEDED;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForInitializerPadCheck
.MSG_PRECEDED;
public class EmptyForInitializerPadCheckTest
extends BaseCheckTestSupport
{
@ -38,7 +43,7 @@ public class EmptyForInitializerPadCheckTest
public void testDefault() throws Exception
{
final String[] expected = {
"48:14: ';' is preceded with whitespace.",
"48:14: " + getCheckMessage(MSG_PRECEDED, ";"),
};
verify(checkConfig, getPath("InputForWhitespace.java"), expected);
}
@ -48,7 +53,7 @@ public class EmptyForInitializerPadCheckTest
{
checkConfig.addAttribute("option", PadOption.SPACE.toString());
final String[] expected = {
"51:13: ';' is not preceded with whitespace.",
"51:13: " + getCheckMessage(MSG_NOT_PRECEDED, ";"),
};
verify(checkConfig, getPath("InputForWhitespace.java"), expected);
}

View File

@ -23,6 +23,11 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Before;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForIteratorPadCheck
.WS_FOLLOWED;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyForIteratorPadCheck
.WS_NOT_FOLLOWED;
public class EmptyForIteratorPadCheckTest
extends BaseCheckTestSupport
{
@ -38,8 +43,8 @@ public class EmptyForIteratorPadCheckTest
public void testDefault() throws Exception
{
final String[] expected = {
"27:31: ';' is followed by whitespace.",
"43:32: ';' is followed by whitespace.",
"27:31: " + getCheckMessage(WS_FOLLOWED, ";"),
"43:32: " + getCheckMessage(WS_FOLLOWED, ";"),
};
verify(checkConfig, getPath("InputForWhitespace.java"), expected);
}
@ -49,7 +54,7 @@ public class EmptyForIteratorPadCheckTest
{
checkConfig.addAttribute("option", PadOption.SPACE.toString());
final String[] expected = {
"23:31: ';' is not followed by whitespace.",
"23:31: " + getCheckMessage(WS_NOT_FOLLOWED, ";"),
};
verify(checkConfig, getPath("InputForWhitespace.java"), expected);
}

View File

@ -22,6 +22,11 @@ import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck
.MSG_MULTIPLE_LINES;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.EmptyLineSeparatorCheck
.MSG_SHOULD_BE_SEPARATED;
public class EmptyLineSeparatorCheckTest
extends BaseCheckTestSupport
{
@ -32,11 +37,11 @@ public class EmptyLineSeparatorCheckTest
DefaultConfiguration checkConfig = createCheckConfig(EmptyLineSeparatorCheck.class);
final String[] expected = {
"21: 'import' should be separated from previous statement.",
"35: 'CLASS_DEF' should be separated from previous statement.",
"38: 'VARIABLE_DEF' should be separated from previous statement.",
"39: 'STATIC_INIT' should be separated from previous statement.",
"77: 'INTERFACE_DEF' should be separated from previous statement.",
"21: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "import"),
"35: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "CLASS_DEF"),
"38: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "VARIABLE_DEF"),
"39: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "STATIC_INIT"),
"77: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "INTERFACE_DEF"),
};
verify(checkConfig, getPath("whitespace/InputEmptyLineSeparatorCheck.java"), expected);
}
@ -49,10 +54,10 @@ public class EmptyLineSeparatorCheckTest
checkConfig.addAttribute("allowNoEmptyLineBetweenFields", "true");
final String[] expected = {
"21: 'import' should be separated from previous statement.",
"35: 'CLASS_DEF' should be separated from previous statement.",
"39: 'STATIC_INIT' should be separated from previous statement.",
"77: 'INTERFACE_DEF' should be separated from previous statement.",
"21: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "import"),
"35: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "CLASS_DEF"),
"39: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "STATIC_INIT"),
"77: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "INTERFACE_DEF"),
};
verify(checkConfig, getPath("whitespace/InputEmptyLineSeparatorCheck.java"), expected);
}
@ -62,7 +67,7 @@ public class EmptyLineSeparatorCheckTest
{
DefaultConfiguration checkConfig = createCheckConfig(EmptyLineSeparatorCheck.class);
final String[] expected = {
"19: 'package' should be separated from previous statement.",
"19: " + getCheckMessage(MSG_SHOULD_BE_SEPARATED, "package"),
};
verify(checkConfig, getPath("whitespace/InputEmptyLineSeparatorCheckHeader.java"), expected);
}
@ -73,11 +78,11 @@ public class EmptyLineSeparatorCheckTest
DefaultConfiguration checkConfig = createCheckConfig(EmptyLineSeparatorCheck.class);
checkConfig.addAttribute("allowMultipleEmptyLines", "false");
final String[] expected = {
"21: 'package' has more than 1 empty lines before.",
"24: 'import' has more than 1 empty lines before.",
"33: 'VARIABLE_DEF' has more than 1 empty lines before.",
"38: 'VARIABLE_DEF' has more than 1 empty lines before.",
"43: 'METHOD_DEF' has more than 1 empty lines before.",
"21: " + getCheckMessage(MSG_MULTIPLE_LINES, "package"),
"24: " + getCheckMessage(MSG_MULTIPLE_LINES, "import"),
"33: " + getCheckMessage(MSG_MULTIPLE_LINES, "VARIABLE_DEF"),
"38: " + getCheckMessage(MSG_MULTIPLE_LINES, "VARIABLE_DEF"),
"43: " + getCheckMessage(MSG_MULTIPLE_LINES, "METHOD_DEF"),
};
verify(checkConfig, getPath("whitespace/InputEmptyLineSeparatorCheckMultipleEmptyLines.java"), expected);
}

View File

@ -24,6 +24,10 @@ import com.puppycrawl.tools.checkstyle.api.Configuration;
import java.io.File;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck.CONTAINS_TAB;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.FileTabCharacterCheck
.FILE_CONTAINS_TAB;
public class FileTabCharacterCheckTest
extends BaseCheckTestSupport
{
@ -41,7 +45,7 @@ public class FileTabCharacterCheckTest
{
final DefaultConfiguration checkConfig = createConfig(false);
final String[] expected = {
"19:25: File contains tab characters (this is the first instance).",
"19:25: " + getCheckMessage(FILE_CONTAINS_TAB),
};
final File[] files = {
new File(getPath("InputSimple.java")),
@ -55,14 +59,14 @@ public class FileTabCharacterCheckTest
{
final DefaultConfiguration checkConfig = createConfig(true);
final String[] expected = {
"19:25: Line contains a tab character.",
"145:35: Line contains a tab character.",
"146:64: Line contains a tab character.",
"154:9: Line contains a tab character.",
"155:10: Line contains a tab character.",
"156:1: Line contains a tab character.",
"157:3: Line contains a tab character.",
"158:3: Line contains a tab character.",
"19:25: " + getCheckMessage(CONTAINS_TAB),
"145:35: " + getCheckMessage(CONTAINS_TAB),
"146:64: " + getCheckMessage(CONTAINS_TAB),
"154:9: " + getCheckMessage(CONTAINS_TAB),
"155:10: " + getCheckMessage(CONTAINS_TAB),
"156:1: " + getCheckMessage(CONTAINS_TAB),
"157:3: " + getCheckMessage(CONTAINS_TAB),
"158:3: " + getCheckMessage(CONTAINS_TAB),
};
final File[] files = {
new File(getPath("InputSimple.java")),

View File

@ -28,6 +28,13 @@ import java.util.Map;
import org.junit.Before;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck.WS_FOLLOWED;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck
.WS_ILLEGAL_FOLLOW;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck
.WS_NOT_PRECEDED;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.GenericWhitespaceCheck.WS_PRECEDED;
public class GenericWhitespaceCheckTest
extends BaseCheckTestSupport
{
@ -48,32 +55,32 @@ public class GenericWhitespaceCheckTest
public void testDefault() throws Exception
{
final String[] expected = {
"16:13: '<' is preceded with whitespace.",
"16:15: '<' is followed by whitespace.",
"16:23: '>' is preceded with whitespace.",
"16:43: '<' is preceded with whitespace.",
"16:45: '<' is followed by whitespace.",
"16:53: '>' is preceded with whitespace.",
"17:13: '<' is preceded with whitespace.",
"17:15: '<' is followed by whitespace.",
"17:20: '<' is preceded with whitespace.",
"17:22: '<' is followed by whitespace.",
"17:30: '>' is preceded with whitespace.",
"17:32: '>' is followed by whitespace.",
"17:32: '>' is preceded with whitespace.",
"17:52: '<' is preceded with whitespace.",
"17:54: '<' is followed by whitespace.",
"17:59: '<' is preceded with whitespace.",
"17:61: '<' is followed by whitespace.",
"17:69: '>' is preceded with whitespace.",
"17:71: '>' is followed by whitespace.",
"17:71: '>' is preceded with whitespace.",
"30:17: '<' is not preceded with whitespace.",
"30:21: '>' is followed by an illegal character.",
"42:21: '<' is preceded with whitespace.",
"42:30: '>' is followed by whitespace.",
"60:60: '&' is not preceded with whitespace.",
"63:60: '>' is followed by whitespace.",
"16:13: " + getCheckMessage(WS_PRECEDED, "<"),
"16:15: " + getCheckMessage(WS_FOLLOWED, "<"),
"16:23: " + getCheckMessage(WS_PRECEDED, ">"),
"16:43: " + getCheckMessage(WS_PRECEDED, "<"),
"16:45: " + getCheckMessage(WS_FOLLOWED, "<"),
"16:53: " + getCheckMessage(WS_PRECEDED, ">"),
"17:13: " + getCheckMessage(WS_PRECEDED, "<"),
"17:15: " + getCheckMessage(WS_FOLLOWED, "<"),
"17:20: " + getCheckMessage(WS_PRECEDED, "<"),
"17:22: " + getCheckMessage(WS_FOLLOWED, "<"),
"17:30: " + getCheckMessage(WS_PRECEDED, ">"),
"17:32: " + getCheckMessage(WS_FOLLOWED, ">"),
"17:32: " + getCheckMessage(WS_PRECEDED, ">"),
"17:52: " + getCheckMessage(WS_PRECEDED, "<"),
"17:54: " + getCheckMessage(WS_FOLLOWED, "<"),
"17:59: " + getCheckMessage(WS_PRECEDED, "<"),
"17:61: " + getCheckMessage(WS_FOLLOWED, "<"),
"17:69: " + getCheckMessage(WS_PRECEDED, ">"),
"17:71: " + getCheckMessage(WS_FOLLOWED, ">"),
"17:71: " + getCheckMessage(WS_PRECEDED, ">"),
"30:17: " + getCheckMessage(WS_NOT_PRECEDED, "<"),
"30:21: " + getCheckMessage(WS_ILLEGAL_FOLLOW, ">"),
"42:21: " + getCheckMessage(WS_PRECEDED, "<"),
"42:30: " + getCheckMessage(WS_FOLLOWED, ">"),
"60:60: " + getCheckMessage(WS_NOT_PRECEDED, "&"),
"63:60: " + getCheckMessage(WS_FOLLOWED, ">"),
};
verify(checkConfig,
getPath("whitespace/InputGenericWhitespaceCheck.java"),

View File

@ -23,6 +23,11 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Before;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck.LINE_PREVIOUS;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck
.WS_NOT_PRECEDED;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.MethodParamPadCheck.WS_PRECEDED;
public class MethodParamPadCheckTest
extends BaseCheckTestSupport
{
@ -38,22 +43,22 @@ public class MethodParamPadCheckTest
public void testDefault() throws Exception
{
final String[] expected = {
"11:32: '(' is preceded with whitespace.",
"13:15: '(' is preceded with whitespace.",
"17:9: '(' should be on the previous line.",
"20:13: '(' should be on the previous line.",
"27:24: '(' is preceded with whitespace.",
"32:9: '(' should be on the previous line.",
"36:39: '(' is preceded with whitespace.",
"38:13: '(' should be on the previous line.",
"42:16: '(' is preceded with whitespace.",
"44:13: '(' should be on the previous line.",
"50:21: '(' is preceded with whitespace.",
"52:13: '(' should be on the previous line.",
"56:18: '(' is preceded with whitespace.",
"58:13: '(' should be on the previous line.",
"61:36: '(' is preceded with whitespace.",
"63:13: '(' should be on the previous line.",
"11:32: " + getCheckMessage(WS_PRECEDED, "("),
"13:15: " + getCheckMessage(WS_PRECEDED, "("),
"17:9: " + getCheckMessage(LINE_PREVIOUS, "("),
"20:13: " + getCheckMessage(LINE_PREVIOUS, "("),
"27:24: " + getCheckMessage(WS_PRECEDED, "("),
"32:9: " + getCheckMessage(LINE_PREVIOUS, "("),
"36:39: " + getCheckMessage(WS_PRECEDED, "("),
"38:13: " + getCheckMessage(LINE_PREVIOUS, "("),
"42:16: " + getCheckMessage(WS_PRECEDED, "("),
"44:13: " + getCheckMessage(LINE_PREVIOUS, "("),
"50:21: " + getCheckMessage(WS_PRECEDED, "("),
"52:13: " + getCheckMessage(LINE_PREVIOUS, "("),
"56:18: " + getCheckMessage(WS_PRECEDED, "("),
"58:13: " + getCheckMessage(LINE_PREVIOUS, "("),
"61:36: " + getCheckMessage(WS_PRECEDED, "("),
"63:13: " + getCheckMessage(LINE_PREVIOUS, "("),
};
verify(checkConfig, getPath("whitespace/InputMethodParamPad.java"), expected);
}
@ -63,14 +68,14 @@ public class MethodParamPadCheckTest
{
checkConfig.addAttribute("allowLineBreaks", "true");
final String[] expected = {
"11:32: '(' is preceded with whitespace.",
"13:15: '(' is preceded with whitespace.",
"27:24: '(' is preceded with whitespace.",
"36:39: '(' is preceded with whitespace.",
"42:16: '(' is preceded with whitespace.",
"50:21: '(' is preceded with whitespace.",
"56:18: '(' is preceded with whitespace.",
"61:36: '(' is preceded with whitespace.",
"11:32: " + getCheckMessage(WS_PRECEDED, "("),
"13:15: " + getCheckMessage(WS_PRECEDED, "("),
"27:24: " + getCheckMessage(WS_PRECEDED, "("),
"36:39: " + getCheckMessage(WS_PRECEDED, "("),
"42:16: " + getCheckMessage(WS_PRECEDED, "("),
"50:21: " + getCheckMessage(WS_PRECEDED, "("),
"56:18: " + getCheckMessage(WS_PRECEDED, "("),
"61:36: " + getCheckMessage(WS_PRECEDED, "("),
};
verify(checkConfig, getPath("whitespace/InputMethodParamPad.java"), expected);
}
@ -80,27 +85,27 @@ public class MethodParamPadCheckTest
{
checkConfig.addAttribute("option", "space");
final String[] expected = {
"6:31: '(' is not preceded with whitespace.",
"8:14: '(' is not preceded with whitespace.",
"17:9: '(' should be on the previous line.",
"20:13: '(' should be on the previous line.",
"23:23: '(' is not preceded with whitespace.",
"32:9: '(' should be on the previous line.",
"35:58: '(' is not preceded with whitespace.",
"38:13: '(' should be on the previous line.",
"41:15: '(' is not preceded with whitespace.",
"44:13: '(' should be on the previous line.",
"47:28: '(' is not preceded with whitespace.",
"49:20: '(' is not preceded with whitespace.",
"52:13: '(' should be on the previous line.",
"54:56: '(' is not preceded with whitespace.",
"55:17: '(' is not preceded with whitespace.",
"58:13: '(' should be on the previous line.",
"60:35: '(' is not preceded with whitespace.",
"63:13: '(' should be on the previous line.",
"66:25: '(' is not preceded with whitespace.",
"69:66: '(' is not preceded with whitespace.",
"70:57: '(' is not preceded with whitespace.",
"6:31: " + getCheckMessage(WS_NOT_PRECEDED, "("),
"8:14: " + getCheckMessage(WS_NOT_PRECEDED, "("),
"17:9: " + getCheckMessage(LINE_PREVIOUS, "("),
"20:13: " + getCheckMessage(LINE_PREVIOUS, "("),
"23:23: " + getCheckMessage(WS_NOT_PRECEDED, "("),
"32:9: " + getCheckMessage(LINE_PREVIOUS, "("),
"35:58: " + getCheckMessage(WS_NOT_PRECEDED, "("),
"38:13: " + getCheckMessage(LINE_PREVIOUS, "("),
"41:15: " + getCheckMessage(WS_NOT_PRECEDED, "("),
"44:13: " + getCheckMessage(LINE_PREVIOUS, "("),
"47:28: " + getCheckMessage(WS_NOT_PRECEDED, "("),
"49:20: " + getCheckMessage(WS_NOT_PRECEDED, "("),
"52:13: " + getCheckMessage(LINE_PREVIOUS, "("),
"54:56: " + getCheckMessage(WS_NOT_PRECEDED, "("),
"55:17: " + getCheckMessage(WS_NOT_PRECEDED, "("),
"58:13: " + getCheckMessage(LINE_PREVIOUS, "("),
"60:35: " + getCheckMessage(WS_NOT_PRECEDED, "("),
"63:13: " + getCheckMessage(LINE_PREVIOUS, "("),
"66:25: " + getCheckMessage(WS_NOT_PRECEDED, "("),
"69:66: " + getCheckMessage(WS_NOT_PRECEDED, "("),
"70:57: " + getCheckMessage(WS_NOT_PRECEDED, "("),
};
verify(checkConfig, getPath("whitespace/InputMethodParamPad.java"), expected);
}

View File

@ -22,6 +22,8 @@ import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.NoLineWrapCheck.MSG_KEY;
public class NoLineWrapCheckTest
extends BaseCheckTestSupport
{
@ -38,8 +40,8 @@ public class NoLineWrapCheckTest
{
final DefaultConfiguration checkConfig = createCheckConfig(NoLineWrapCheck.class);
final String[] expected = {
"1: package statement should not be line-wrapped.",
"6: import statement should not be line-wrapped.",
"1: " + getCheckMessage(MSG_KEY, "package"),
"6: " + getCheckMessage(MSG_KEY, "import"),
};
verify(checkConfig, getPath("whitespace/NoLineWrapBadInput.java"), expected);
}
@ -51,10 +53,10 @@ public class NoLineWrapCheckTest
final DefaultConfiguration checkConfig = createCheckConfig(NoLineWrapCheck.class);
checkConfig.addAttribute("tokens", "IMPORT, CLASS_DEF, METHOD_DEF, ENUM_DEF");
final String[] expected = {
"6: import statement should not be line-wrapped.",
"10: CLASS_DEF statement should not be line-wrapped.",
"13: METHOD_DEF statement should not be line-wrapped.",
"20: ENUM_DEF statement should not be line-wrapped.",
"6: " + getCheckMessage(MSG_KEY, "import"),
"10: " + getCheckMessage(MSG_KEY, "CLASS_DEF"),
"13: " + getCheckMessage(MSG_KEY, "METHOD_DEF"),
"20: " + getCheckMessage(MSG_KEY, "ENUM_DEF"),
};
verify(checkConfig, getPath("whitespace/NoLineWrapBadInput.java"), expected);
}

View File

@ -23,6 +23,8 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Before;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceAfterCheck.MSG_KEY;
public class NoWhitespaceAfterCheckTest
extends BaseCheckTestSupport
{
@ -39,17 +41,17 @@ public class NoWhitespaceAfterCheckTest
{
checkConfig.addAttribute("allowLineBreaks", "false");
final String[] expected = {
"5:14: '.' is followed by whitespace.",
"6:12: '.' is followed by whitespace.",
"29:14: '-' is followed by whitespace.",
"29:21: '+' is followed by whitespace.",
"31:15: '++' is followed by whitespace.",
"31:22: '--' is followed by whitespace.",
"111:22: '!' is followed by whitespace.",
"112:23: '~' is followed by whitespace.",
"129:24: '.' is followed by whitespace.",
"132:11: '.' is followed by whitespace.",
"136:12: '.' is followed by whitespace.",
"5:14: " + getCheckMessage(MSG_KEY, "."),
"6:12: " + getCheckMessage(MSG_KEY, "."),
"29:14: " + getCheckMessage(MSG_KEY, "-"),
"29:21: " + getCheckMessage(MSG_KEY, "+"),
"31:15: " + getCheckMessage(MSG_KEY, "++"),
"31:22: " + getCheckMessage(MSG_KEY, "--"),
"111:22: " + getCheckMessage(MSG_KEY, "!"),
"112:23: " + getCheckMessage(MSG_KEY, "~"),
"129:24: " + getCheckMessage(MSG_KEY, "."),
"132:11: " + getCheckMessage(MSG_KEY, "."),
"136:12: " + getCheckMessage(MSG_KEY, "."),
};
verify(checkConfig, getPath("InputWhitespace.java"), expected);
}
@ -59,9 +61,9 @@ public class NoWhitespaceAfterCheckTest
{
checkConfig.addAttribute("tokens", "DOT");
final String[] expected = {
"5:14: '.' is followed by whitespace.",
"129:24: '.' is followed by whitespace.",
"136:12: '.' is followed by whitespace.",
"5:14: " + getCheckMessage(MSG_KEY, "."),
"129:24: " + getCheckMessage(MSG_KEY, "."),
"136:12: " + getCheckMessage(MSG_KEY, "."),
};
verify(checkConfig, getPath("InputWhitespace.java"), expected);
}
@ -71,9 +73,9 @@ public class NoWhitespaceAfterCheckTest
{
checkConfig.addAttribute("tokens", "TYPECAST");
final String[] expected = {
"87:28: ')' is followed by whitespace.",
"89:23: ')' is followed by whitespace.",
"241:22: ')' is followed by whitespace.",
"87:28: " + getCheckMessage(MSG_KEY, ")"),
"89:23: " + getCheckMessage(MSG_KEY, ")"),
"241:22: " + getCheckMessage(MSG_KEY, ")"),
};
verify(checkConfig, getPath("InputWhitespace.java"), expected);
}
@ -83,22 +85,22 @@ public class NoWhitespaceAfterCheckTest
{
checkConfig.addAttribute("tokens", "ARRAY_DECLARATOR");
final String[] expected = {
"6:11: 'Object' is followed by whitespace.",
"8:22: 'someStuff3' is followed by whitespace.",
"9:8: 'int' is followed by whitespace.",
"10:13: 's' is followed by whitespace.",
"11:13: 'd' is followed by whitespace.",
"16:14: 'get' is followed by whitespace.",
"18:8: 'int' is followed by whitespace.",
"19:34: 'get1' is followed by whitespace.",
"28:8: 'int' is followed by whitespace.",
"29:12: 'cba' is followed by whitespace.",
"31:26: 'String' is followed by whitespace.",
"32:27: 'String' is followed by whitespace.",
"39:11: 'ar' is followed by whitespace.",
"39:24: 'int' is followed by whitespace.",
"40:16: 'int' is followed by whitespace.",
"43:63: 'getLongMultArray' is followed by whitespace.",
"6:11: " + getCheckMessage(MSG_KEY, "Object"),
"8:22: " + getCheckMessage(MSG_KEY, "someStuff3"),
"9:8: " + getCheckMessage(MSG_KEY, "int"),
"10:13: " + getCheckMessage(MSG_KEY, "s"),
"11:13: " + getCheckMessage(MSG_KEY, "d"),
"16:14: " + getCheckMessage(MSG_KEY, "get"),
"18:8: " + getCheckMessage(MSG_KEY, "int"),
"19:34: " + getCheckMessage(MSG_KEY, "get1"),
"28:8: " + getCheckMessage(MSG_KEY, "int"),
"29:12: " + getCheckMessage(MSG_KEY, "cba"),
"31:26: " + getCheckMessage(MSG_KEY, "String"),
"32:27: " + getCheckMessage(MSG_KEY, "String"),
"39:11: " + getCheckMessage(MSG_KEY, "ar"),
"39:24: " + getCheckMessage(MSG_KEY, "int"),
"40:16: " + getCheckMessage(MSG_KEY, "int"),
"43:63: " + getCheckMessage(MSG_KEY, "getLongMultArray"),
};
verify(checkConfig, getPath("whitespace/InputNoWhitespaceAfterArrayDeclarations.java"), expected);
}

View File

@ -23,6 +23,8 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Before;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.NoWhitespaceBeforeCheck.MSG_KEY;
public class NoWhitespaceBeforeCheckTest
extends BaseCheckTestSupport
{
@ -38,14 +40,14 @@ public class NoWhitespaceBeforeCheckTest
public void testDefault() throws Exception
{
final String[] expected = {
"30:14: '++' is preceded with whitespace.",
"30:21: '--' is preceded with whitespace.",
"176:18: ';' is preceded with whitespace.",
"178:23: ';' is preceded with whitespace.",
"185:18: ';' is preceded with whitespace.",
"187:27: ';' is preceded with whitespace.",
"195:26: ';' is preceded with whitespace.",
"211:15: ';' is preceded with whitespace.",
"30:14: " + getCheckMessage(MSG_KEY, "++"),
"30:21: " + getCheckMessage(MSG_KEY, "--"),
"176:18: " + getCheckMessage(MSG_KEY, ";"),
"178:23: " + getCheckMessage(MSG_KEY, ";"),
"185:18: " + getCheckMessage(MSG_KEY, ";"),
"187:27: " + getCheckMessage(MSG_KEY, ";"),
"195:26: " + getCheckMessage(MSG_KEY, ";"),
"211:15: " + getCheckMessage(MSG_KEY, ";"),
};
verify(checkConfig, getPath("InputWhitespace.java"), expected);
}
@ -55,11 +57,11 @@ public class NoWhitespaceBeforeCheckTest
{
checkConfig.addAttribute("tokens", "DOT");
final String[] expected = {
"5:12: '.' is preceded with whitespace.",
"6:4: '.' is preceded with whitespace.",
"129:17: '.' is preceded with whitespace.",
"135:12: '.' is preceded with whitespace.",
"136:10: '.' is preceded with whitespace.",
"5:12: " + getCheckMessage(MSG_KEY, "."),
"6:4: " + getCheckMessage(MSG_KEY, "."),
"129:17: " + getCheckMessage(MSG_KEY, "."),
"135:12: " + getCheckMessage(MSG_KEY, "."),
"136:10: " + getCheckMessage(MSG_KEY, "."),
};
verify(checkConfig, getPath("InputWhitespace.java"), expected);
}
@ -70,9 +72,9 @@ public class NoWhitespaceBeforeCheckTest
checkConfig.addAttribute("tokens", "DOT");
checkConfig.addAttribute("allowLineBreaks", "yes");
final String[] expected = {
"5:12: '.' is preceded with whitespace.",
"129:17: '.' is preceded with whitespace.",
"136:10: '.' is preceded with whitespace.",
"5:12: " + getCheckMessage(MSG_KEY, "."),
"129:17: " + getCheckMessage(MSG_KEY, "."),
"136:10: " + getCheckMessage(MSG_KEY, "."),
};
verify(checkConfig, getPath("InputWhitespace.java"), expected);
}

View File

@ -23,6 +23,9 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Before;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.OperatorWrapCheck.LINE_NEW;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.OperatorWrapCheck.LINE_PREVIOUS;
public class OperatorWrapCheckTest
extends BaseCheckTestSupport
{
@ -39,11 +42,11 @@ public class OperatorWrapCheckTest
throws Exception
{
final String[] expected = {
"15:19: '+' should be on a new line.",
"16:15: '-' should be on a new line.",
"24:18: '&&' should be on a new line.",
"39:30: '&' should be on a new line.",
"52:29: '&' should be on a new line.",
"15:19: " + getCheckMessage(LINE_NEW, "+"),
"16:15: " + getCheckMessage(LINE_NEW, "-"),
"24:18: " + getCheckMessage(LINE_NEW, "&&"),
"39:30: " + getCheckMessage(LINE_NEW, "&"),
"52:29: " + getCheckMessage(LINE_NEW, "&"),
};
verify(checkConfig, getPath("InputOpWrap.java"), expected);
}
@ -54,9 +57,9 @@ public class OperatorWrapCheckTest
{
checkConfig.addAttribute("option", WrapOption.EOL.toString());
final String[] expected = {
"18:13: '-' should be on the previous line.",
"22:13: '&&' should be on the previous line.",
"27:13: '&&' should be on the previous line.",
"18:13: " + getCheckMessage(LINE_PREVIOUS, "-"),
"22:13: " + getCheckMessage(LINE_PREVIOUS, "&&"),
"27:13: " + getCheckMessage(LINE_PREVIOUS, "&&"),
};
verify(checkConfig, getPath("InputOpWrap.java"), expected);
}
@ -68,7 +71,7 @@ public class OperatorWrapCheckTest
checkConfig.addAttribute("tokens", "ASSIGN");
checkConfig.addAttribute("option", WrapOption.EOL.toString());
final String[] expected = {
"33:13: '=' should be on the previous line.",
"33:13: " + getCheckMessage(LINE_PREVIOUS, "="),
};
verify(checkConfig, getPath("InputOpWrap.java"), expected);
}

View File

@ -22,6 +22,13 @@ import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck.WS_FOLLOWED;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck.WS_PRECEDED;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck
.WS_NOT_FOLLOWED;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck
.WS_NOT_PRECEDED;
public class ParenPadCheckTest
extends BaseCheckTestSupport
{
@ -32,13 +39,13 @@ public class ParenPadCheckTest
final DefaultConfiguration checkConfig =
createCheckConfig(ParenPadCheck.class);
final String[] expected = {
"58:12: '(' is followed by whitespace.",
"58:36: ')' is preceded with whitespace.",
"74:13: '(' is followed by whitespace.",
"74:18: ')' is preceded with whitespace.",
"232:27: ')' is preceded with whitespace.",
"241:24: '(' is followed by whitespace.",
"241:30: ')' is preceded with whitespace.",
"58:12: " + getCheckMessage(WS_FOLLOWED, "("),
"58:36: " + getCheckMessage(WS_PRECEDED, ")"),
"74:13: " + getCheckMessage(WS_FOLLOWED, "("),
"74:18: " + getCheckMessage(WS_PRECEDED, ")"),
"232:27: " + getCheckMessage(WS_PRECEDED, ")"),
"241:24: " + getCheckMessage(WS_FOLLOWED, "("),
"241:30: " + getCheckMessage(WS_PRECEDED, ")"),
};
verify(checkConfig, getPath("InputWhitespace.java"), expected);
}
@ -51,31 +58,31 @@ public class ParenPadCheckTest
createCheckConfig(ParenPadCheck.class);
checkConfig.addAttribute("option", PadOption.SPACE.toString());
final String[] expected = {
"29:20: '(' is not followed by whitespace.",
"29:23: ')' is not preceded with whitespace.",
"37:22: '(' is not followed by whitespace.",
"37:26: ')' is not preceded with whitespace.",
"41:15: '(' is not followed by whitespace.",
"41:33: ')' is not preceded with whitespace.",
"76:20: '(' is not followed by whitespace.",
"76:21: ')' is not preceded with whitespace.",
"97:22: '(' is not followed by whitespace.",
"97:28: ')' is not preceded with whitespace.",
"98:14: '(' is not followed by whitespace.",
"98:18: ')' is not preceded with whitespace.",
"150:28: '(' is not followed by whitespace.",
"150:32: ')' is not preceded with whitespace.",
"153:16: '(' is not followed by whitespace.",
"153:20: ')' is not preceded with whitespace.",
"160:21: '(' is not followed by whitespace.",
"160:34: ')' is not preceded with whitespace.",
"162:20: '(' is not followed by whitespace.",
"165:10: ')' is not preceded with whitespace.",
"178:14: '(' is not followed by whitespace.",
"178:36: ')' is not preceded with whitespace.",
"225:14: '(' is not followed by whitespace.",
"235:14: '(' is not followed by whitespace.",
"235:39: ')' is not preceded with whitespace.",
"29:20: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"29:23: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
"37:22: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"37:26: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
"41:15: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"41:33: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
"76:20: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"76:21: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
"97:22: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"97:28: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
"98:14: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"98:18: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
"150:28: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"150:32: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
"153:16: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"153:20: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
"160:21: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"160:34: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
"162:20: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"165:10: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
"178:14: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"178:36: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
"225:14: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"235:14: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"235:39: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
};
verify(checkConfig, getPath("InputWhitespace.java"), expected);
}
@ -87,13 +94,13 @@ public class ParenPadCheckTest
final DefaultConfiguration checkConfig =
createCheckConfig(ParenPadCheck.class);
final String[] expected = {
"17:34: ')' is preceded with whitespace.",
"20:35: ')' is preceded with whitespace.",
"40:14: '(' is followed by whitespace.",
"40:36: ')' is preceded with whitespace.",
"43:14: '(' is followed by whitespace.",
"48:27: ')' is preceded with whitespace.",
"51:26: ')' is preceded with whitespace.",
"17:34: " + getCheckMessage(WS_PRECEDED, ")"),
"20:35: " + getCheckMessage(WS_PRECEDED, ")"),
"40:14: " + getCheckMessage(WS_FOLLOWED, "("),
"40:36: " + getCheckMessage(WS_PRECEDED, ")"),
"43:14: " + getCheckMessage(WS_FOLLOWED, "("),
"48:27: " + getCheckMessage(WS_PRECEDED, ")"),
"51:26: " + getCheckMessage(WS_PRECEDED, ")"),
};
verify(checkConfig, getPath("InputForWhitespace.java"), expected);
}
@ -106,15 +113,15 @@ public class ParenPadCheckTest
createCheckConfig(ParenPadCheck.class);
checkConfig.addAttribute("option", PadOption.SPACE.toString());
final String[] expected = {
"11:14: '(' is not followed by whitespace.",
"11:35: ')' is not preceded with whitespace.",
"14:14: '(' is not followed by whitespace.",
"14:34: ')' is not preceded with whitespace.",
"17:14: '(' is not followed by whitespace.",
"20:14: '(' is not followed by whitespace.",
"23:14: '(' is not followed by whitespace.",
"27:14: '(' is not followed by whitespace.",
"32:14: '(' is not followed by whitespace.",
"11:14: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"11:35: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
"14:14: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"14:34: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
"17:14: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"20:14: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"23:14: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"27:14: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"32:14: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
};
verify(checkConfig, getPath("InputForWhitespace.java"), expected);
}

View File

@ -23,6 +23,9 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Before;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.SeparatorWrapCheck.LINE_NEW;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.SeparatorWrapCheck.LINE_PREVIOUS;
public class SeparatorWrapCheckTest
extends BaseCheckTestSupport
{
@ -41,7 +44,7 @@ public class SeparatorWrapCheckTest
checkConfig.addAttribute("option", "NL");
checkConfig.addAttribute("tokens", "DOT");
final String[] expected = {
"31:10: '.' should be on a new line.",
"31:10: " + getCheckMessage(LINE_NEW, "."),
};
verify(checkConfig, getPath("whitespace/InputSeparatorWrap.java"), expected);
}
@ -52,7 +55,7 @@ public class SeparatorWrapCheckTest
checkConfig.addAttribute("option", "EOL");
checkConfig.addAttribute("tokens", "COMMA");
final String[] expected = {
"39:17: ',' should be on the previous line.",
"39:17: " + getCheckMessage(LINE_PREVIOUS, ","),
};
verify(checkConfig, getPath("whitespace/InputSeparatorWrap.java"), expected);
}

View File

@ -22,6 +22,13 @@ import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck.WS_FOLLOWED;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck.WS_PRECEDED;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck
.WS_NOT_FOLLOWED;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.AbstractParenPadCheck
.WS_NOT_PRECEDED;
public class TypecastParenPadCheckTest
extends BaseCheckTestSupport
{
@ -32,8 +39,8 @@ public class TypecastParenPadCheckTest
final DefaultConfiguration checkConfig =
createCheckConfig(TypecastParenPadCheck.class);
final String[] expected = {
"89:14: '(' is followed by whitespace.",
"89:21: ')' is preceded with whitespace.",
"89:14: " + getCheckMessage(WS_FOLLOWED, "("),
"89:21: " + getCheckMessage(WS_PRECEDED, ")"),
};
verify(checkConfig, getPath("InputWhitespace.java"), expected);
}
@ -46,14 +53,14 @@ public class TypecastParenPadCheckTest
createCheckConfig(TypecastParenPadCheck.class);
checkConfig.addAttribute("option", PadOption.SPACE.toString());
final String[] expected = {
"87:21: '(' is not followed by whitespace.",
"87:27: ')' is not preceded with whitespace.",
"88:14: '(' is not followed by whitespace.",
"88:20: ')' is not preceded with whitespace.",
"90:14: '(' is not followed by whitespace.",
"90:20: ')' is not preceded with whitespace.",
"241:18: '(' is not followed by whitespace.",
"241:21: ')' is not preceded with whitespace.",
"87:21: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"87:27: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
"88:14: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"88:20: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
"90:14: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"90:20: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
"241:18: " + getCheckMessage(WS_NOT_FOLLOWED, "("),
"241:21: " + getCheckMessage(WS_NOT_PRECEDED, ")"),
};
verify(checkConfig, getPath("InputWhitespace.java"), expected);
}

View File

@ -23,6 +23,9 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Before;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAfterCheck
.WS_NOT_FOLLOWED;
public class WhitespaceAfterCheckTest
extends BaseCheckTestSupport
{
@ -38,8 +41,8 @@ public class WhitespaceAfterCheckTest
public void testDefault() throws Exception
{
final String[] expected = {
"42:40: ',' is not followed by whitespace.",
"71:30: ',' is not followed by whitespace.",
"42:40: " + getCheckMessage(WS_NOT_FOLLOWED, ","),
"71:30: " + getCheckMessage(WS_NOT_FOLLOWED, ","),
};
verify(checkConfig, getPath("InputSimple.java"), expected);
}
@ -48,7 +51,7 @@ public class WhitespaceAfterCheckTest
public void testCast() throws Exception
{
final String[] expected = {
"88:21: 'cast' is not followed by whitespace.",
"88:21: " + getCheckMessage(WS_NOT_FOLLOWED, "cast"),
};
verify(checkConfig, getPath("InputWhitespace.java"), expected);
}
@ -57,9 +60,9 @@ public class WhitespaceAfterCheckTest
public void testSemi() throws Exception
{
final String[] expected = {
"58:23: ';' is not followed by whitespace.",
"58:29: ';' is not followed by whitespace.",
"107:19: ';' is not followed by whitespace.",
"58:23: " + getCheckMessage(WS_NOT_FOLLOWED, ";"),
"58:29: " + getCheckMessage(WS_NOT_FOLLOWED, ";"),
"107:19: " + getCheckMessage(WS_NOT_FOLLOWED, ";"),
};
verify(checkConfig, getPath("InputBraces.java"), expected);
}
@ -68,8 +71,8 @@ public class WhitespaceAfterCheckTest
public void testEmptyForIterator() throws Exception
{
final String[] expected = {
"14:31: ';' is not followed by whitespace.",
"17:31: ';' is not followed by whitespace.",
"14:31: " + getCheckMessage(WS_NOT_FOLLOWED, ";"),
"17:31: " + getCheckMessage(WS_NOT_FOLLOWED, ";"),
};
verify(checkConfig, getPath("InputForWhitespace.java"), expected);
}
@ -78,9 +81,9 @@ public class WhitespaceAfterCheckTest
public void testTypeArgumentAndParameterCommas() throws Exception
{
final String[] expected = {
"11:21: ',' is not followed by whitespace.",
"11:23: ',' is not followed by whitespace.",
"11:41: ',' is not followed by whitespace.",
"11:21: " + getCheckMessage(WS_NOT_FOLLOWED, ","),
"11:23: " + getCheckMessage(WS_NOT_FOLLOWED, ","),
"11:41: " + getCheckMessage(WS_NOT_FOLLOWED, ","),
};
verify(checkConfig, getPath("InputGenerics.java"), expected);
}

View File

@ -23,6 +23,11 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import org.junit.Before;
import org.junit.Test;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck.
WS_NOT_FOLLOWED;
import static com.puppycrawl.tools.checkstyle.checks.whitespace.WhitespaceAroundCheck.
WS_NOT_PRECEDED;
public class WhitespaceAroundTest
extends BaseCheckTestSupport
{
@ -39,41 +44,41 @@ public class WhitespaceAroundTest
throws Exception
{
final String[] expected = {
"16:22: '=' is not preceded with whitespace.",
"16:23: '=' is not followed by whitespace.",
"18:24: '=' is not followed by whitespace.",
"26:14: '=' is not preceded with whitespace.",
"27:10: '=' is not preceded with whitespace.",
"27:11: '=' is not followed by whitespace.",
"28:10: '+=' is not preceded with whitespace.",
"28:12: '+=' is not followed by whitespace.",
"29:13: '-=' is not followed by whitespace.",
"37:21: 'synchronized' is not followed by whitespace.",
"39:12: 'try' is not followed by whitespace.",
"39:12: '{' is not preceded with whitespace.",
"41:14: 'catch' is not followed by whitespace.",
"41:34: '{' is not preceded with whitespace.",
"58:11: 'if' is not followed by whitespace.",
"76:19: 'return' is not followed by whitespace.",
"97:29: '?' is not preceded with whitespace.",
"97:30: '?' is not followed by whitespace.",
"97:34: ':' is not preceded with whitespace.",
"97:35: ':' is not followed by whitespace.",
"98:15: '==' is not preceded with whitespace.",
"98:17: '==' is not followed by whitespace.",
"104:20: '*' is not followed by whitespace.",
"104:21: '*' is not preceded with whitespace.",
"119:18: '%' is not preceded with whitespace.",
"120:20: '%' is not followed by whitespace.",
"121:18: '%' is not preceded with whitespace.",
"121:19: '%' is not followed by whitespace.",
"123:18: '/' is not preceded with whitespace.",
"124:20: '/' is not followed by whitespace.",
"125:18: '/' is not preceded with whitespace.",
"125:19: '/' is not followed by whitespace.",
"153:15: 'assert' is not followed by whitespace.",
"156:20: ':' is not preceded with whitespace.",
"156:21: ':' is not followed by whitespace.",
"16:22: " + getCheckMessage(WS_NOT_PRECEDED, "="),
"16:23: " + getCheckMessage(WS_NOT_FOLLOWED, "="),
"18:24: " + getCheckMessage(WS_NOT_FOLLOWED, "="),
"26:14: " + getCheckMessage(WS_NOT_PRECEDED, "="),
"27:10: " + getCheckMessage(WS_NOT_PRECEDED, "="),
"27:11: " + getCheckMessage(WS_NOT_FOLLOWED, "="),
"28:10: " + getCheckMessage(WS_NOT_PRECEDED, "+="),
"28:12: " + getCheckMessage(WS_NOT_FOLLOWED, "+="),
"29:13: " + getCheckMessage(WS_NOT_FOLLOWED, "-="),
"37:21: " + getCheckMessage(WS_NOT_FOLLOWED, "synchronized"),
"39:12: " + getCheckMessage(WS_NOT_FOLLOWED, "try"),
"39:12: " + getCheckMessage(WS_NOT_PRECEDED, "{"),
"41:14: " + getCheckMessage(WS_NOT_FOLLOWED, "catch"),
"41:34: " + getCheckMessage(WS_NOT_PRECEDED, "{"),
"58:11: " + getCheckMessage(WS_NOT_FOLLOWED, "if"),
"76:19: " + getCheckMessage(WS_NOT_FOLLOWED, "return"),
"97:29: " + getCheckMessage(WS_NOT_PRECEDED, "?"),
"97:30: " + getCheckMessage(WS_NOT_FOLLOWED, "?"),
"97:34: " + getCheckMessage(WS_NOT_PRECEDED, ":"),
"97:35: " + getCheckMessage(WS_NOT_FOLLOWED, ":"),
"98:15: " + getCheckMessage(WS_NOT_PRECEDED, "=="),
"98:17: " + getCheckMessage(WS_NOT_FOLLOWED, "=="),
"104:20: " + getCheckMessage(WS_NOT_FOLLOWED, "*"),
"104:21: " + getCheckMessage(WS_NOT_PRECEDED, "*"),
"119:18: " + getCheckMessage(WS_NOT_PRECEDED, "%"),
"120:20: " + getCheckMessage(WS_NOT_FOLLOWED, "%"),
"121:18: " + getCheckMessage(WS_NOT_PRECEDED, "%"),
"121:19: " + getCheckMessage(WS_NOT_FOLLOWED, "%"),
"123:18: " + getCheckMessage(WS_NOT_PRECEDED, "/"),
"124:20: " + getCheckMessage(WS_NOT_FOLLOWED, "/"),
"125:18: " + getCheckMessage(WS_NOT_PRECEDED, "/"),
"125:19: " + getCheckMessage(WS_NOT_FOLLOWED, "/"),
"153:15: " + getCheckMessage(WS_NOT_FOLLOWED, "assert"),
"156:20: " + getCheckMessage(WS_NOT_PRECEDED, ":"),
"156:21: " + getCheckMessage(WS_NOT_FOLLOWED, ":"),
};
verify(checkConfig, getPath("InputWhitespace.java"), expected);
}
@ -83,12 +88,12 @@ public class WhitespaceAroundTest
throws Exception
{
final String[] expected = {
"153:27: '=' is not followed by whitespace.",
"154:27: '=' is not followed by whitespace.",
"155:27: '=' is not followed by whitespace.",
"156:27: '=' is not followed by whitespace.",
"157:27: '=' is not followed by whitespace.",
"158:27: '=' is not followed by whitespace.",
"153:27: " + getCheckMessage(WS_NOT_FOLLOWED, "="),
"154:27: " + getCheckMessage(WS_NOT_FOLLOWED, "="),
"155:27: " + getCheckMessage(WS_NOT_FOLLOWED, "="),
"156:27: " + getCheckMessage(WS_NOT_FOLLOWED, "="),
"157:27: " + getCheckMessage(WS_NOT_FOLLOWED, "="),
"158:27: " + getCheckMessage(WS_NOT_FOLLOWED, "="),
};
verify(checkConfig, getPath("InputSimple.java"), expected);
}
@ -98,14 +103,14 @@ public class WhitespaceAroundTest
throws Exception
{
final String[] expected = {
"41:14: 'while' is not followed by whitespace.",
"58:12: 'for' is not followed by whitespace.",
"41:14: " + getCheckMessage(WS_NOT_FOLLOWED, "while"),
"58:12: " + getCheckMessage(WS_NOT_FOLLOWED, "for"),
// + ":58:23: ';' is not followed by whitespace.",
// + ":58:29: ';' is not followed by whitespace.",
"115:27: '{' is not followed by whitespace.",
"115:27: '}' is not preceded with whitespace.",
"118:40: '{' is not followed by whitespace.",
"118:40: '}' is not preceded with whitespace.",
"115:27: " + getCheckMessage(WS_NOT_FOLLOWED, "{"),
"115:27: " + getCheckMessage(WS_NOT_PRECEDED, "}"),
"118:40: " + getCheckMessage(WS_NOT_FOLLOWED, "{"),
"118:40: " + getCheckMessage(WS_NOT_PRECEDED, "}"),
};
verify(checkConfig, getPath("InputBraces.java"), expected);
}
@ -117,8 +122,8 @@ public class WhitespaceAroundTest
checkConfig.addAttribute("allowEmptyMethods", "true");
checkConfig.addAttribute("allowEmptyConstructors", "true");
final String[] expected = {
"41:14: 'while' is not followed by whitespace.",
"58:12: 'for' is not followed by whitespace.",
"41:14: " + getCheckMessage(WS_NOT_FOLLOWED, "while"),
"58:12: " + getCheckMessage(WS_NOT_FOLLOWED, "for"),
};
verify(checkConfig, getPath("InputBraces.java"), expected);
}
@ -128,8 +133,8 @@ public class WhitespaceAroundTest
throws Exception
{
final String[] expected = {
"6:67: '&' is not preceded with whitespace.",
"6:68: '&' is not followed by whitespace.",
"6:67: " + getCheckMessage(WS_NOT_PRECEDED, "&"),
"6:68: " + getCheckMessage(WS_NOT_FOLLOWED, "&"),
};
verify(checkConfig, getPath("InputGenerics.java"), expected);
}
@ -148,7 +153,7 @@ public class WhitespaceAroundTest
{
checkConfig.addAttribute("ignoreEnhancedForColon", "false");
final String[] expected = {
"19:20: ':' is not preceded with whitespace.",
"19:20: " + getCheckMessage(WS_NOT_PRECEDED, ":"),
};
verify(checkConfig, getPath("whitespace/InputWhitespaceAround.java"),
expected);
@ -159,12 +164,12 @@ public class WhitespaceAroundTest
{
checkConfig.addAttribute("allowEmptyTypes", "true");
final String[] expected = {
"29:95: '{' is not followed by whitespace.",
"29:95: '}' is not preceded with whitespace.",
"30:33: '{' is not followed by whitespace.",
"30:33: '}' is not preceded with whitespace.",
"31:21: '{' is not followed by whitespace.",
"31:21: '}' is not preceded with whitespace.",
"29:95: " + getCheckMessage(WS_NOT_FOLLOWED, "{"),
"29:95: " + getCheckMessage(WS_NOT_PRECEDED, "}"),
"30:33: " + getCheckMessage(WS_NOT_FOLLOWED, "{"),
"30:33: " + getCheckMessage(WS_NOT_PRECEDED, "}"),
"31:21: " + getCheckMessage(WS_NOT_FOLLOWED, "{"),
"31:21: " + getCheckMessage(WS_NOT_PRECEDED, "}"),
};
verify(checkConfig, getPath("whitespace/InputEmptyTypesAndCycles.java"),
expected);
@ -175,16 +180,16 @@ public class WhitespaceAroundTest
{
checkConfig.addAttribute("allowEmptyLoops", "true");
final String[] expected = {
"40:65: '{' is not followed by whitespace.",
"40:65: '}' is not preceded with whitespace.",
"42:17: '{' is not followed by whitespace.",
"42:17: '}' is not preceded with whitespace.",
"44:20: '{' is not followed by whitespace.",
"44:20: '}' is not preceded with whitespace.",
"50:44: '{' is not followed by whitespace.",
"50:44: '}' is not preceded with whitespace.",
"60:18: '{' is not followed by whitespace.",
"60:18: '}' is not preceded with whitespace.",
"40:65: " + getCheckMessage(WS_NOT_FOLLOWED, "{"),
"40:65: " + getCheckMessage(WS_NOT_PRECEDED, "}"),
"42:17: " + getCheckMessage(WS_NOT_FOLLOWED, "{"),
"42:17: " + getCheckMessage(WS_NOT_PRECEDED, "}"),
"44:20: " + getCheckMessage(WS_NOT_FOLLOWED, "{"),
"44:20: " + getCheckMessage(WS_NOT_PRECEDED, "}"),
"50:44: " + getCheckMessage(WS_NOT_FOLLOWED, "{"),
"50:44: " + getCheckMessage(WS_NOT_PRECEDED, "}"),
"60:18: " + getCheckMessage(WS_NOT_FOLLOWED, "{"),
"60:18: " + getCheckMessage(WS_NOT_PRECEDED, "}"),
};
verify(checkConfig, getPath("whitespace/InputEmptyTypesAndCycles.java"),
expected);
@ -194,7 +199,7 @@ public class WhitespaceAroundTest
public void testSwitchWhitespaceAround() throws Exception
{
final String[] expected = {
"6:15: 'switch' is not followed by whitespace.",
"6:15: " + getCheckMessage(WS_NOT_FOLLOWED, "switch"),
};
verify(checkConfig,
getPath("whitespace/InputSwitchWhitespaceAround.java"),
@ -205,7 +210,7 @@ public class WhitespaceAroundTest
public void testDoWhileWhitespaceAround() throws Exception
{
final String[] expected = {
"9:16: 'while' is not followed by whitespace.",
"9:16: " + getCheckMessage(WS_NOT_FOLLOWED, "while"),
};
verify(checkConfig,
getPath("whitespace/InputDoWhileWhitespaceAround.java"),