Code cleanup (#4246)

This commit is contained in:
HManiac74
2023-07-22 17:23:00 +02:00
committed by GitHub
parent 3facb0d862
commit 2488a2ad51
52 changed files with 50 additions and 167 deletions

View File

@ -2,7 +2,6 @@ package com.thealgorithms.strings;
import static org.junit.jupiter.api.Assertions.*;
import java.util.*;
import org.junit.jupiter.api.Test;
public class IsomorphicTest {
@ -21,11 +20,9 @@ public class IsomorphicTest {
String str7 = "aaammmnnn";
String str8 = "ggghhhbbj";
Isomorphic isomorphic = new Isomorphic();
assertTrue(isomorphic.checkStrings(str1, str2));
assertTrue(isomorphic.checkStrings(str3, str4));
assertFalse(isomorphic.checkStrings(str5, str6));
assertFalse(isomorphic.checkStrings(str7, str8));
assertTrue(Isomorphic.checkStrings(str1, str2));
assertTrue(Isomorphic.checkStrings(str3, str4));
assertFalse(Isomorphic.checkStrings(str5, str6));
assertFalse(Isomorphic.checkStrings(str7, str8));
}
}

View File

@ -9,29 +9,28 @@ public class LetterCombinationsOfPhoneNumberTest {
@Test
public void letterCombinationsOfPhoneNumber() {
LetterCombinationsOfPhoneNumber ob = new LetterCombinationsOfPhoneNumber();
ob.generateNumberToCharMap();
LetterCombinationsOfPhoneNumber.generateNumberToCharMap();
// ** Test 1 **
// Input: digits = ""
// Output: []
int[] numbers1 = {};
List<String> output1 = Arrays.asList("");
assertTrue(ob.printWords(numbers1, numbers1.length, 0, "").equals(output1));
assertTrue(LetterCombinationsOfPhoneNumber.printWords(numbers1, numbers1.length, 0, "").equals(output1));
// ** Test 2 **
// Input: digits = "2"
// Output: ["a","b","c"]
int[] numbers2 = {2};
List<String> output2 = Arrays.asList("a", "b", "c");
assertTrue(ob.printWords(numbers2, numbers2.length, 0, "").equals(output2));
assertTrue(LetterCombinationsOfPhoneNumber.printWords(numbers2, numbers2.length, 0, "").equals(output2));
// ** Test 3 **
// Input: digits = "23"
// Output: ["ad","ae","af","bd","be","bf","cd","ce","cf"]
int[] numbers3 = {2, 3};
List<String> output3 = Arrays.asList("ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf");
assertTrue(ob.printWords(numbers3, numbers3.length, 0, "").equals(output3));
assertTrue(LetterCombinationsOfPhoneNumber.printWords(numbers3, numbers3.length, 0, "").equals(output3));
// ** Test 4 **
// Input: digits = "234"
@ -40,6 +39,6 @@ public class LetterCombinationsOfPhoneNumberTest {
// "cdi", "ceg", "ceh", "cei", "cfg", "cfh", "cfi"]
int[] numbers4 = {2, 3, 4};
List<String> output4 = Arrays.asList("adg", "adh", "adi", "aeg", "aeh", "aei", "afg", "afh", "afi", "bdg", "bdh", "bdi", "beg", "beh", "bei", "bfg", "bfh", "bfi", "cdg", "cdh", "cdi", "ceg", "ceh", "cei", "cfg", "cfh", "cfi");
assertTrue(ob.printWords(numbers4, numbers4.length, 0, "").equals(output4));
assertTrue(LetterCombinationsOfPhoneNumber.printWords(numbers4, numbers4.length, 0, "").equals(output4));
}
}

View File

@ -10,7 +10,7 @@ public class ReverseStringRecursiveTest {
@Test
void shouldAcceptWhenEmptyStringIsPassed() {
String expected = "";
String reversed = stringRecursive.reverse("");
String reversed = ReverseStringRecursive.reverse("");
assertEquals(expected, reversed);
}
@ -18,7 +18,7 @@ public class ReverseStringRecursiveTest {
@Test
void shouldAcceptNotWhenWhenSingleCharacterIsPassed() {
String expected = "a";
String reversed = stringRecursive.reverse("a");
String reversed = ReverseStringRecursive.reverse("a");
assertEquals(expected, reversed);
}
@ -26,7 +26,7 @@ public class ReverseStringRecursiveTest {
@Test
void shouldAcceptWhenStringIsPassed() {
String expected = "dlroWolleH";
String reversed = stringRecursive.reverse("HelloWorld");
String reversed = ReverseStringRecursive.reverse("HelloWorld");
assertEquals(expected, reversed);
}