forked from phoedos/pmd
Add a failing test for multiple exact matches
This commit is contained in:
parent
f9cb7ab992
commit
9d04358707
@ -39,4 +39,21 @@ public class CppCpdTest {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testMultipleExactMatches() throws Exception {
|
||||
CPDConfiguration configuration = new CPDConfiguration();
|
||||
configuration.setMinimumTileSize(40);
|
||||
configuration.setOnlyRecognizeLanguage(CppLanguageModule.getInstance());
|
||||
try (CpdAnalysis cpd = CpdAnalysis.create(configuration)) {
|
||||
cpd.files().addFile(testdir.resolve("multipleExactMatches.c"));
|
||||
|
||||
cpd.performAnalysis(matches -> {
|
||||
// There should only be 1 duplication, and it should be maximal
|
||||
assertEquals(1, matches.getMatches().size());
|
||||
assertEquals(3, matches.getMatches().get(0).getMarkCount());
|
||||
assertEquals(41, matches.getMatches().get(0).getTokenCount());
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
12
pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/multipleExactMatches.c
vendored
Normal file
12
pmd-cpp/src/test/resources/net/sourceforge/pmd/lang/cpp/cpd/testdata/multipleExactMatches.c
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
unsigned char _ctype[] = { 3,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
4
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user