test: custom linked list get before, after
This commit is contained in:
@@ -7,7 +7,10 @@ import java.util.stream.Stream;
|
|||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.junit.jupiter.params.ParameterizedTest;
|
import org.junit.jupiter.params.ParameterizedTest;
|
||||||
import org.junit.jupiter.params.converter.ConvertWith;
|
import org.junit.jupiter.params.converter.ConvertWith;
|
||||||
|
import org.junit.jupiter.params.provider.Arguments;
|
||||||
import org.junit.jupiter.params.provider.CsvSource;
|
import org.junit.jupiter.params.provider.CsvSource;
|
||||||
|
import org.junit.jupiter.params.provider.MethodSource;
|
||||||
|
import org.junit.jupiter.params.provider.MethodSources;
|
||||||
|
|
||||||
import appointmentplanner.StringArrayConverter;
|
import appointmentplanner.StringArrayConverter;
|
||||||
import appointmentplanner.customlist.CustomLinkedListImpl;
|
import appointmentplanner.customlist.CustomLinkedListImpl;
|
||||||
@@ -61,4 +64,42 @@ public class CustomLinkedListTest {
|
|||||||
assertThat(list.contains(toRemove)).isFalse();
|
assertThat(list.contains(toRemove)).isFalse();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static enum LlGetPosition {
|
||||||
|
BEFORE, AFTER
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String[] someBasicDataSet = new String[] { "O", "MUJ", "BOZE" };
|
||||||
|
|
||||||
|
private static Stream<Arguments> getAfterBeforeData() {
|
||||||
|
return Stream.of(
|
||||||
|
Arguments.of(someBasicDataSet, LlGetPosition.BEFORE, "MUJ", "O"),
|
||||||
|
Arguments.of(someBasicDataSet, LlGetPosition.AFTER, "MUJ", "BOZE"),
|
||||||
|
Arguments.of(someBasicDataSet, LlGetPosition.AFTER, "BOZE", null),
|
||||||
|
Arguments.of(someBasicDataSet, LlGetPosition.BEFORE, "O", null));
|
||||||
|
}
|
||||||
|
|
||||||
|
@ParameterizedTest
|
||||||
|
@MethodSource("getAfterBeforeData")
|
||||||
|
void cllGetAfter_shouldReturnCorrectResult(String[] data, LlGetPosition position, String reference,
|
||||||
|
String expectedResult) {
|
||||||
|
|
||||||
|
CustomLinkedList<String> list = new CustomLinkedListImpl<>();
|
||||||
|
Stream.of(data).forEach(list::add);
|
||||||
|
|
||||||
|
switch (position) {
|
||||||
|
case BEFORE:
|
||||||
|
assertThat(list.getBefore(reference)).isEqualTo(expectedResult);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case AFTER:
|
||||||
|
assertThat(list.getAfter(reference)).isEqualTo(expectedResult);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fail("Incorrect parameters");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user