aboutsummaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorMikhailovOlegM <mikhailov.oleg.m@gmail.com>2017-03-21 18:44:45 +0200
committerRoman Ivanov <ivanov-jr@mail.ru>2017-04-05 04:17:17 -0700
commit2da952656897641e7268160fb7512d0f62c58f69 (patch)
tree47d7a25839f221b1b66624542e5a68da84d95499 /src/test
parent7b95603c0e5036f397365a05b68483d0da690c63 (diff)
downloadcheckstyle-2da952656897641e7268160fb7512d0f62c58f69.tar.gz
Issue #4013: Split and Organize Checkstyle inputsby Test for LineLength
Diffstat (limited to 'src/test')
-rw-r--r--src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/InputLineLengthCheckTest.java (renamed from src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheckTest.java)14
-rw-r--r--src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/sizes/linelength/InputLongPackageStatement.java (renamed from src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/sizes/InputLongPackageStatement.java)0
-rw-r--r--src/test/resources/com/puppycrawl/tools/checkstyle/checks/sizes/linelength/InputLineLengthSimple.java225
-rw-r--r--src/test/resources/com/puppycrawl/tools/checkstyle/checks/sizes/linelength/InputLongImportStatements.java (renamed from src/test/resources/com/puppycrawl/tools/checkstyle/checks/sizes/InputLongImportStatements.java)2
4 files changed, 235 insertions, 6 deletions
diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/InputLineLengthCheckTest.java
index 7fedad8f6..7fb9af540 100644
--- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/LineLengthCheckTest.java
+++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/sizes/InputLineLengthCheckTest.java
@@ -31,17 +31,21 @@ import com.puppycrawl.tools.checkstyle.BaseCheckTestSupport;
import com.puppycrawl.tools.checkstyle.DefaultConfiguration;
import com.puppycrawl.tools.checkstyle.utils.CommonUtils;
-public class LineLengthCheckTest extends BaseCheckTestSupport {
+public class InputLineLengthCheckTest extends BaseCheckTestSupport {
@Override
protected String getPath(String filename) throws IOException {
return super.getPath("checks" + File.separator
- + "sizes" + File.separator + filename);
+ + "sizes" + File.separator
+ + "linelength" + File.separator
+ + filename);
}
@Override
protected String getNonCompilablePath(String filename) throws IOException {
return super.getNonCompilablePath("checks" + File.separator
- + "sizes" + File.separator + filename);
+ + "sizes" + File.separator
+ + "linelength" + File.separator
+ + filename);
}
@Test
@@ -67,7 +71,7 @@ public class LineLengthCheckTest extends BaseCheckTestSupport {
"18: " + getCheckMessage(MSG_KEY, 80, 81),
"145: " + getCheckMessage(MSG_KEY, 80, 83),
};
- verify(checkConfig, getPath("InputSimple.java"), expected);
+ verify(checkConfig, getPath("InputLineLengthSimple.java"), expected);
}
@Test
@@ -82,7 +86,7 @@ public class LineLengthCheckTest extends BaseCheckTestSupport {
"18: 80,81",
"145: 80,83",
};
- verify(checkConfig, getPath("InputSimple.java"), expected);
+ verify(checkConfig, getPath("InputLineLengthSimple.java"), expected);
}
@Test
diff --git a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/sizes/InputLongPackageStatement.java b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/sizes/linelength/InputLongPackageStatement.java
index 214278982..214278982 100644
--- a/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/sizes/InputLongPackageStatement.java
+++ b/src/test/resources-noncompilable/com/puppycrawl/tools/checkstyle/checks/sizes/linelength/InputLongPackageStatement.java
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/sizes/linelength/InputLineLengthSimple.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/sizes/linelength/InputLineLengthSimple.java
new file mode 100644
index 000000000..792fd9f54
--- /dev/null
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/sizes/linelength/InputLineLengthSimple.java
@@ -0,0 +1,225 @@
+////////////////////////////////////////////////////////////////////////////////
+// Test case file for checkstyle.
+// Created: Feb-2001
+// Ignore error
+////////////////////////////////////////////////////////////////////////////////
+package com.puppycrawl.tools.checkstyle.checks.sizes.linelength;
+
+/**
+ * Contains simple mistakes:
+ * - Long lines
+ * - Tabs
+ * - Format of variables and parameters
+ * - Order of modifiers
+ * @author Oliver Burn
+ **/
+final class InputLineLengthSimple
+{
+ // Long line ----------------------------------------------------------------
+ // Contains a tab -> <-
+ // Contains trailing whitespace ->
+
+ // Name format tests
+ //
+ /** Invalid format **/
+ public static final int badConstant = 2;
+ /** Valid format **/
+ public static final int MAX_ROWS = 2;
+
+ /** Invalid format **/
+ private static int badStatic = 2;
+ /** Valid format **/
+ private static int sNumCreated = 0;
+
+ /** Invalid format **/
+ private int badMember = 2;
+ /** Valid format **/
+ private int mNumCreated1 = 0;
+ /** Valid format **/
+ protected int mNumCreated2 = 0;
+
+ /** commas are wrong **/
+ private int[] mInts = new int[] {1,2, 3,
+ 4};
+
+ //
+ // Accessor tests
+ //
+ /** should be private **/
+ public static int sTest1;
+ /** should be private **/
+ protected static int sTest3;
+ /** should be private **/
+ static int sTest2;
+
+ /** should be private **/
+ int mTest1;
+ /** should be private **/
+ public int mTest2;
+
+ //
+ // Parameter name format tests
+ //
+
+ /**
+ * @return hack
+ * @param badFormat1 bad format
+ * @param badFormat2 bad format
+ * @param badFormat3 bad format
+ * @throws Exception abc
+ **/
+ int test1(int badFormat1,int badFormat2,
+ final int badFormat3)
+ throws Exception
+ {
+ return 0;
+ }
+
+ /** method that is 20 lines long **/
+ private void longMethod()
+ {
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ }
+
+ /** constructor that is 10 lines long **/
+ private InputLineLengthSimple()
+ {
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ // a line
+ }
+
+ /** test local variables */
+ private void localVariables()
+ {
+ // normal decl
+ int abc = 0;
+ int ABC = 0;
+
+ // final decls
+ final int cde = 0;
+ final int CDE = 0;
+
+ // decl in for loop init statement
+ for (int k = 0; k < 1; k++)
+ {
+ String innerBlockVariable = "";
+ }
+ for (int I = 0; I < 1; I++)
+ {
+ String InnerBlockVariable = "";
+ }
+ }
+
+ /** test method pattern */
+ void ALL_UPPERCASE_METHOD()
+ {
+ }
+
+ /** test illegal constant **/
+ private static final int BAD__NAME = 3;
+
+ // A very, very long line that is OK because it matches the regexp "^.*is OK.*regexp.*$"
+ // long line that has a tab -> <- and would be OK if tab counted as 1 char
+ // tabs that count as one char because of their position -> <- -> <-, OK
+
+ /** some lines to test the error column after tabs */
+ void errorColumnAfterTabs()
+ {
+ // with tab-width 8 all statements below start at the same column,
+ // with different combinations of ' ' and '\t' before the statement
+ int tab0 =1;
+ int tab1 =1;
+ int tab2 =1;
+ int tab3 =1;
+ int tab4 =1;
+ int tab5 =1;
+ }
+
+ // FIXME:
+ /* FIXME: a
+ * FIXME:
+ * TODO
+ */
+ /* NOTHING */
+ /* YES */ /* FIXME: x */ /* YES!! */
+
+ /** test long comments **/
+ void veryLong()
+ {
+ /*
+ blah blah blah blah
+ blah blah blah blah
+ blah blah blah blah
+ blah blah blah blah
+ blah blah blah blah
+ blah blah blah blah
+ blah blah blah blah
+ blah blah blah blah
+ blah blah blah blah
+ blah blah blah blah
+ blah blah blah blah
+ blah blah blah blah
+ blah blah blah blah
+ blah blah blah blah
+ blah blah blah blah
+ enough talk */
+ }
+
+ /**
+ * @see to lazy to document all args. Testing excessive # args
+ **/
+ void toManyArgs(int aArg1, int aArg2, int aArg3, int aArg4, int aArg5,
+ int aArg6, int aArg7, int aArg8, int aArg9)
+ {
+ }
+}
+
+/** Test class for variable naming in for each clauses. */
+class InputLineLengthSimple2
+{
+ /** Some more Javadoc. */
+ public void doSomething()
+ {
+ //"O" should be named "o"
+ for (Object O : new java.util.ArrayList())
+ {
+
+ }
+ }
+}
+
+/** Test enum for member naming check */
+enum MyEnum1
+{
+ /** ABC constant */
+ ABC,
+
+ /** XYZ constant */
+ XYZ;
+
+ /** Should be mSomeMemeber */
+ private int someMember;
+}
diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/sizes/InputLongImportStatements.java b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/sizes/linelength/InputLongImportStatements.java
index 304f0d5f5..79585b29f 100644
--- a/src/test/resources/com/puppycrawl/tools/checkstyle/checks/sizes/InputLongImportStatements.java
+++ b/src/test/resources/com/puppycrawl/tools/checkstyle/checks/sizes/linelength/InputLongImportStatements.java
@@ -1,4 +1,4 @@
-package com.puppycrawl.tools.checkstyle.checks.sizes;
+package com.puppycrawl.tools.checkstyle.checks.sizes.linelength;
import com.puppycrawl.tools.checkstyle.grammars.comments.InputFullOfSinglelineComments;
import static com.puppycrawl.tools.checkstyle.grammars.comments.InputFullOfSinglelineComments.main;