|
3 | 3 | import static org.junit.jupiter.api.Assertions.assertFalse; |
4 | 4 | import static org.junit.jupiter.api.Assertions.assertTrue; |
5 | 5 |
|
6 | | -import org.junit.jupiter.api.Test; |
7 | | - |
8 | | -public final class IsomorphicTest { |
9 | | - private IsomorphicTest() { |
10 | | - } |
| 6 | +import java.util.stream.Stream; |
11 | 7 |
|
12 | | - @Test |
13 | | - public static void main(String[] args) { |
14 | | - String str1 = "abbbbaac"; |
15 | | - String str2 = "kffffkkd"; |
| 8 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
16 | 9 |
|
17 | | - String str3 = "xyxyxy"; |
18 | | - String str4 = "bnbnbn"; |
19 | | - |
20 | | - String str5 = "ghjknnmm"; |
21 | | - String str6 = "wertpopo"; |
| 10 | +import org.junit.jupiter.api.Test; |
| 11 | +import org.junit.jupiter.params.ParameterizedTest; |
| 12 | +import org.junit.jupiter.params.provider.Arguments; |
| 13 | +import org.junit.jupiter.params.provider.MethodSource; |
22 | 14 |
|
23 | | - String str7 = "aaammmnnn"; |
24 | | - String str8 = "ggghhhbbj"; |
| 15 | +public final class IsomorphicTest { |
25 | 16 |
|
26 | | - assertTrue(Isomorphic.checkStrings(str1, str2)); |
27 | | - assertTrue(Isomorphic.checkStrings(str3, str4)); |
28 | | - assertFalse(Isomorphic.checkStrings(str5, str6)); |
29 | | - assertFalse(Isomorphic.checkStrings(str7, str8)); |
| 17 | + @ParameterizedTest |
| 18 | + @MethodSource("isomorphicProvider") |
| 19 | + public void testCheckStrings(String str1, String str2, boolean expected) { |
| 20 | + assertEquals(expected, Isomorphic.checkStrings(str1, str2)); |
| 21 | + } |
| 22 | + |
| 23 | + private static Stream<Arguments> isomorphicProvider() { |
| 24 | + return Stream.of( |
| 25 | + Arguments.of("abbbbaac", "kffffkkd", true), |
| 26 | + Arguments.of("xyxyxy", "bnbnbn", true), |
| 27 | + Arguments.of("ghjknnmm", "wertpopo", false), |
| 28 | + Arguments.of("aaammmnnn", "ggghhhbbj", false) |
| 29 | + ); |
30 | 30 | } |
31 | 31 | } |
0 commit comments