File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed
src/test/java/com/thealgorithms/datastructures/caches Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff 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}
You can’t perform that action at this time.
0 commit comments