From a1068badba958ca522fc27f6952dabc3e949b62b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20K=C3=BChne?= Date: Sun, 24 Sep 2006 11:37:55 +0000 Subject: [PATCH] added unit test to demostrate bug #1564465 (test is disabled until the problem is fixed, so that gump won't break) --- .../checkstyle/duplicates/Overlapping.java | 30 +++++++++++++++++++ .../StrictDuplicateCodeCheckTest.java | 17 +++++++++++ 2 files changed, 47 insertions(+) create mode 100644 src/testinputs/com/puppycrawl/tools/checkstyle/duplicates/Overlapping.java diff --git a/src/testinputs/com/puppycrawl/tools/checkstyle/duplicates/Overlapping.java b/src/testinputs/com/puppycrawl/tools/checkstyle/duplicates/Overlapping.java new file mode 100644 index 000000000..4ca7b1857 --- /dev/null +++ b/src/testinputs/com/puppycrawl/tools/checkstyle/duplicates/Overlapping.java @@ -0,0 +1,30 @@ +// A class that has overlapping areas of duplication (min=3) + +public class Overlapping { + + public m1() { + int a = 0; + int b = 0; + int c = 0; + int d = 0; + } + + public m2() { + int a = 0; + int b = 0; + int c = 0; + } + + public m3() { + int b = 0; + int c = 0; + int d = 0; + } + + public m4() { + int a = 0; + int b = 0; + int c = 0; + int d = 0; + } +} \ No newline at end of file diff --git a/src/tests/com/puppycrawl/tools/checkstyle/checks/duplicates/StrictDuplicateCodeCheckTest.java b/src/tests/com/puppycrawl/tools/checkstyle/checks/duplicates/StrictDuplicateCodeCheckTest.java index 9489fde52..66801d611 100644 --- a/src/tests/com/puppycrawl/tools/checkstyle/checks/duplicates/StrictDuplicateCodeCheckTest.java +++ b/src/tests/com/puppycrawl/tools/checkstyle/checks/duplicates/StrictDuplicateCodeCheckTest.java @@ -47,4 +47,21 @@ public class StrictDuplicateCodeCheckTest extends BaseCheckTestCase { verify(createChecker(checkConfig), checkedFiles, aPath, expected); } + public void failingTestOverlapping() throws Exception + { + final DefaultConfiguration checkConfig = createCheckConfig(StrictDuplicateCodeCheck.class); + checkConfig.addAttribute("min", "3"); + final String path = getPath("duplicates/Overlapping.java"); + final String[] expected = { + "6: Found duplicate of 3 lines in " + path + ", starting from line 13", + "6: Found duplicate of 5 lines in " + path + ", starting from line 25", + "7: Found duplicate of 5 lines in " + path + ", starting from line 19", + "13: Found duplicate of 3 lines in " + path + ", starting from line 25", + "19: Found duplicate of 4 lines in " + path + ", starting from line 26", + }; + final File[] checkedFiles = new File[] { + new File(path), + }; + verify(createChecker(checkConfig), checkedFiles, path, expected); + } }