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