Skip to content

Commit

Permalink
Issue checkstyle#3976: EmptyForIteratorPad input test organise and split
Browse files Browse the repository at this point in the history
  • Loading branch information
shivanshsoni authored and sagarshah94 committed Mar 18, 2017
1 parent 56064e7 commit 33ff792
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 5 deletions.
Expand Up @@ -48,8 +48,8 @@ public void setUp() {

@Override
protected String getPath(String filename) throws IOException {
return super.getPath("checks" + File.separator
+ "whitespace" + File.separator + filename);
return super.getPath("checks" + File.separator + "whitespace" + File.separator
+ "emptyforiteratorpad" + File.separator + filename);
}

@Test
Expand All @@ -66,7 +66,7 @@ public void testDefault() throws Exception {
"43:32: " + getCheckMessage(MSG_WS_FOLLOWED, ";"),
"55:11: " + getCheckMessage(MSG_WS_FOLLOWED, ";"),
};
verify(checkConfig, getPath("InputForWhitespace.java"), expected);
verify(checkConfig, getPath("InputEmptyForIteratorPad.java"), expected);
}

@Test
Expand All @@ -75,7 +75,7 @@ public void testSpaceOption() throws Exception {
final String[] expected = {
"23:31: " + getCheckMessage(MSG_WS_NOT_FOLLOWED, ";"),
};
verify(checkConfig, getPath("InputForWhitespace.java"), expected);
verify(checkConfig, getPath("InputEmptyForIteratorPad.java"), expected);
}

@Test
Expand All @@ -95,7 +95,7 @@ public void testInvalidOption() throws Exception {
try {
final String[] expected = CommonUtils.EMPTY_STRING_ARRAY;

verify(checkConfig, getPath("InputForWhitespace.java"), expected);
verify(checkConfig, getPath("InputEmptyForIteratorPad.java"), expected);
fail("exception expected");
}
catch (CheckstyleException ex) {
Expand Down
@@ -0,0 +1,58 @@
////////////////////////////////////////////////////////////////////////////////
// Test case file for FOR_ITERATION.
// Created: 2003
////////////////////////////////////////////////////////////////////////////////
package com.puppycrawl.tools.checkstyle.checks.whitespace.emptyforiteratorpad;

class InputEmptyForIteratorPad
{
void method1()
{
for (int i = 0; i < 1; i++) {
}

for (int i = 0; i < 1;i++) {
}

for (int i = 0; i < 1;i++ ) {
}

for (int i = 0; i < 1; i++ ) {
}

for (int i = 0; i < 1;) {
i++;
}

for (int i = 0; i < 1; ) {
i++;
}

// test eol, there is no space after second SEMI
for (int i = 0; i < 1;
) {
i++;
}
}

void method2()
{
for ( int i = 0; i < 1; i++ ) {
}

for ( int i = 0; i < 1; ) {
i++;
}

int i = 0;
for ( ; i < 1; i++ ) {
}

for (; i < 2; i++ ) {
}

for (
;; ) {
}
}
}

0 comments on commit 33ff792

Please sign in to comment.