Skip to content

Commit 1661b83

Browse files
committed
Fix
1 parent 540eeaa commit 1661b83

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/test/java/com/thealgorithms/datastructures/caches/MRUCacheTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,10 @@ public void capacityValidation() {
138138

139139
// Ensure exception is not null before accessing its message
140140
assertNotNull(exception, "Expected IllegalArgumentException for capacity 0");
141-
assertEquals("Capacity must be greater than 0!", exception.getMessage());
141+
142+
if (exception != null) {
143+
assertEquals("Capacity must be greater than 0!", exception.getMessage());
144+
}
142145

143146
// Resetting exception for the next test
144147
exception = null;
@@ -152,6 +155,9 @@ public void capacityValidation() {
152155

153156
// Ensure exception is not null before accessing its message
154157
assertNotNull(exception, "Expected IllegalArgumentException for capacity -1");
155-
assertEquals("Capacity must be greater than 0!", exception.getMessage());
158+
159+
if (exception != null) {
160+
assertEquals("Capacity must be greater than 0!", exception.getMessage());
161+
}
156162
}
157163
}

0 commit comments

Comments
 (0)