test: cll iterator
This commit is contained in:
@@ -144,6 +144,22 @@ public class CustomLinkedListTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
void cllIterate_shouldPerformCorrectIteration() {
|
||||
|
||||
String[] data = new String[] { "Ahoj", "jak", "se", "mas", "?" };
|
||||
|
||||
CustomLinkedList<String> list = initPopulatedList(data);
|
||||
|
||||
int counter = data.length - 1;
|
||||
|
||||
for (String element : list) {
|
||||
assertThat(element).isEqualTo(data[counter]);
|
||||
counter--;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private CustomLinkedList<String> initPopulatedList(String[] initData) {
|
||||
CustomLinkedList<String> list = new CustomLinkedListImpl<>();
|
||||
Stream.of(initData).forEach(list::add);
|
||||
|
||||
Reference in New Issue
Block a user