Issue #2589: Unify IT input file locations with tests.

This commit is contained in:
rnveach 2015-11-12 09:47:41 -05:00 committed by Roman Ivanov
parent 7a4ec11d12
commit c29af9d036
8 changed files with 200 additions and 29 deletions

View File

@ -71,13 +71,7 @@ public class NoLineWrapTest extends BaseCheckTestSupport {
final int maxLineLength = 100;
final String[] expected = {
"5: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", maxLineLength, 112),
"29: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", maxLineLength, 183),
"46: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", maxLineLength, 131),
"47: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", maxLineLength, 124),
"48: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", maxLineLength, 113),
"50: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", maxLineLength, 116),
"53: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", maxLineLength, 131),
"57: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", maxLineLength, 116),
"29: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", maxLineLength, 113),
};
final Configuration checkConfig = getCheckConfig("LineLength");

View File

@ -41,13 +41,7 @@ public class LineLengthTest extends BaseCheckTestSupport {
final String[] expected = {
"5: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 112),
"29: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 183),
"46: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 131),
"47: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 124),
"48: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 113),
"50: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 116),
"53: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 131),
"57: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 116),
"29: " + getCheckMessage(LineLengthCheck.class, "maxLineLen", 100, 113),
};
final Configuration checkConfig = getCheckConfig("LineLength");

View File

@ -36,9 +36,8 @@ public class PackageNameTest extends BaseCheckTestSupport {
private static Configuration checkConfig;
private static String format;
@Override
protected String getPath(String fileName) throws IOException {
return super.getPath("chapter5naming" + File.separator + "rule521packagenames"
protected String getPath(String packageName, String fileName) throws IOException {
return getPath("chapter5naming" + File.separator + "rule521" + packageName
+ File.separator + fileName);
}
@ -53,7 +52,7 @@ public class PackageNameTest extends BaseCheckTestSupport {
final String[] expected = ArrayUtils.EMPTY_STRING_ARRAY;
final String filePath = getPath("InputPackageNameGood.java");
final String filePath = getPath("packagenames", "InputPackageNameGood.java");
final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList);
@ -70,7 +69,7 @@ public class PackageNameTest extends BaseCheckTestSupport {
"1:9: " + msg,
};
final String filePath = getPath("InputPackageNameBad.java");
final String filePath = getPath("packageNamesCamelCase", "InputPackageNameBad.java");
final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList);
@ -86,7 +85,7 @@ public class PackageNameTest extends BaseCheckTestSupport {
"1:9: " + msg,
};
final String filePath = getPath("InputBadPackageName2.java");
final String filePath = getPath("_packagenames", "InputBadPackageName2.java");
final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList);
@ -102,7 +101,7 @@ public class PackageNameTest extends BaseCheckTestSupport {
"1:9: " + msg,
};
final String filePath = getPath("InputPackageBadName3.java");
final String filePath = getPath("$packagenames", "InputPackageBadName3.java");
final Integer[] warnList = getLinesWithWarn(filePath);
verify(checkConfig, filePath, expected, warnList);

View File

@ -1,4 +1,4 @@
package com.google.checkstyle.test.chapter3filestructure.rule32packagestatement; // ok
package com.google.checkstyle.test.chapter3filestructure.rule32packagestate; // ok
import java.io.*;
final class InputLineLength
{

View File

@ -0,0 +1,184 @@
package com.google.checkstyle.test.chapter3filestructure.rule332nolinewrap; //ok
import com.google.checkstyle.test.chapter3filestructure.toolongpackagetotestcoveragegooglesjavastylerule.*; //ok
final class InputLineLength
{
// Long line ---------------------------------------------------------------------------------------- //warn
// 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, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, }; //warn
//
// 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 java.lang.Exception abc
**/
int test1(int badFormat1,int badFormat2,
final int badFormat3)
throws java.lang.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 InputLineLength()
{
// 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)
{
}
}

View File

@ -16,7 +16,7 @@
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
////////////////////////////////////////////////////////////////////////////////
package com.google.checkstyle.test.chapter3filestructure.rule3sourcefilestructure; //warn
package com.google.checkstyle.test.chapter3filestructure.rule3sourcefile; //warn
import java.io.Serializable; //warn
import java.util.ArrayList;
import java.util.HashMap;
@ -107,8 +107,8 @@ class InputEmptyLineSeparator //warn
}
}
class Class { //ok
private Class() {} //ok
class Class1 { //ok
private Class1() {} //ok
}
class Class2{ //warn
public int compareTo(InputEmptyLineSeparator aObject) //ok

View File

@ -1,8 +1,8 @@
package com.google.checkstyle.test.chapter4formatting.rule44columnlimit; //ok
import com.google.checkstyle.test.chapter3filestructure.toolongpackagetotestcoveragegooglesjavastylerule.*; //ok
final class LineLengthInput
final class InputLineLength
{
// Long line ----------------------------------------------------------------------------------------
// Long line ---------------------------------------------------------------------------------------- //warn
// Contains a tab -> <-
// Contains trailing whitespace ->
@ -85,7 +85,7 @@ final class LineLengthInput
}
/** constructor that is 10 lines long **/
private LineLengthInput()
private InputLineLength()
{
// a line
// a line

View File

@ -2,7 +2,7 @@
// Test case file for checkstyle.
// Created: 2001
////////////////////////////////////////////////////////////////////////////////
package com.google.checkstyle.test.chapter6programpractice.rule62caughtexceptions;
package com.google.checkstyle.test.chapter6programpractice.rule62donotignoreexceptions;
import java.io.*;
import java.awt.Dimension;