Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f3e1ef1

Browse filesBrowse files
committed
Add stack code
1 parent a87418f commit f3e1ef1
Copy full SHA for f3e1ef1

2 files changed

+17-15Lines changed: 17 additions & 15 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/test/java/datastructure/stack/MyStackWithArrayListTest.java‎

Copy file name to clipboardExpand all lines: src/test/java/datastructure/stack/MyStackWithArrayListTest.java
+9-7Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ public void test() {
2121
stack.push(5);
2222
stack.push(6);
2323

24-
assertThat(6, is(stack.pop()));
25-
assertThat(5, is(stack.pop()));
26-
assertThat(4, is(stack.pop()));
27-
assertThat(3, is(stack.pop()));
28-
assertThat(2, is(stack.pop()));
29-
assertThat(1, is(stack.pop()));
30-
assertThat(0, is(stack.pop()));
24+
assertThat(stack.pop(), is(6));
25+
assertThat(stack.pop(), is(5));
26+
assertThat(stack.pop(), is(4));
27+
assertThat(stack.pop(), is(3));
28+
assertThat(stack.pop(), is(2));
29+
assertThat(stack.pop(), is(1));
30+
assertThat(stack.pop(), is(0));
31+
// java.lang.ArrayIndexOutOfBoundsException: -1
32+
// assertThat(stack.pop(), is(0));
3133
}
3234

3335
public class MyStackWithArrayList<T> {
Collapse file

‎src/test/java/datastructure/stack/MyStackWithArrayTest.java‎

Copy file name to clipboardExpand all lines: src/test/java/datastructure/stack/MyStackWithArrayTest.java
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ public void test() {
1818
stack.push(5);
1919
stack.push(6);
2020

21-
assertThat(6, is(stack.pop()));
22-
assertThat(5, is(stack.pop()));
23-
assertThat(4, is(stack.pop()));
24-
assertThat(3, is(stack.pop()));
25-
assertThat(2, is(stack.pop()));
26-
assertThat(1, is(stack.pop()));
27-
assertThat(0, is(stack.pop()));
28-
21+
assertThat(stack.pop(), is(6));
22+
assertThat(stack.pop(), is(5));
23+
assertThat(stack.pop(), is(4));
24+
assertThat(stack.pop(), is(3));
25+
assertThat(stack.pop(), is(2));
26+
assertThat(stack.pop(), is(1));
27+
assertThat(stack.pop(), is(0));
28+
2929
// java.lang.RuntimeException: Empty Stack!
3030
// assertThat(0, is(stack.pop()));
3131
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.