mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-28 06:55:02 +08:00
code-clean-up (#4519)
* code-clean-up * style: make `RabinKarpAlgorithm` a proper utility class --------- Co-authored-by: arintripathi1 <arint@trainee.nrifintech.com> Co-authored-by: vil02 <vil02@o2.pl> Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
This commit is contained in:
@ -6,12 +6,11 @@ import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.CsvSource;
|
||||
|
||||
class RabinKarpAlgorithmTest {
|
||||
RabinKarpAlgorithm RKA = new RabinKarpAlgorithm();
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource({"This is an example for rabin karp algorithmn, algorithmn, 101", "AAABBDDG, AAA, 137", "AAABBCCBB, BBCC, 101", "AAABBCCBB, BBCC, 131", "AAAABBBBCCC, CCC, 41", "ABCBCBCAAB, AADB, 293", "Algorithm The Algorithm, Algorithm, 101"})
|
||||
void RabinKarpAlgorithmTestExample(String txt, String pat, int q) {
|
||||
int indexFromOurAlgorithm = RKA.search(pat, txt, q);
|
||||
int indexFromOurAlgorithm = RabinKarpAlgorithm.search(pat, txt, q);
|
||||
int indexFromLinearSearch = txt.indexOf(pat);
|
||||
assertEquals(indexFromOurAlgorithm, indexFromLinearSearch);
|
||||
}
|
||||
|
Reference in New Issue
Block a user