-
Notifications
You must be signed in to change notification settings - Fork 0
/
MinCharsForPalindrome.test.java
34 lines (27 loc) · 1.22 KB
/
MinCharsForPalindrome.test.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class MinCharsForPalindromeTest {
@Test
public void testFindMinInsertions() {
assertEquals(1, MinCharsForPalindrome.findMinInsertions("ABCAB"));
assertEquals(3, MinCharsForPalindrome.findMinInsertions("ABC"));
assertEquals(0, MinCharsForPalindrome.findMinInsertions("ABCBA"));
assertEquals(2, MinCharsForPalindrome.findMinInsertions("AACECAAAA"));
}
@Test
public void testLongestCommonSubsequence() {
assertEquals(3, MinCharsForPalindrome.longestCommonSubsequence("ABCAB", "BACBA"));
assertEquals(1, MinCharsForPalindrome.longestCommonSubsequence("A", "A"));
assertEquals(0, MinCharsForPalindrome.longestCommonSubsequence("A", "B"));
assertEquals(3, MinCharsForPalindrome.longestCommonSubsequence("AGGTAB", "GXTXAYB"));
}
@Test
public void testFindMinInsertions_Empty() {
assertEquals(0, MinCharsForPalindrome.findMinInsertions(""));
}
@Test
public void testFindMinInsertions_SingleCharacter() {
assertEquals(0, MinCharsForPalindrome.findMinInsertions("A"));
}
// ... Additional test cases as necessary ...
}