mirror of
https://github.com/TheAlgorithms/Java.git
synced 2025-07-28 06:55:02 +08:00
Add automatic linter (#4214)
This commit is contained in:
@ -18,8 +18,7 @@ public class HammingDistanceTest {
|
||||
|
||||
@Test
|
||||
void testNotEqualStringLengths() {
|
||||
Exception exception = assertThrows(
|
||||
Exception.class, () -> HammingDistance.calculateHammingDistance("ab", "abc"));
|
||||
Exception exception = assertThrows(Exception.class, () -> HammingDistance.calculateHammingDistance("ab", "abc"));
|
||||
assertEquals("String lengths must be equal", exception.getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -76,8 +76,7 @@ class HorspoolSearchTest {
|
||||
|
||||
@Test
|
||||
void testFindFirstPatternNull() {
|
||||
assertThrows(
|
||||
NullPointerException.class, () -> HorspoolSearch.findFirst(null, "Hello World"));
|
||||
assertThrows(NullPointerException.class, () -> HorspoolSearch.findFirst(null, "Hello World"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -39,9 +39,7 @@ public class LetterCombinationsOfPhoneNumberTest {
|
||||
// "bdg", "bdh", "bdi", "beg", "beh", "bei", "bfg", "bfh", "bfi", "cdg", "cdh",
|
||||
// "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");
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -10,14 +10,12 @@ public class PalindromeTest {
|
||||
|
||||
String[] palindromes = {null, "", "aba", "123321", "kayak"};
|
||||
for (String s : palindromes) {
|
||||
Assertions.assertTrue(Palindrome.isPalindrome(s) && Palindrome.isPalindromeRecursion(s)
|
||||
&& Palindrome.isPalindromeTwoPointer(s));
|
||||
Assertions.assertTrue(Palindrome.isPalindrome(s) && Palindrome.isPalindromeRecursion(s) && Palindrome.isPalindromeTwoPointer(s));
|
||||
}
|
||||
|
||||
String[] notPalindromes = {"abb", "abc", "abc123", "kayaks"};
|
||||
for (String s : notPalindromes) {
|
||||
Assertions.assertFalse(Palindrome.isPalindrome(s) || Palindrome.isPalindromeRecursion(s)
|
||||
|| Palindrome.isPalindromeTwoPointer(s));
|
||||
Assertions.assertFalse(Palindrome.isPalindrome(s) || Palindrome.isPalindromeRecursion(s) || Palindrome.isPalindromeTwoPointer(s));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,14 +9,12 @@ public class PangramTest {
|
||||
@Test
|
||||
public void testPangram() {
|
||||
assertTrue(Pangram.isPangram("The quick brown fox jumps over the lazy dog"));
|
||||
assertFalse(
|
||||
Pangram.isPangram("The quick brown fox jumps over the azy dog")); // L is missing
|
||||
assertFalse(Pangram.isPangram("The quick brown fox jumps over the azy dog")); // L is missing
|
||||
assertFalse(Pangram.isPangram("+-1234 This string is not alphabetical"));
|
||||
assertFalse(Pangram.isPangram("\u0000/\\ Invalid characters are alright too"));
|
||||
|
||||
assertTrue(Pangram.isPangram2("The quick brown fox jumps over the lazy dog"));
|
||||
assertFalse(
|
||||
Pangram.isPangram2("The quick brown fox jumps over the azy dog")); // L is missing
|
||||
assertFalse(Pangram.isPangram2("The quick brown fox jumps over the azy dog")); // L is missing
|
||||
assertFalse(Pangram.isPangram2("+-1234 This string is not alphabetical"));
|
||||
assertFalse(Pangram.isPangram2("\u0000/\\ Invalid characters are alright too"));
|
||||
}
|
||||
|
Reference in New Issue
Block a user