mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-05 00:14:33 +08:00
tests: properly test Isomorphic
(#6259)
Fixes #6258 --------- Co-authored-by: Piotr Idzik <65706193+vil02@users.noreply.github.com>
This commit is contained in:
@ -1,31 +1,23 @@
|
||||
package com.thealgorithms.strings;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
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 final class IsomorphicTest {
|
||||
private IsomorphicTest() {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource("inputs")
|
||||
public void testCheckStrings(String str1, String str2, Boolean expected) {
|
||||
assertEquals(expected, Isomorphic.checkStrings(str1, str2));
|
||||
assertEquals(expected, Isomorphic.checkStrings(str2, str1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public static void main(String[] args) {
|
||||
String str1 = "abbbbaac";
|
||||
String str2 = "kffffkkd";
|
||||
|
||||
String str3 = "xyxyxy";
|
||||
String str4 = "bnbnbn";
|
||||
|
||||
String str5 = "ghjknnmm";
|
||||
String str6 = "wertpopo";
|
||||
|
||||
String str7 = "aaammmnnn";
|
||||
String str8 = "ggghhhbbj";
|
||||
|
||||
assertTrue(Isomorphic.checkStrings(str1, str2));
|
||||
assertTrue(Isomorphic.checkStrings(str3, str4));
|
||||
assertFalse(Isomorphic.checkStrings(str5, str6));
|
||||
assertFalse(Isomorphic.checkStrings(str7, str8));
|
||||
private static Stream<Arguments> inputs() {
|
||||
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),
|
||||
Arguments.of("aaammmnnn", "ggghhhbbj", Boolean.FALSE));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user