mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-28 23:15:17 +08:00
Fix:/Number of count of major element in Boyer Moore algorithm (#4728)
* Number of count of major element in Boyer Moore algorithm * test: add `BoyerMooreTest` * style: basic linting * tests: add test case from the issue --------- Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com> Co-authored-by: vil02 <vil02@o2.pl>
This commit is contained in:

committed by
GitHub

parent
9dde8a7808
commit
945e7b56bb
22
src/test/java/com/thealgorithms/others/BoyerMooreTest.java
Normal file
22
src/test/java/com/thealgorithms/others/BoyerMooreTest.java
Normal file
@ -0,0 +1,22 @@
|
||||
package com.thealgorithms.others;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
|
||||
public class BoyerMooreTest {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("inputStream")
|
||||
void numberTests(int expected, int[] input) {
|
||||
Assertions.assertEquals(expected, BoyerMoore.findmajor(input));
|
||||
}
|
||||
|
||||
private static Stream<Arguments> inputStream() {
|
||||
return Stream.of(Arguments.of(5, new int[] {5, 5, 5, 2}), Arguments.of(10, new int[] {10, 10, 20}), Arguments.of(10, new int[] {10, 20, 10}), Arguments.of(10, new int[] {20, 10, 10}), Arguments.of(-1, new int[] {10, 10, 20, 20, 30, 30}), Arguments.of(4, new int[] {1, 4, 2, 4, 4, 5, 4}));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user