Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.junit.jupiter.params.ParameterizedTest;
- import org.junit.jupiter.params.provider.Arguments;
- import org.junit.jupiter.params.provider.MethodSource;
- import java.util.Arrays;
- import java.util.List;
- import java.util.stream.Stream;
- import static org.junit.jupiter.api.Assertions.*;
- class SKITH1Test {
- // Interface-based tests
- @ParameterizedTest
- @MethodSource("generateTest1Data")
- void test1(List<String> list1, List<String> list2) {
- List<String> result = SKITH1.commonElements(list1, list2);
- assertTrue(result == null || result.size() > 0);
- }
- @ParameterizedTest
- @MethodSource("generateTest2Data")
- void test2(List<String> list1, List<String> list2) {
- assertNull(SKITH1.commonElements(list1, list2));
- }
- @ParameterizedTest
- @MethodSource("generateTest3Data")
- void test3(List<String> list1, List<String> list2) {
- assertThrows(NullPointerException.class, () -> SKITH1.commonElements(list1, list2));
- }
- @ParameterizedTest
- @MethodSource("generateTest4Data")
- void test4(List<String> list1, List<String> list2) {
- List<String> result = SKITH1.commonElements(list1, list2);
- assertTrue(result == null || result.size() > 0);
- }
- @ParameterizedTest
- @MethodSource("generateTest5Data")
- void test5(List<String> list1, List<String> list2) {
- assertThrows(NullPointerException.class, () -> SKITH1.commonElements(list1, list2));
- }
- static Stream<Arguments> generateTest1Data() {
- return Stream.of(
- Arguments.of(Arrays.asList("a", "b", "c"), Arrays.asList("d", "e", "f")),
- Arguments.of(Arrays.asList("g", "h", "i"), Arrays.asList("j", "k", "l"))
- );
- }
- static Stream<Arguments> generateTest2Data() {
- return Stream.of(
- Arguments.of(Arrays.asList("a", "b", "c"), List.of()),
- Arguments.of(Arrays.asList("a", "b", "c"), List.of()),
- Arguments.of(Arrays.asList("a", "b", "c"), List.of())
- );
- }
- static Stream<Arguments> generateTest3Data() {
- return Stream.of(
- Arguments.of(Arrays.asList("a", "b", "c"), null),
- Arguments.of(Arrays.asList("a", "b", "c"), null),
- Arguments.of(Arrays.asList("a", "b", "c"), null)
- );
- }
- static Stream<Arguments> generateTest4Data() {
- return Stream.of(
- Arguments.of(List.of(), Arrays.asList("a", "b", "c")),
- Arguments.of(List.of(), Arrays.asList("a", "b", "c"))
- );
- }
- static Stream<Arguments> generateTest5Data() {
- return Stream.of(
- Arguments.of(null, Arrays.asList("a", "b", "c")),
- Arguments.of(null, Arrays.asList("a", "b", "c"))
- );
- }
- // Functionality-based tests
- @ParameterizedTest
- @MethodSource("generateTest6Data")
- void test6(List<String> list1, List<String> list2) {
- List<String> result = SKITH1.commonElements(list1, list2);
- assertTrue(result.size() > 1);
- }
- @ParameterizedTest
- @MethodSource("generateTest7Data")
- void test7(List<String> list1, List<String> list2) {
- List<String> result = SKITH1.commonElements(list1, list2);
- assertTrue(result.size() == 1);
- }
- @ParameterizedTest
- @MethodSource("generateTest8Data")
- void test8(List<String> list1, List<String> list2) {
- assertNull(SKITH1.commonElements(list1, list2));
- }
- static Stream<Arguments> generateTest6Data() {
- return Stream.of(
- Arguments.of(Arrays.asList("a", "b", "c"), Arrays.asList("a", "b", "c")),
- Arguments.of(Arrays.asList("a", "b", "c"), Arrays.asList("a", "b", "c"))
- );
- }
- static Stream<Arguments> generateTest7Data() {
- return Stream.of(
- Arguments.of(Arrays.asList("a", "b", "c"), Arrays.asList("a", "d", "f")),
- Arguments.of(Arrays.asList("a", "b", "c"), Arrays.asList("a", "d", "f"))
- );
- }
- static Stream<Arguments> generateTest8Data() {
- return Stream.of(
- Arguments.of(Arrays.asList("a", "b", "c"), Arrays.asList("z", "d", "f")),
- Arguments.of(Arrays.asList("a", "b", "c"), Arrays.asList("z", "d", "f"))
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement