From f35aeb53116e4f99535e516bcb66d043036ace0f Mon Sep 17 00:00:00 2001 From: James Tuong <69408227+Tuong328@users.noreply.github.com> Date: Sat, 22 Oct 2022 15:23:35 -0400 Subject: [PATCH] Add ReverseStringTest (#3607) Co-authored-by: jtuong --- .../strings/ReverseStringTest.java | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/test/java/com/thealgorithms/strings/ReverseStringTest.java diff --git a/src/test/java/com/thealgorithms/strings/ReverseStringTest.java b/src/test/java/com/thealgorithms/strings/ReverseStringTest.java new file mode 100644 index 000000000000..b190a437fa89 --- /dev/null +++ b/src/test/java/com/thealgorithms/strings/ReverseStringTest.java @@ -0,0 +1,31 @@ +package com.thealgorithms.strings; + +import org.junit.jupiter.api.Test; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class ReverseStringTest { + + @Test + public void ReverseStringTest() { + String input1 = "Hello World"; + String input2 = "helloworld"; + String input3 = "123456789"; + String input4 = ""; + + String expectedOutput1 = "dlroW olleH"; + String expectedOutput2 = "dlrowolleh"; + String expectedOutput3 = "987654321"; + String expectedOutput4 = ""; + + assertEquals(ReverseString.reverse(input1), expectedOutput1); + assertEquals(ReverseString.reverse(input2), expectedOutput2); + assertEquals(ReverseString.reverse(input3), expectedOutput3); + assertEquals(ReverseString.reverse(input4), expectedOutput4); + + assertEquals(ReverseString.reverse2(input1), expectedOutput1); + assertEquals(ReverseString.reverse2(input2), expectedOutput2); + assertEquals(ReverseString.reverse2(input3), expectedOutput3); + assertEquals(ReverseString.reverse2(input4), expectedOutput4); + } +}