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

Sign up
Appearance settings

Commit 3961b1d

Browse files
VickySourceDenizAltunkapan
andauthored
fix: revert ReverseStack deletion and verify linting (#6474) (#6494)
* fix: revert ReverseStack deletions and ensure lint compliance * Fix formatting for ReverseStack and test files * Delete ReverseStackUsingRecursion and its test as requested --------- Co-authored-by: Deniz Altunkapan <93663085+DenizAltunkapan@users.noreply.github.com>
1 parent 3f195c2 commit 3961b1d

File tree

4 files changed

+9
-102
lines changed

4 files changed

+9
-102
lines changed

‎src/main/java/com/thealgorithms/datastructures/stacks/ReverseStack.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ private ReverseStack() {
3838
* @param stack the stack to reverse; should not be null
3939
*/
4040
public static void reverseStack(Stack<Integer> stack) {
41+
if (stack == null) {
42+
throw new IllegalArgumentException("Stack cannot be null");
43+
}
4144
if (stack.isEmpty()) {
4245
return;
4346
}

‎src/main/java/com/thealgorithms/others/ReverseStackUsingRecursion.java

Lines changed: 0 additions & 44 deletions
This file was deleted.

‎src/test/java/com/thealgorithms/datastructures/stacks/ReverseStackTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
package com.thealgorithms.datastructures.stacks;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertThrows;
45
import static org.junit.jupiter.api.Assertions.assertTrue;
56

67
import java.util.Stack;
78
import org.junit.jupiter.api.Test;
89

910
class ReverseStackTest {
1011

12+
@Test
13+
void testReverseNullStack() {
14+
assertThrows(IllegalArgumentException.class, () -> ReverseStack.reverseStack(null), "Reversing a null stack should throw an IllegalArgumentException.");
15+
}
16+
1117
@Test
1218
void testReverseEmptyStack() {
1319
Stack<Integer> stack = new Stack<>();

‎src/test/java/com/thealgorithms/others/ReverseStackUsingRecursionTest.java

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /