fix: change location of others to correct places (#5559)

This commit is contained in:
B Karthik
2024-10-04 23:17:50 +05:30
committed by GitHub
parent 393337fa8e
commit 042d458d34
12 changed files with 42 additions and 21 deletions

View File

@@ -0,0 +1,23 @@
package com.thealgorithms.strings;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.Set;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
class StringMatchFiniteAutomataTest {
@ParameterizedTest
@MethodSource("provideTestCases")
void searchPattern(String text, String pattern, Set<Integer> expectedOutput) {
assertEquals(expectedOutput, StringMatchFiniteAutomata.searchPattern(text, pattern));
}
private static Stream<Arguments> provideTestCases() {
return Stream.of(Arguments.of("abcbcabc", "abc", Set.of(0, 5)), Arguments.of("", "abc", Set.of()), Arguments.of("", "", Set.of()), Arguments.of("a", "b", Set.of()), Arguments.of("a", "a", Set.of(0)), Arguments.of("abcdabcabcabcd", "abcd", Set.of(0, 10)), Arguments.of("abc", "bcd", Set.of()),
Arguments.of("abcdefg", "xyz", Set.of()), Arguments.of("abcde", "", Set.of(1, 2, 3, 4, 5)), Arguments.of("abcabcabc", "abc", Set.of(0, 3, 6)), Arguments.of("abcabcabc", "abcabcabc", Set.of(0)), Arguments.of("aaabbbaaa", "aaa", Set.of(0, 6)), Arguments.of("abcdefg", "efg", Set.of(4)));
}
}