Skip to content

Commit

Permalink
test: PatternSearchUsingRabinKarpAlgoTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Lohit-pro committed Sep 16, 2024
1 parent e8248d4 commit 7330323
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ private PatternSearchUsingRabinKarpAlgo() {
// I'm using Rabin-Karp algorithm that uses hashing to find pattern strings in a text.
public static List<String> search(String text, String pattern) {
List<String> result = new ArrayList<>();
text = text.toLowerCase();
pattern = pattern.toLowerCase();
int m = pattern.length();
int n = text.length();
int prime = 101; // A prime number to mod hash values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public void testMultipleMatches() {
public void testCaseInsensitiveSearch() {
String text = "HelloWorld";
String pattern = "helloworld";
List<String> result = PatternSearchUsingRabinKarpAlgo.search(text.toLowerCase(), pattern.toLowerCase());
List<String> result = PatternSearchUsingRabinKarpAlgo.search(text, pattern);
assertFalse(result.isEmpty(), "Pattern should match regardless of case");
assertEquals("Start: 0, End: 9, Substring: helloworld", result.get(0));
}
Expand Down

0 comments on commit 7330323

Please sign in to comment.