Add automatic linter (#4214)

This commit is contained in:
acbin
2023-06-09 20:05:14 +08:00
committed by GitHub
parent 00282efd8b
commit 415a04ea7f
188 changed files with 661 additions and 1133 deletions

View File

@ -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());
}
}

View File

@ -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

View File

@ -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));
}
}

View File

@ -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));
}
}
}

View File

@ -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"));
}