Skip to content

Create a new Rabin-Karp Algorithm #3201

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 5, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Update and rename RabinKarpAlgorithmTest to RabinKarpAlgorithmTest.java
  • Loading branch information
tackhwa authored Aug 4, 2022
commit 303d3bb4f65ff58166eb83b69ef7e6f7bcb067ea
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,20 @@
import static org.junit.jupiter.api.Assertions.*;




class RabinKarpAlgorithmTest {


RabinKarpAlgorithm RKA= new RabinKarpAlgorithm();
int q= 101;





@Test
// valid test case
public void RabinKarpAlgorithmTestExample() {
String txt = "This is an example for rabin karp algorithmn";
String pat = "algorithmn";
int value = RKA.search(pat, txt, q);
assertEquals(value,34);

}




@Test
// valid test case
Expand All @@ -35,46 +26,33 @@ public void RabinKarpAlgorithmTestFront() {
String pat = "AAA";
int value = RKA.search(pat, txt, q);
assertEquals(value, 0);

}




@Test
// valid test case
public void RabinKarpAlgorithmTestMiddle() {
String txt = "AAABBCCBB";
String pat = "BBCC";
int value = RKA.search(pat, txt, q);
assertEquals(value, 3);

}





@Test
// valid test case
public void RabinKarpAlgorithmTestLast() {
String txt = "AAAABBBBCCC";
String pat = "CCC";
int value = RKA.search(pat, txt, q);
assertEquals(value, 8);

}





@Test
// valid test case
public void RabinKarpAlgorithmTestNotFound() {
String txt = "ABCBCBCAAB";
String pat = "AADB";
int value = RKA.search(pat, txt, q);
assertEquals(value, -1);

}

}