fix: placement and tests

This commit is contained in:
2026-04-17 01:09:22 +03:30
parent 636de18d6c
commit 87affb5e56
8 changed files with 20 additions and 36 deletions
+73
View File
@@ -0,0 +1,73 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.List;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class BonusTestPalindromes {
static BonusExercises ex;
@BeforeAll
static void setUp() {
ex = new BonusExercises();
}
@Test
void testPalindrome0() {
String input = "madam racecar level";
// palindrome words
List<String> expected = new ArrayList<>();
expected.add("madam");
expected.add("racecar");
expected.add("level");
assertEquals(expected, ex.findPalindromes(input));
}
@Test
void testPalindrome1() {
String input = "hello world";
// palindrome words
List<String> expected = new ArrayList<>();
assertEquals(expected, ex.findPalindromes(input));
}
@Test
void testPalindrome2() {
String input = "Step on no pets";
// palindrome words
List<String> expected = new ArrayList<>();
assertEquals(expected, ex.findPalindromes(input));
}
@Test
void testPalindrome3() {
String input = """
Madam, did you see Bob running? I asked Kayak and radar to wait at the civic center.\s
The level of security was high, but I noticed a racecar driving past. A deed was done in the noon,\s
and many said it was a referable situation.
""";
// palindrome words
List<String> expected = new ArrayList<>();
expected.add("Madam");
expected.add("did");
expected.add("Bob");
expected.add("Kayak");
expected.add("radar");
expected.add("civic");
expected.add("level");
expected.add("racecar");
expected.add("deed");
expected.add("noon");
assertEquals(expected, ex.findPalindromes(input));
}
}