Fix ReverseWords class and test (#2077)
This commit is contained in:
parent
09765b8ab4
commit
bd60e13d79
@ -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();
|
||||||
|
|
||||||
|
@ -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");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user