Tests für Blatt2
This commit is contained in:
parent
2fbe9d5f68
commit
b3fb099758
@ -91,6 +91,7 @@ public class Main {
|
||||
while(iter.hasNext()) {
|
||||
System.out.print(iter.next() + " ");
|
||||
}
|
||||
|
||||
System.out.println();
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ public class RingList<E> implements List<E> {
|
||||
private Wrapper last;
|
||||
private int size;
|
||||
|
||||
RingList() {
|
||||
public RingList() {
|
||||
first = new Wrapper(null);
|
||||
last = first;
|
||||
last.succ = first;
|
||||
|
@ -0,0 +1,41 @@
|
||||
package xyz.joethei.studium.algodat.vorlesung;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import xyz.joethei.studium.algodat.praktikum.blatt2.List;
|
||||
import xyz.joethei.studium.algodat.praktikum.blatt2.RingList;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
class Blatt2Test {
|
||||
|
||||
@Test
|
||||
void add() {
|
||||
List<Integer> rList = new RingList<>();
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
rList.add(i * i);
|
||||
}
|
||||
assertEquals(Optional.of(1), Optional.of(rList.get(0)));
|
||||
assertEquals(Optional.of(4), Optional.of(rList.get(1)));
|
||||
assertEquals(Optional.of(9), Optional.of(rList.get(2)));
|
||||
assertEquals(Optional.of(16), Optional.of(rList.get(3)));
|
||||
assertEquals(Optional.of(25), Optional.of(rList.get(4)));
|
||||
assertEquals(Optional.of(36), Optional.of(rList.get(5)));
|
||||
assertEquals(Optional.of(49), Optional.of(rList.get(6)));
|
||||
assertEquals(Optional.of(64), Optional.of(rList.get(7)));
|
||||
assertEquals(Optional.of(81), Optional.of(rList.get(8)));
|
||||
assertEquals(Optional.of(100), Optional.of(rList.get(9)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void size() {
|
||||
List<Integer> rList = new RingList<>();
|
||||
for (int i = 1; i <= 10; i++) {
|
||||
rList.add(i * i);
|
||||
}
|
||||
assertEquals(10, rList.size());
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user