- Notifications
You must be signed in to change notification settings - Fork 19.9k
/
Copy pathNonRepeatingElementTest.java
30 lines (23 loc) · 1.15 KB
/
NonRepeatingElementTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
packagecom.thealgorithms.maths;
importstaticorg.junit.jupiter.api.Assertions.assertArrayEquals;
importjava.util.stream.Stream;
importorg.junit.jupiter.api.Test;
importorg.junit.jupiter.params.ParameterizedTest;
importorg.junit.jupiter.params.provider.MethodSource;
publicclassNonRepeatingElementTest {
privaterecordTestData(int[] input, int[] expected) {
}
privatestaticStream<TestData> provideTestCases() {
returnStream.of(newTestData(newint[] {1, 2, 1, 3, 2, 4}, newint[] {3, 4}), newTestData(newint[] {-1, -2, -1, -3, -2, -4}, newint[] {-3, -4}), newTestData(newint[] {-1, 2, 2, -3, -1, 4}, newint[] {-3, 4}));
}
@ParameterizedTest
@MethodSource("provideTestCases")
voidtestFindNonRepeatingElements(TestDatatestData) {
int[] result = NonRepeatingElement.findNonRepeatingElements(testData.input);
assertArrayEquals(testData.expected, result);
}
@Test
publicvoidtestFindNonRepeatingElementsWithLargeNumbers() {
assertArrayEquals(newint[] {200000, 400000}, NonRepeatingElement.findNonRepeatingElements(newint[] {100000, 200000, 100000, 300000, 400000, 300000}));
}
}