From 328e27a1c77ab3a91ef61e269a70f58502fa04e3 Mon Sep 17 00:00:00 2001 From: maxvetrenko Date: Fri, 19 Dec 2014 19:20:12 +0300 Subject: [PATCH] Added Ut to show that method call line wrapping now is works correct. #116 --- .../indentation/IndentationCheckTest.java | 10 +++++ .../indentation/InputMethodCallLineWrap.java | 40 +++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 src/test/resources/com/puppycrawl/tools/checkstyle/indentation/InputMethodCallLineWrap.java diff --git a/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java b/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java index 449ce7982..29fcf245c 100644 --- a/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java +++ b/src/test/java/com/puppycrawl/tools/checkstyle/checks/indentation/IndentationCheckTest.java @@ -60,6 +60,16 @@ public class IndentationCheckTest extends BaseCheckTestSupport verify(checkConfig, getPath("indentation/InputAndroidStyle.java"), expected); } + public void testMethodCallLineWrap() throws Exception + { + final DefaultConfiguration checkConfig = createCheckConfig(IndentationCheck.class); + final String[] expected = { + "36: 'method call' child have incorrect indentation level 18, expected level should be 20.", + "37: 'method call rparen' have incorrect indentation level 14, expected level should be 16.", + }; + verify(checkConfig, getPath("indentation/InputMethodCallLineWrap.java"), expected); + } + @Test public void testAnonClassesFromGuava() throws Exception { diff --git a/src/test/resources/com/puppycrawl/tools/checkstyle/indentation/InputMethodCallLineWrap.java b/src/test/resources/com/puppycrawl/tools/checkstyle/indentation/InputMethodCallLineWrap.java new file mode 100644 index 000000000..4e9235fd3 --- /dev/null +++ b/src/test/resources/com/puppycrawl/tools/checkstyle/indentation/InputMethodCallLineWrap.java @@ -0,0 +1,40 @@ +package com.puppycrawl.tools.checkstyle.indentation; + +public class InputMethodCallLineWrap { + + void foo() { + new String() + .substring( + 0, 100 + ) + .substring( + 0, 50 + ); + } + + class InnerFoo { + + void foo() { + new String() + .substring( + 0, 100 + ) + .substring( + 0, 50 + ); + } + } + + InnerFoo anon = new InnerFoo() { + + void foo() { + new String() + .substring( + 0, 100 + ) + .substring( + 0, 50 //incorrect + ); //incorrect + } + }; +}