Skip to content

Commit 5978973

Browse files
test: add unit tests for StackUsingLinkedList
1 parent 5b327c8 commit 5978973

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/test/java/com/thealgorithms/stacks/StackUsingLinkedListTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,10 @@ public void testSize() {
4949
public void testPopOnEmptyStack() {
5050
assertThrows(RuntimeException.class, () -> stack.pop());
5151
}
52+
@Test
53+
public void testPeekOnEmptyStackThrowsException() {
54+
RuntimeException exception =
55+
assertThrows(RuntimeException.class, () -> stack.peek());
56+
assertEquals("Stack is empty", exception.getMessage());
57+
}
5258
}

0 commit comments

Comments
 (0)