@@ -124,37 +124,4 @@ public void testEmptyCacheBehavior() {
124
124
mruCache .put (1 , 10 );
125
125
assertEquals (10 , mruCache .get (1 ));
126
126
}
127
-
128
- @ Test
129
- public void capacityValidation () {
130
- // Check that an exception is thrown for invalid capacities
131
- Exception exception = null ;
132
-
133
- // Testing for zero capacity
134
- try {
135
- new MRUCache <>(0 ); // Should throw an exception
136
- // If no exception is thrown, we should fail the test
137
- fail ("Expected IllegalArgumentException for capacity 0" );
138
- } catch (IllegalArgumentException e ) {
139
- exception = e ; // Store the exception if caught
140
- }
141
-
142
- // Ensure exception is not null and check the message
143
- assertNotNull (exception , "Expected IllegalArgumentException for capacity 0" );
144
- assertEquals ("Capacity must be greater than 0!" , exception .getMessage ());
145
-
146
- // Resetting exception for the next test
147
- // Testing for negative capacity
148
- try {
149
- new MRUCache <>(-1 ); // Should throw an exception
150
- // If no exception is thrown, we should fail the test
151
- fail ("Expected IllegalArgumentException for capacity -1" );
152
- } catch (IllegalArgumentException e ) {
153
- exception = e ; // Store the exception if caught
154
- }
155
-
156
- // Ensure exception is not null and check the message
157
- assertNotNull (exception , "Expected IllegalArgumentException for capacity -1" );
158
- assertEquals ("Capacity must be greater than 0!" , exception .getMessage ());
159
- }
160
127
}
0 commit comments