Skip to content

Commit cdb28e9

Browse files
authored
validate popping & shifting from empty linkedlist (exercism#2332)
1 parent 940bb71 commit cdb28e9

1 file changed

Lines changed: 44 additions & 0 deletions

File tree

exercises/practice/linked-list/src/test/java/DoublyLinkedListTest.java

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,17 @@ public void testPushPop() {
1818
assertThat(list.pop()).isEqualTo(10);
1919
}
2020

21+
@Ignore("Remove to run test")
22+
@Test
23+
public void testPushOncePopTwice() {
24+
DoublyLinkedList<Integer> list = new DoublyLinkedList<>();
25+
26+
list.push(10);
27+
28+
assertThat(list.pop()).isEqualTo(10);
29+
assertThat(list.pop()).isNull();
30+
}
31+
2132
@Ignore("Remove to run test")
2233
@Test
2334
public void testPushShift() {
@@ -32,6 +43,17 @@ public void testPushShift() {
3243
assertThat(list.shift()).isEqualTo("30");
3344
}
3445

46+
@Ignore("Remove to run test")
47+
@Test
48+
public void testPushPopShift() {
49+
DoublyLinkedList<Integer> list = new DoublyLinkedList<>();
50+
51+
list.push(10);
52+
53+
assertThat(list.pop()).isEqualTo(10);
54+
assertThat(list.shift()).isNull();
55+
}
56+
3557
@Ignore("Remove to run test")
3658
@Test
3759
public void testUnshiftShift() {
@@ -46,6 +68,17 @@ public void testUnshiftShift() {
4668
assertThat(list.shift()).isEqualTo('1');
4769
}
4870

71+
@Ignore("Remove to run test")
72+
@Test
73+
public void testUnshiftOnceShiftTwice() {
74+
DoublyLinkedList<String> list = new DoublyLinkedList<>();
75+
76+
list.unshift("10");
77+
78+
assertThat(list.shift()).isEqualTo("10");
79+
assertThat(list.shift()).isNull();
80+
}
81+
4982
@Ignore("Remove to run test")
5083
@Test
5184
public void testUnshiftPop() {
@@ -60,6 +93,17 @@ public void testUnshiftPop() {
6093
assertThat(list.pop()).isEqualTo(30);
6194
}
6295

96+
@Ignore("Remove to run test")
97+
@Test
98+
public void testUnshiftShiftPop() {
99+
DoublyLinkedList<Integer> list = new DoublyLinkedList<>();
100+
101+
list.unshift(10);
102+
103+
assertThat(list.shift()).isEqualTo(10);
104+
assertThat(list.pop()).isNull();
105+
}
106+
63107
@Ignore("Remove to run test")
64108
@Test
65109
public void testExample() {

0 commit comments

Comments
 (0)