Fix ReverseWords class and test (#2077)

This commit is contained in:
Jake Antonio Ruiz Zeledón 2021-01-04 06:15:31 -06:00 committed by GitHub
parent 09765b8ab4
commit bd60e13d79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 7 deletions

View File

@ -1,4 +1,4 @@
package com.strings; package com.string;
public class ReverseWords { public class ReverseWords {
/** /**
@ -8,7 +8,7 @@ public class ReverseWords {
* @return the {@code String}, converted to a string with reveresed words. * @return the {@code String}, converted to a string with reveresed words.
*/ */
public String returnReverseWords(String s) { public static String returnReverseWords(String s) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
StringBuilder word = new StringBuilder(); StringBuilder word = new StringBuilder();

View File

@ -3,13 +3,11 @@ package com.string;
import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
class ReveresWordsTest { class ReverseWordsTest extends ReverseWords {
@Test @Test
void testReverseWords() { void testReverseWords() {
ReverseWords reverseWords = new ReverseWords(); Assertions.assertEquals(true, returnReverseWords("this is my car").equals("siht si ym rac"), "Correct");
Assertions.assertEquals(true, reverseWords.returnReverseWords("this is my car"), "siht si ym rac"); Assertions.assertEquals(true, returnReverseWords("ABC 123").equals("CBA 321"), "Correct");
Assertions.assertEquals(true, reverseWords.returnReverseWords("ABC 123"), "CBA 321");
} }
} }