mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-12-19 07:00:35 +08:00
Add ReverseStringUsingStack (#6452)
* Refactored ReverseStringUsingStack * Add ReverseStringUsingStack * Refactored ReverseStringUsingStack * Closes #6451
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
package com.thealgorithms.strings;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
@@ -31,4 +33,15 @@ public class ReverseStringTest {
|
||||
public void testReverseString3(String input, String expectedOutput) {
|
||||
assertEquals(expectedOutput, ReverseString.reverse3(input));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("testCases")
|
||||
public void testReverseStringUsingStack(String input, String expectedOutput) {
|
||||
assertEquals(expectedOutput, ReverseString.reverseStringUsingStack(input));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReverseStringUsingStackWithNullInput() {
|
||||
assertThrows(IllegalArgumentException.class, () -> ReverseString.reverseStringUsingStack(null));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user