Add a failing test for multiple exact matches

This commit is contained in:
Juan Martín Sotuyo Dodero 2024-04-17 23:36:49 -03:00
parent f9cb7ab992
commit 9d04358707
2 changed files with 29 additions and 0 deletions

View File

@ -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());
});
}
}
}

View 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
};