Skip to content

Commit 1b014a2

Browse files
authored
style: include UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NULL (#7225)
1 parent ba5ccbe commit 1b014a2

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

spotbugs-exclude.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,6 @@
222222
<Match>
223223
<Bug pattern="UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NOT_NULL" />
224224
</Match>
225-
<Match>
226-
<Bug pattern="UTAO_JUNIT_ASSERTION_ODDITIES_USE_ASSERT_NULL" />
227-
</Match>
228225
<Match>
229226
<Bug pattern="UTAO_JUNIT_ASSERTION_ODDITIES_IMPOSSIBLE_NULL" />
230227
</Match>

src/test/java/com/thealgorithms/ciphers/PermutationCipherTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.thealgorithms.ciphers;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertNull;
45
import static org.junit.jupiter.api.Assertions.assertThrows;
56

67
import org.junit.jupiter.api.Test;
@@ -121,8 +122,8 @@ void testNullString() {
121122
String decrypted = cipher.decrypt(encrypted, key);
122123

123124
// then
124-
assertEquals(null, encrypted);
125-
assertEquals(null, decrypted);
125+
assertNull(encrypted);
126+
assertNull(decrypted);
126127
}
127128

128129
@Test

src/test/java/com/thealgorithms/datastructures/trees/TreapTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
44
import static org.junit.jupiter.api.Assertions.assertFalse;
5+
import static org.junit.jupiter.api.Assertions.assertNull;
56

67
import org.junit.jupiter.api.Test;
78

@@ -30,7 +31,7 @@ public void searchAndNotFound() {
3031
treap.insert(3);
3132
treap.insert(8);
3233
treap.insert(1);
33-
assertEquals(null, treap.search(4));
34+
assertNull(treap.search(4));
3435
}
3536

3637
@Test

src/test/java/com/thealgorithms/dynamicprogramming/LongestCommonSubsequenceTest.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.thealgorithms.dynamicprogramming;
22

33
import static org.junit.jupiter.api.Assertions.assertEquals;
4+
import static org.junit.jupiter.api.Assertions.assertNull;
45

56
import org.junit.jupiter.api.Test;
67

@@ -55,27 +56,24 @@ public void testLCSWithBothEmptyStrings() {
5556
public void testLCSWithNullFirstString() {
5657
String str1 = null;
5758
String str2 = "XYZ";
58-
String expected = null; // Should return null if first string is null
5959
String result = LongestCommonSubsequence.getLCS(str1, str2);
60-
assertEquals(expected, result);
60+
assertNull(result);
6161
}
6262

6363
@Test
6464
public void testLCSWithNullSecondString() {
6565
String str1 = "ABC";
6666
String str2 = null;
67-
String expected = null; // Should return null if second string is null
6867
String result = LongestCommonSubsequence.getLCS(str1, str2);
69-
assertEquals(expected, result);
68+
assertNull(result);
7069
}
7170

7271
@Test
7372
public void testLCSWithNullBothStrings() {
7473
String str1 = null;
7574
String str2 = null;
76-
String expected = null; // Should return null if both strings are null
7775
String result = LongestCommonSubsequence.getLCS(str1, str2);
78-
assertEquals(expected, result);
76+
assertNull(result);
7977
}
8078

8179
@Test

0 commit comments

Comments
 (0)