-
Notifications
You must be signed in to change notification settings - Fork 19.7k
/
Copy pathAbbreviationTest.java
44 lines (32 loc) · 1.57 KB
/
AbbreviationTest.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
35
36
37
38
39
40
41
42
43
44
package com.thealgorithms.dynamicprogramming;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
public class AbbreviationTest {
@ParameterizedTest
@MethodSource("provideTestCases")
public void testAbbreviation(String a, String b, boolean expected) {
assertEquals(expected, Abbreviation.abbr(a, b));
}
private static Stream<Arguments> provideTestCases() {
return Stream.of(
// Example test case from problem description
Arguments.of("daBcd", "ABC", Boolean.TRUE),
// Test case where transformation is impossible
Arguments.of("dBcd", "ABC", Boolean.FALSE),
// Test case with exact match (all uppercase)
Arguments.of("ABC", "ABC", Boolean.TRUE),
// Test case where input string contains all required letters plus extra lowercase letters
Arguments.of("aAbBcC", "ABC", Boolean.TRUE),
// Test case with only lowercase letters in input
Arguments.of("abcd", "ABCD", Boolean.TRUE),
// Test case with an empty second string (b)
Arguments.of("abc", "", Boolean.TRUE),
// Test case with an empty first string (a) but non-empty second string (b)
Arguments.of("", "A", Boolean.FALSE),
// Complex case with interleaved letters
Arguments.of("daBcAbCd", "ABCD", Boolean.FALSE));
}
}