Issue #537 refactored tests from blocks package.
This commit is contained in:
parent
f0326fd4c8
commit
abe8ae60ee
|
|
@ -92,6 +92,12 @@ public class AvoidNestedBlocksCheck extends Check
|
|||
*/
|
||||
private boolean mAllowInSwitchCase;
|
||||
|
||||
/**
|
||||
* A key is pointing to the warning message text in "messages.properties"
|
||||
* file.
|
||||
*/
|
||||
public static final String MSG_KEY_BLOCK_NESTED = "block.nested";
|
||||
|
||||
@Override
|
||||
public int[] getDefaultTokens()
|
||||
{
|
||||
|
|
@ -109,7 +115,7 @@ public class AvoidNestedBlocksCheck extends Check
|
|||
{
|
||||
return;
|
||||
}
|
||||
log(aAST.getLineNo(), aAST.getColumnNo(), "block.nested");
|
||||
log(aAST.getLineNo(), aAST.getColumnNo(), MSG_KEY_BLOCK_NESTED);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -61,6 +61,18 @@ import com.puppycrawl.tools.checkstyle.checks.AbstractOptionCheck;
|
|||
public class EmptyBlockCheck
|
||||
extends AbstractOptionCheck<BlockOption>
|
||||
{
|
||||
/**
|
||||
* A key is pointing to the warning message text in "messages.properties"
|
||||
* file.
|
||||
*/
|
||||
public static final String MSG_KEY_BLOCK_NO_STMT = "block.noStmt";
|
||||
|
||||
/**
|
||||
* A key is pointing to the warning message text in "messages.properties"
|
||||
* file.
|
||||
*/
|
||||
public static final String MSG_KEY_BLOCK_EMPTY = "block.empty";
|
||||
|
||||
/**
|
||||
* Creates a new <code>EmptyBlockCheck</code> instance.
|
||||
*/
|
||||
|
|
@ -106,7 +118,7 @@ public class EmptyBlockCheck
|
|||
if (emptyBlock) {
|
||||
log(leftCurly.getLineNo(),
|
||||
leftCurly.getColumnNo(),
|
||||
"block.noStmt",
|
||||
MSG_KEY_BLOCK_NO_STMT,
|
||||
aAST.getText());
|
||||
}
|
||||
}
|
||||
|
|
@ -115,7 +127,7 @@ public class EmptyBlockCheck
|
|||
{
|
||||
log(leftCurly.getLineNo(),
|
||||
leftCurly.getColumnNo(),
|
||||
"block.empty",
|
||||
MSG_KEY_BLOCK_EMPTY,
|
||||
aAST.getText());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,24 @@ public class LeftCurlyCheck
|
|||
/** default maximum line length */
|
||||
private static final int DEFAULT_MAX_LINE_LENGTH = 80;
|
||||
|
||||
/**
|
||||
* A key is pointing to the warning message text in "messages.properties"
|
||||
* file.
|
||||
*/
|
||||
public static final String MSG_KEY_LINE_NEW = "line.new";
|
||||
|
||||
/**
|
||||
* A key is pointing to the warning message text in "messages.properties"
|
||||
* file.
|
||||
*/
|
||||
public static final String MSG_KEY_LINE_PREVIOUS = "line.previous";
|
||||
|
||||
/**
|
||||
* A key is pointing to the warning message text in "messages.properties"
|
||||
* file.
|
||||
*/
|
||||
public static final String MSG_KEY_LINE_BREAK_AFTER = "line.break.after";
|
||||
|
||||
/** TODO: replace this ugly hack **/
|
||||
private int mMaxLineLength = DEFAULT_MAX_LINE_LENGTH;
|
||||
|
||||
|
|
@ -271,7 +289,7 @@ public class LeftCurlyCheck
|
|||
else if (getAbstractOption() == LeftCurlyOption.NL) {
|
||||
if (!Utils.whitespaceBefore(aBrace.getColumnNo(), braceLine)) {
|
||||
log(aBrace.getLineNo(), aBrace.getColumnNo(),
|
||||
"line.new", "{");
|
||||
MSG_KEY_LINE_NEW, "{");
|
||||
}
|
||||
}
|
||||
else if (getAbstractOption() == LeftCurlyOption.EOL) {
|
||||
|
|
@ -279,10 +297,10 @@ public class LeftCurlyCheck
|
|||
&& ((prevLineLen + 2) <= mMaxLineLength))
|
||||
{
|
||||
log(aBrace.getLineNo(), aBrace.getColumnNo(),
|
||||
"line.previous", "{");
|
||||
MSG_KEY_LINE_PREVIOUS, "{");
|
||||
}
|
||||
if (!hasLineBreakAfter(aBrace)) {
|
||||
log(aBrace.getLineNo(), aBrace.getColumnNo(), "line.break.after");
|
||||
log(aBrace.getLineNo(), aBrace.getColumnNo(), MSG_KEY_LINE_BREAK_AFTER);
|
||||
}
|
||||
}
|
||||
else if (getAbstractOption() == LeftCurlyOption.NLOW) {
|
||||
|
|
@ -292,16 +310,16 @@ public class LeftCurlyCheck
|
|||
else if ((aStartToken.getLineNo() + 1) == aBrace.getLineNo()) {
|
||||
if (!Utils.whitespaceBefore(aBrace.getColumnNo(), braceLine)) {
|
||||
log(aBrace.getLineNo(), aBrace.getColumnNo(),
|
||||
"line.new", "{");
|
||||
MSG_KEY_LINE_NEW, "{");
|
||||
}
|
||||
else if ((prevLineLen + 2) <= mMaxLineLength) {
|
||||
log(aBrace.getLineNo(), aBrace.getColumnNo(),
|
||||
"line.previous", "{");
|
||||
MSG_KEY_LINE_PREVIOUS, "{");
|
||||
}
|
||||
}
|
||||
else if (!Utils.whitespaceBefore(aBrace.getColumnNo(), braceLine)) {
|
||||
log(aBrace.getLineNo(), aBrace.getColumnNo(),
|
||||
"line.new", "{");
|
||||
MSG_KEY_LINE_NEW, "{");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,6 +69,12 @@ public class NeedBracesCheck extends Check
|
|||
*/
|
||||
private boolean mAllowSingleLineIf;
|
||||
|
||||
/**
|
||||
* A key is pointing to the warning message text in "messages.properties"
|
||||
* file.
|
||||
*/
|
||||
public static final String MSG_KEY_NEED_BRACES = "needBraces";
|
||||
|
||||
/**
|
||||
* Setter.
|
||||
* @param aAllowSingleLineIf Check's option for skipping single-line if-statements
|
||||
|
|
@ -105,7 +111,7 @@ public class NeedBracesCheck extends Check
|
|||
skipStatement = isSkipIfBlock(aAST);
|
||||
}
|
||||
if ((slistAST == null) && !isElseIf && !skipStatement) {
|
||||
log(aAST.getLineNo(), "needBraces", aAST.getText());
|
||||
log(aAST.getLineNo(), MSG_KEY_NEED_BRACES, aAST.getText());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,6 +75,30 @@ public class RightCurlyCheck extends AbstractOptionCheck<RightCurlyOption>
|
|||
/** Do we need to check if rculry starts line. */
|
||||
private boolean mShouldStartLine = true;
|
||||
|
||||
/**
|
||||
* A key is pointing to the warning message text in "messages.properties"
|
||||
* file.
|
||||
*/
|
||||
public static final String MSG_KEY_LINE_BREAK_BEFORE = "line.break.before";
|
||||
|
||||
/**
|
||||
* A key is pointing to the warning message text in "messages.properties"
|
||||
* file.
|
||||
*/
|
||||
public static final String MSG_KEY_LINE_ALONE = "line.alone";
|
||||
|
||||
/**
|
||||
* A key is pointing to the warning message text in "messages.properties"
|
||||
* file.
|
||||
*/
|
||||
public static final String MSG_KEY_LINE_SAME = "line.same";
|
||||
|
||||
/**
|
||||
* A key is pointing to the warning message text in "messages.properties"
|
||||
* file.
|
||||
*/
|
||||
public static final String MSG_KEY_LINE_NEW = "line.new";
|
||||
|
||||
/**
|
||||
* Sets the right curly option to same.
|
||||
*/
|
||||
|
|
@ -209,24 +233,24 @@ public class RightCurlyCheck extends AbstractOptionCheck<RightCurlyOption>
|
|||
}
|
||||
|
||||
if (getAbstractOption() == RightCurlyOption.SAME && !hasLineBreakBefore(rcurly)) {
|
||||
log(rcurly, "line.break.before");
|
||||
log(rcurly, MSG_KEY_LINE_BREAK_BEFORE);
|
||||
}
|
||||
|
||||
if (shouldCheckLastRcurly) {
|
||||
if (rcurly.getLineNo() == nextToken.getLineNo()) {
|
||||
log(rcurly, "line.alone", "}");
|
||||
log(rcurly, MSG_KEY_LINE_ALONE, "}");
|
||||
}
|
||||
}
|
||||
else if ((getAbstractOption() == RightCurlyOption.SAME)
|
||||
&& (rcurly.getLineNo() != nextToken.getLineNo()))
|
||||
{
|
||||
log(rcurly, "line.same", "}");
|
||||
log(rcurly, MSG_KEY_LINE_SAME, "}");
|
||||
}
|
||||
else if ((getAbstractOption() == RightCurlyOption.ALONE)
|
||||
&& (rcurly.getLineNo() == nextToken.getLineNo())
|
||||
&& !isEmptyBody(lcurly))
|
||||
{
|
||||
log(rcurly, "line.alone", "}");
|
||||
log(rcurly, MSG_KEY_LINE_ALONE, "}");
|
||||
}
|
||||
|
||||
if (!mShouldStartLine) {
|
||||
|
|
@ -237,7 +261,7 @@ public class RightCurlyCheck extends AbstractOptionCheck<RightCurlyOption>
|
|||
getLines()[rcurly.getLineNo() - 1]);
|
||||
|
||||
if (!startsLine && (lcurly.getLineNo() != rcurly.getLineNo())) {
|
||||
log(rcurly, "line.new", "}");
|
||||
log(rcurly, MSG_KEY_LINE_NEW, "}");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.blocks.AvoidNestedBlocksCheck.MSG_KEY_BLOCK_NESTED;
|
||||
|
||||
public class AvoidNestedBlocksCheckTest
|
||||
extends BaseCheckTestSupport
|
||||
{
|
||||
|
|
@ -32,10 +34,10 @@ public class AvoidNestedBlocksCheckTest
|
|||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(AvoidNestedBlocksCheck.class);
|
||||
final String[] expected = {
|
||||
"22:9: Avoid nested blocks.",
|
||||
"44:17: Avoid nested blocks.",
|
||||
"50:17: Avoid nested blocks.",
|
||||
"58:17: Avoid nested blocks.",
|
||||
"22:9: " + getCheckMessage(MSG_KEY_BLOCK_NESTED),
|
||||
"44:17: " + getCheckMessage(MSG_KEY_BLOCK_NESTED),
|
||||
"50:17: " + getCheckMessage(MSG_KEY_BLOCK_NESTED),
|
||||
"58:17: " + getCheckMessage(MSG_KEY_BLOCK_NESTED),
|
||||
};
|
||||
verify(checkConfig, getPath("InputNestedBlocks.java"), expected);
|
||||
}
|
||||
|
|
@ -49,9 +51,9 @@ public class AvoidNestedBlocksCheckTest
|
|||
checkConfig.addAttribute("allowInSwitchCase", Boolean.TRUE.toString());
|
||||
|
||||
final String[] expected = {
|
||||
"22:9: Avoid nested blocks.",
|
||||
"44:17: Avoid nested blocks.",
|
||||
"58:17: Avoid nested blocks.",
|
||||
"22:9: " + getCheckMessage(MSG_KEY_BLOCK_NESTED),
|
||||
"44:17: " + getCheckMessage(MSG_KEY_BLOCK_NESTED),
|
||||
"58:17: " + getCheckMessage(MSG_KEY_BLOCK_NESTED),
|
||||
};
|
||||
verify(checkConfig, getPath("InputNestedBlocks.java"), expected);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck.MSG_KEY_BLOCK_EMPTY;
|
||||
import static com.puppycrawl.tools.checkstyle.checks.blocks.EmptyBlockCheck.MSG_KEY_BLOCK_NO_STMT;
|
||||
|
||||
public class EmptyBlockCheckTest
|
||||
extends BaseCheckTestSupport
|
||||
{
|
||||
|
|
@ -33,16 +36,16 @@ public class EmptyBlockCheckTest
|
|||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(EmptyBlockCheck.class);
|
||||
final String[] expected = {
|
||||
"52:65: Must have at least one statement.",
|
||||
"54:41: Must have at least one statement.",
|
||||
"71:38: Must have at least one statement.",
|
||||
"72:52: Must have at least one statement.",
|
||||
"73:45: Must have at least one statement.",
|
||||
"75:13: Must have at least one statement.",
|
||||
"77:17: Must have at least one statement.",
|
||||
"79:13: Must have at least one statement.",
|
||||
"82:17: Must have at least one statement.",
|
||||
"178:5: Must have at least one statement.",
|
||||
"52:65: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"54:41: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"71:38: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"72:52: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"73:45: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"75:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"77:17: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"79:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"82:17: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"178:5: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
};
|
||||
verify(checkConfig, getPath("InputSemantic.java"), expected);
|
||||
}
|
||||
|
|
@ -55,12 +58,12 @@ public class EmptyBlockCheckTest
|
|||
createCheckConfig(EmptyBlockCheck.class);
|
||||
checkConfig.addAttribute("option", BlockOption.TEXT.toString());
|
||||
final String[] expected = {
|
||||
"52:65: Empty catch block.",
|
||||
"72:52: Empty catch block.",
|
||||
"73:45: Empty catch block.",
|
||||
"75:13: Empty try block.",
|
||||
"77:17: Empty finally block.",
|
||||
"178:5: Empty INSTANCE_INIT block.",
|
||||
"52:65: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "catch"),
|
||||
"72:52: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "catch"),
|
||||
"73:45: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "catch"),
|
||||
"75:13: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "try"),
|
||||
"77:17: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "finally"),
|
||||
"178:5: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "INSTANCE_INIT"),
|
||||
};
|
||||
verify(checkConfig, getPath("InputSemantic.java"), expected);
|
||||
}
|
||||
|
|
@ -73,16 +76,16 @@ public class EmptyBlockCheckTest
|
|||
createCheckConfig(EmptyBlockCheck.class);
|
||||
checkConfig.addAttribute("option", BlockOption.STMT.toString());
|
||||
final String[] expected = {
|
||||
"52:65: Must have at least one statement.",
|
||||
"54:41: Must have at least one statement.",
|
||||
"71:38: Must have at least one statement.",
|
||||
"72:52: Must have at least one statement.",
|
||||
"73:45: Must have at least one statement.",
|
||||
"75:13: Must have at least one statement.",
|
||||
"77:17: Must have at least one statement.",
|
||||
"79:13: Must have at least one statement.",
|
||||
"82:17: Must have at least one statement.",
|
||||
"178:5: Must have at least one statement.",
|
||||
"52:65: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"54:41: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"71:38: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"72:52: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"73:45: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"75:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"77:17: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"79:13: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"82:17: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"178:5: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
};
|
||||
verify(checkConfig, getPath("InputSemantic.java"), expected);
|
||||
}
|
||||
|
|
@ -97,10 +100,10 @@ public class EmptyBlockCheckTest
|
|||
+ "LITERAL_FINALLY, LITERAL_DO, LITERAL_IF,"
|
||||
+ "LITERAL_ELSE, INSTANCE_INIT, STATIC_INIT, LITERAL_SWITCH");
|
||||
final String[] expected = {
|
||||
"16:29: Must have at least one statement.",
|
||||
"19:42: Must have at least one statement.",
|
||||
"22:29: Must have at least one statement.",
|
||||
"23:28: Must have at least one statement.",
|
||||
"16:29: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"19:42: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"22:29: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
"23:28: " + getCheckMessage(MSG_KEY_BLOCK_NO_STMT),
|
||||
};
|
||||
verify(checkConfig, getPath("InputSemantic2.java"), expected);
|
||||
}
|
||||
|
|
@ -115,10 +118,10 @@ public class EmptyBlockCheckTest
|
|||
+ "LITERAL_FINALLY, LITERAL_DO, LITERAL_IF,"
|
||||
+ "LITERAL_ELSE, INSTANCE_INIT, STATIC_INIT, LITERAL_SWITCH");
|
||||
final String[] expected = {
|
||||
"16:29: Empty if block.",
|
||||
"19:42: Empty if block.",
|
||||
"22:29: Empty if block.",
|
||||
"23:28: Empty switch block.",
|
||||
"16:29: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "if"),
|
||||
"19:42: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "if"),
|
||||
"22:29: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "if"),
|
||||
"23:28: " + getCheckMessage(MSG_KEY_BLOCK_EMPTY, "switch"),
|
||||
};
|
||||
verify(checkConfig, getPath("InputSemantic2.java"), expected);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,10 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck.MSG_KEY_LINE_BREAK_AFTER;
|
||||
import static com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck.MSG_KEY_LINE_NEW;
|
||||
import static com.puppycrawl.tools.checkstyle.checks.blocks.LeftCurlyCheck.MSG_KEY_LINE_PREVIOUS;
|
||||
|
||||
public class LeftCurlyCheckTest extends BaseCheckTestSupport
|
||||
{
|
||||
private DefaultConfiguration mCheckConfig;
|
||||
|
|
@ -37,11 +41,11 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport
|
|||
public void testDefault() throws Exception
|
||||
{
|
||||
final String[] expected = {
|
||||
"8:1: '{' should be on the previous line.",
|
||||
"12:5: '{' should be on the previous line.",
|
||||
"21:5: '{' should be on the previous line.",
|
||||
"30:5: '{' should be on the previous line.",
|
||||
"39:5: '{' should be on the previous line.",
|
||||
"8:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"12:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"21:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"30:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"39:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputScopeInnerInterfaces.java"), expected);
|
||||
}
|
||||
|
|
@ -51,12 +55,12 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport
|
|||
{
|
||||
mCheckConfig.addAttribute("option", LeftCurlyOption.NL.toString());
|
||||
final String[] expected = {
|
||||
"49:14: '{' should be on a new line.",
|
||||
"53:14: '{' should be on a new line.",
|
||||
"58:18: '{' should be on a new line.",
|
||||
"62:18: '{' should be on a new line.",
|
||||
"67:12: '{' should be on a new line.",
|
||||
"72:18: '{' should be on a new line.",
|
||||
"49:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"53:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"58:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"62:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"67:12: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"72:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputScopeInnerInterfaces.java"), expected);
|
||||
}
|
||||
|
|
@ -66,17 +70,17 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport
|
|||
{
|
||||
mCheckConfig.addAttribute("option", LeftCurlyOption.NLOW.toString());
|
||||
final String[] expected = {
|
||||
"8:1: '{' should be on the previous line.",
|
||||
"12:5: '{' should be on the previous line.",
|
||||
"21:5: '{' should be on the previous line.",
|
||||
"30:5: '{' should be on the previous line.",
|
||||
"39:5: '{' should be on the previous line.",
|
||||
"49:14: '{' should be on a new line.",
|
||||
"53:14: '{' should be on a new line.",
|
||||
"58:18: '{' should be on a new line.",
|
||||
"62:18: '{' should be on a new line.",
|
||||
"67:12: '{' should be on a new line.",
|
||||
"72:18: '{' should be on a new line.",
|
||||
"8:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"12:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"21:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"30:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"39:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"49:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"53:14: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"58:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"62:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"67:12: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"72:18: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputScopeInnerInterfaces.java"), expected);
|
||||
}
|
||||
|
|
@ -85,17 +89,17 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport
|
|||
public void testDefault2() throws Exception
|
||||
{
|
||||
final String[] expected = {
|
||||
"12:1: '{' should be on the previous line.",
|
||||
"17:5: '{' should be on the previous line.",
|
||||
"24:5: '{' should be on the previous line.",
|
||||
"31:5: '{' should be on the previous line.",
|
||||
"39:1: '{' should be on the previous line.",
|
||||
"41:5: '{' should be on the previous line.",
|
||||
"46:9: '{' should be on the previous line.",
|
||||
"53:9: '{' should be on the previous line.",
|
||||
"69:5: '{' should be on the previous line.",
|
||||
"77:5: '{' should be on the previous line.",
|
||||
"84:5: '{' should be on the previous line.",
|
||||
"12:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"17:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"24:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"31:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"39:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"41:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"46:9: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"53:9: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"69:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"77:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"84:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputLeftCurlyMethod.java"), expected);
|
||||
}
|
||||
|
|
@ -105,14 +109,14 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport
|
|||
{
|
||||
mCheckConfig.addAttribute("option", LeftCurlyOption.NL.toString());
|
||||
final String[] expected = {
|
||||
"14:39: '{' should be on a new line.",
|
||||
"21:20: '{' should be on a new line.",
|
||||
"34:31: '{' should be on a new line.",
|
||||
"43:24: '{' should be on a new line.",
|
||||
"56:35: '{' should be on a new line.",
|
||||
"60:24: '{' should be on a new line.",
|
||||
"74:20: '{' should be on a new line.",
|
||||
"87:31: '{' should be on a new line.",
|
||||
"14:39: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"21:20: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"34:31: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"43:24: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"56:35: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"60:24: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"74:20: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"87:31: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputLeftCurlyMethod.java"), expected);
|
||||
}
|
||||
|
|
@ -120,29 +124,29 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport
|
|||
public void testDefault3() throws Exception
|
||||
{
|
||||
final String[] expected = {
|
||||
"12:1: '{' should be on the previous line.",
|
||||
"15:5: '{' should be on the previous line.",
|
||||
"19:9: '{' should be on the previous line.",
|
||||
"21:13: '{' should be on the previous line.",
|
||||
"23:17: '{' should be on the previous line.",
|
||||
"30:17: '{' should be on the previous line.",
|
||||
"34:17: '{' should be on the previous line.",
|
||||
"42:13: '{' should be on the previous line.",
|
||||
"46:13: '{' should be on the previous line.",
|
||||
"52:9: '{' should be on the previous line.",
|
||||
"54:13: '{' should be on the previous line.",
|
||||
"63:9: '{' should be on the previous line.",
|
||||
"83:5: '{' should be on the previous line.",
|
||||
"89:5: '{' should be on the previous line.",
|
||||
"97:19: '{' should have line break after.",
|
||||
"106:1: '{' should be on the previous line.",
|
||||
"109:9: '{' should be on the previous line.",
|
||||
"118:1: '{' should be on the previous line.",
|
||||
"120:9: '{' should be on the previous line.",
|
||||
"129:1: '{' should be on the previous line.",
|
||||
"131:9: '{' should be on the previous line.",
|
||||
"133:17: '{' should be on the previous line.",
|
||||
"148:1: '{' should be on the previous line.",
|
||||
"12:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"15:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"19:9: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"21:13: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"23:17: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"30:17: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"34:17: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"42:13: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"46:13: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"52:9: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"54:13: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"63:9: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"83:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"89:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"97:19: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{"),
|
||||
"106:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"109:9: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"118:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"120:9: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"129:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"131:9: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"133:17: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"148:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputLeftCurlyOther.java"), expected);
|
||||
}
|
||||
|
|
@ -152,10 +156,10 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport
|
|||
{
|
||||
mCheckConfig.addAttribute("option", LeftCurlyOption.NL.toString());
|
||||
final String[] expected = {
|
||||
"26:33: '{' should be on a new line.",
|
||||
"91:19: '{' should be on a new line.",
|
||||
"97:19: '{' should be on a new line.",
|
||||
"142:37: '{' should be on a new line.",
|
||||
"26:33: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"91:19: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"97:19: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"142:37: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputLeftCurlyOther.java"), expected);
|
||||
}
|
||||
|
|
@ -164,13 +168,13 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport
|
|||
public void testMissingBraces() throws Exception
|
||||
{
|
||||
final String[] expected = {
|
||||
"12:1: '{' should be on the previous line.",
|
||||
"15:5: '{' should be on the previous line.",
|
||||
"21:5: '{' should be on the previous line.",
|
||||
"34:5: '{' should be on the previous line.",
|
||||
"51:5: '{' should be on the previous line.",
|
||||
"69:5: '{' should be on the previous line.",
|
||||
"105:5: '{' should be on the previous line.",
|
||||
"12:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"15:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"21:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"34:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"51:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"69:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"105:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputBraces.java"), expected);
|
||||
}
|
||||
|
|
@ -179,9 +183,9 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport
|
|||
public void testDefaultWithAnnotations() throws Exception
|
||||
{
|
||||
final String[] expected = {
|
||||
"10:1: '{' should be on the previous line.",
|
||||
"14:5: '{' should be on the previous line.",
|
||||
"21:5: '{' should be on the previous line.",
|
||||
"10:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"14:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"21:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputLeftCurlyAnnotations.java"), expected);
|
||||
}
|
||||
|
|
@ -191,10 +195,10 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport
|
|||
{
|
||||
mCheckConfig.addAttribute("option", LeftCurlyOption.NL.toString());
|
||||
final String[] expected = {
|
||||
"35:34: '{' should be on a new line.",
|
||||
"38:41: '{' should be on a new line.",
|
||||
"44:27: '{' should be on a new line.",
|
||||
"58:32: '{' should be on a new line.",
|
||||
"35:34: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"38:41: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"44:27: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
"58:32: " + getCheckMessage(MSG_KEY_LINE_NEW, "{"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputLeftCurlyAnnotations.java"), expected);
|
||||
}
|
||||
|
|
@ -205,21 +209,21 @@ public class LeftCurlyCheckTest extends BaseCheckTestSupport
|
|||
mCheckConfig.addAttribute("option", LeftCurlyOption.EOL.toString());
|
||||
mCheckConfig.addAttribute("maxLineLength", "100");
|
||||
final String[] expected = {
|
||||
"9:1: '{' should be on the previous line.",
|
||||
"12:5: '{' should be on the previous line.",
|
||||
"16:9: '{' should be on the previous line.",
|
||||
"18:13: '{' should be on the previous line.",
|
||||
"20:17: '{' should be on the previous line.",
|
||||
"26:22: '{' should have line break after.",
|
||||
"28:17: '{' should be on the previous line.",
|
||||
"35:33: '{' should have line break after.",
|
||||
"36:21: '{' should have line break after.",
|
||||
"39:29: '{' should have line break after.",
|
||||
"39:34: '{' should have line break after.",
|
||||
"45:37: '{' should have line break after.",
|
||||
"54:5: '{' should be on the previous line.",
|
||||
"56:27: '{' should have line break after.",
|
||||
"66:1: '{' should be on the previous line.",
|
||||
"9:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"12:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"16:9: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"18:13: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"20:17: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"26:22: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{"),
|
||||
"28:17: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"35:33: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{"),
|
||||
"36:21: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{"),
|
||||
"39:29: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{"),
|
||||
"39:34: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{"),
|
||||
"45:37: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{"),
|
||||
"54:5: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
"56:27: " + getCheckMessage(MSG_KEY_LINE_BREAK_AFTER, "{"),
|
||||
"66:1: " + getCheckMessage(MSG_KEY_LINE_PREVIOUS, "{"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputLeftCurlyLineBreakAfter.java"), expected);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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.blocks.NeedBracesCheck.MSG_KEY_NEED_BRACES;
|
||||
|
||||
public class NeedBracesCheckTest extends BaseCheckTestSupport
|
||||
{
|
||||
@Test
|
||||
|
|
@ -30,23 +32,23 @@ public class NeedBracesCheckTest extends BaseCheckTestSupport
|
|||
final DefaultConfiguration checkConfig =
|
||||
createCheckConfig(NeedBracesCheck.class);
|
||||
final String[] expected = {
|
||||
"29: 'do' construct must use '{}'s." ,
|
||||
"41: 'while' construct must use '{}'s." ,
|
||||
"42: 'while' construct must use '{}'s." ,
|
||||
"44: 'while' construct must use '{}'s." ,
|
||||
"45: 'if' construct must use '{}'s." ,
|
||||
"58: 'for' construct must use '{}'s." ,
|
||||
"59: 'for' construct must use '{}'s." ,
|
||||
"61: 'for' construct must use '{}'s." ,
|
||||
"63: 'if' construct must use '{}'s." ,
|
||||
"82: 'if' construct must use '{}'s." ,
|
||||
"83: 'if' construct must use '{}'s." ,
|
||||
"85: 'if' construct must use '{}'s." ,
|
||||
"87: 'else' construct must use '{}'s." ,
|
||||
"89: 'if' construct must use '{}'s." ,
|
||||
"97: 'else' construct must use '{}'s." ,
|
||||
"99: 'if' construct must use '{}'s." ,
|
||||
"100: 'if' construct must use '{}'s." ,
|
||||
"29: " + getCheckMessage(MSG_KEY_NEED_BRACES, "do"),
|
||||
"41: " + getCheckMessage(MSG_KEY_NEED_BRACES, "while"),
|
||||
"42: " + getCheckMessage(MSG_KEY_NEED_BRACES, "while"),
|
||||
"44: " + getCheckMessage(MSG_KEY_NEED_BRACES, "while"),
|
||||
"45: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"),
|
||||
"58: " + getCheckMessage(MSG_KEY_NEED_BRACES, "for"),
|
||||
"59: " + getCheckMessage(MSG_KEY_NEED_BRACES, "for"),
|
||||
"61: " + getCheckMessage(MSG_KEY_NEED_BRACES, "for"),
|
||||
"63: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"),
|
||||
"82: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"),
|
||||
"83: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"),
|
||||
"85: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"),
|
||||
"87: " + getCheckMessage(MSG_KEY_NEED_BRACES, "else"),
|
||||
"89: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"),
|
||||
"97: " + getCheckMessage(MSG_KEY_NEED_BRACES, "else"),
|
||||
"99: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"),
|
||||
"100: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"),
|
||||
};
|
||||
verify(checkConfig, getPath("InputBraces.java"), expected);
|
||||
}
|
||||
|
|
@ -58,8 +60,8 @@ public class NeedBracesCheckTest extends BaseCheckTestSupport
|
|||
createCheckConfig(NeedBracesCheck.class);
|
||||
checkConfig.addAttribute("allowSingleLineIf", "true");
|
||||
final String[] expected = {
|
||||
"23: 'if' construct must use '{}'s." ,
|
||||
"29: 'if' construct must use '{}'s." ,
|
||||
"23: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"),
|
||||
"29: " + getCheckMessage(MSG_KEY_NEED_BRACES, "if"),
|
||||
};
|
||||
verify(checkConfig, getPath("InputBracesSingleLineIfBlock.java"), expected);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,11 @@ import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_ALONE;
|
||||
import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_BREAK_BEFORE;
|
||||
import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_NEW;
|
||||
import static com.puppycrawl.tools.checkstyle.checks.blocks.RightCurlyCheck.MSG_KEY_LINE_SAME;
|
||||
|
||||
public class RightCurlyCheckTest extends BaseCheckTestSupport
|
||||
{
|
||||
private DefaultConfiguration mCheckConfig;
|
||||
|
|
@ -38,14 +43,14 @@ public class RightCurlyCheckTest extends BaseCheckTestSupport
|
|||
public void testDefault() throws Exception
|
||||
{
|
||||
final String[] expected = {
|
||||
"25:17: '}' should be on the same line.",
|
||||
"28:17: '}' should be on the same line.",
|
||||
"40:13: '}' should be on the same line.",
|
||||
"44:13: '}' should be on the same line.",
|
||||
"93:27: '}' should be alone on a line.",
|
||||
"93:27: '}' should be on a new line.",
|
||||
"93:27: '}' should have line break before.",
|
||||
"97:54: '}' should have line break before.",
|
||||
"25:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}"),
|
||||
"28:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}"),
|
||||
"40:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}"),
|
||||
"44:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}"),
|
||||
"93:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}"),
|
||||
"93:27: " + getCheckMessage(MSG_KEY_LINE_NEW, "}"),
|
||||
"93:27: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}"),
|
||||
"97:54: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputLeftCurlyOther.java"), expected);
|
||||
}
|
||||
|
|
@ -54,14 +59,14 @@ public class RightCurlyCheckTest extends BaseCheckTestSupport
|
|||
{
|
||||
mCheckConfig.addAttribute("option", RightCurlyOption.SAME.toString());
|
||||
final String[] expected = {
|
||||
"25:17: '}' should be on the same line.",
|
||||
"28:17: '}' should be on the same line.",
|
||||
"40:13: '}' should be on the same line.",
|
||||
"44:13: '}' should be on the same line.",
|
||||
"93:27: '}' should be alone on a line.",
|
||||
"93:27: '}' should be on a new line.",
|
||||
"93:27: '}' should have line break before.",
|
||||
"97:54: '}' should have line break before.",
|
||||
"25:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}"),
|
||||
"28:17: " + getCheckMessage(MSG_KEY_LINE_SAME, "}"),
|
||||
"40:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}"),
|
||||
"44:13: " + getCheckMessage(MSG_KEY_LINE_SAME, "}"),
|
||||
"93:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}"),
|
||||
"93:27: " + getCheckMessage(MSG_KEY_LINE_NEW, "}"),
|
||||
"93:27: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}"),
|
||||
"97:54: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputLeftCurlyOther.java"), expected);
|
||||
}
|
||||
|
|
@ -71,8 +76,8 @@ public class RightCurlyCheckTest extends BaseCheckTestSupport
|
|||
{
|
||||
mCheckConfig.addAttribute("option", RightCurlyOption.ALONE.toString());
|
||||
final String[] expected = {
|
||||
"93:27: '}' should be alone on a line.",
|
||||
"93:27: '}' should be on a new line.",
|
||||
"93:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}"),
|
||||
"93:27: " + getCheckMessage(MSG_KEY_LINE_NEW, "}"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputLeftCurlyOther.java"), expected);
|
||||
}
|
||||
|
|
@ -83,9 +88,9 @@ public class RightCurlyCheckTest extends BaseCheckTestSupport
|
|||
mCheckConfig.addAttribute("option", RightCurlyOption.ALONE.toString());
|
||||
mCheckConfig.addAttribute("tokens", "CLASS_DEF, METHOD_DEF, CTOR_DEF");
|
||||
final String[] expected = {
|
||||
"111:10: '}' should be on a new line.",
|
||||
"122:10: '}' should be on a new line.",
|
||||
"136:10: '}' should be on a new line.",
|
||||
"111:10: " + getCheckMessage(MSG_KEY_LINE_NEW, "}"),
|
||||
"122:10: " + getCheckMessage(MSG_KEY_LINE_NEW, "}"),
|
||||
"136:10: " + getCheckMessage(MSG_KEY_LINE_NEW, "}"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputLeftCurlyOther.java"), expected);
|
||||
}
|
||||
|
|
@ -96,7 +101,7 @@ public class RightCurlyCheckTest extends BaseCheckTestSupport
|
|||
mCheckConfig.addAttribute("option", RightCurlyOption.ALONE.toString());
|
||||
mCheckConfig.addAttribute("shouldStartLine", "false");
|
||||
final String[] expected = {
|
||||
"93:27: '}' should be alone on a line.",
|
||||
"93:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputLeftCurlyOther.java"), expected);
|
||||
}
|
||||
|
|
@ -107,7 +112,7 @@ public class RightCurlyCheckTest extends BaseCheckTestSupport
|
|||
mCheckConfig.addAttribute("option", RightCurlyOption.ALONE.toString());
|
||||
mCheckConfig.addAttribute("shouldStartLine", "false");
|
||||
final String[] expected = {
|
||||
"93:27: '}' should be alone on a line.",
|
||||
"93:27: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputLeftCurlyOther.java"), expected);
|
||||
}
|
||||
|
|
@ -119,9 +124,9 @@ public class RightCurlyCheckTest extends BaseCheckTestSupport
|
|||
mCheckConfig.addAttribute("tokens", "LITERAL_FOR,"
|
||||
+ "LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT");
|
||||
final String[] expected = {
|
||||
"35:43: '}' should be alone on a line.",
|
||||
"41:71: '}' should be alone on a line.",
|
||||
"47:25: '}' should be alone on a line.",
|
||||
"35:43: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}"),
|
||||
"41:71: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}"),
|
||||
"47:25: " + getCheckMessage(MSG_KEY_LINE_ALONE, "}"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputRightCurlyLineBreakBefore.java"), expected);
|
||||
}
|
||||
|
|
@ -130,10 +135,10 @@ public class RightCurlyCheckTest extends BaseCheckTestSupport
|
|||
public void testForceLineBreakBefore2() throws Exception
|
||||
{
|
||||
final String[] expected = {
|
||||
"24:33: '}' should have line break before.",
|
||||
"32:44: '}' should have line break before.",
|
||||
"32:63: '}' should have line break before.",
|
||||
"52:56: '}' should have line break before.",
|
||||
"24:33: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}"),
|
||||
"32:44: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}"),
|
||||
"32:63: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}"),
|
||||
"52:56: " + getCheckMessage(MSG_KEY_LINE_BREAK_BEFORE, "}"),
|
||||
};
|
||||
verify(mCheckConfig, getPath("InputRightCurlyLineBreakBefore.java"), expected);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue