Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ReverseStringTest for both implementations of reverse #3607

Merged
merged 3 commits into from
Oct 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/test/java/com/thealgorithms/strings/ReverseStringTest.java
Original file line number Diff line number Diff line change
@@ -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);
}
}