File tree 1 file changed +8
-2
lines changed
src/test/java/com/thealgorithms/datastructures/caches
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -138,7 +138,10 @@ public void capacityValidation() {
138
138
139
139
// Ensure exception is not null before accessing its message
140
140
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
+ }
142
145
143
146
// Resetting exception for the next test
144
147
exception = null ;
@@ -152,6 +155,9 @@ public void capacityValidation() {
152
155
153
156
// Ensure exception is not null before accessing its message
154
157
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
+ }
156
162
}
157
163
}
You can’t perform that action at this time.
0 commit comments