44from data_structures .array .static_array import StaticArray
55
66
7- @pytest .fixture (params = [lambda : StaticArray (5 ), DynamicArray ])
7+ @pytest .fixture (params = [lambda : StaticArray (capacity = 5 ), DynamicArray ])
88def arr (request ):
99 return request .param ()
1010
@@ -168,20 +168,20 @@ def test_bool_non_empty(arr):
168168def test_eq_same_elements (arr ):
169169 for v in [1 , 2 , 3 ]:
170170 arr .append (v )
171- other = DynamicArray ([ 1 , 2 , 3 ] )
171+ other = DynamicArray (1 , 2 , 3 )
172172 assert arr == other
173173
174174
175175def test_eq_different_elements (arr ):
176176 for v in [1 , 2 , 3 ]:
177177 arr .append (v )
178- other = DynamicArray ([ 1 , 2 , 4 ] )
178+ other = DynamicArray (1 , 2 , 4 )
179179 assert arr != other
180180
181181
182182def test_eq_different_length (arr ):
183183 arr .append (1 )
184- other = DynamicArray ([ 1 , 2 ] )
184+ other = DynamicArray (1 , 2 )
185185 assert arr != other
186186
187187
@@ -191,8 +191,8 @@ def test_eq_not_array(arr):
191191
192192
193193def test_eq_cross_type ():
194- sa = StaticArray ([ 1 , 2 , 3 ] )
195- da = DynamicArray ([ 1 , 2 , 3 ] )
194+ sa = StaticArray (1 , 2 , 3 )
195+ da = DynamicArray (1 , 2 , 3 )
196196 assert sa == da
197197
198198
@@ -249,72 +249,66 @@ def test_slice_empty_result(arr):
249249
250250
251251def test_static_capacity ():
252- arr = StaticArray (5 )
252+ arr = StaticArray (capacity = 5 )
253253 assert arr .capacity == 5
254254
255255
256256def test_static_zero_capacity_raises ():
257257 with pytest .raises (ValueError ):
258- StaticArray (0 )
258+ StaticArray (capacity = 0 )
259259
260260
261261def test_static_negative_capacity_raises ():
262262 with pytest .raises (ValueError ):
263- StaticArray (- 1 )
263+ StaticArray (capacity = - 1 )
264264
265265
266266def test_static_append_on_full_raises ():
267- arr = StaticArray (3 )
267+ arr = StaticArray (capacity = 3 )
268268 for i in range (3 ):
269269 arr .append (i )
270270 with pytest .raises (OverflowError ):
271271 arr .append (99 )
272272
273273
274274def test_static_insert_on_full_raises ():
275- arr = StaticArray (3 )
275+ arr = StaticArray (capacity = 3 )
276276 for i in range (3 ):
277277 arr .append (i )
278278 with pytest .raises (OverflowError ):
279279 arr .insert (0 , 99 )
280280
281281
282282def test_static_repr ():
283- arr = StaticArray (5 )
283+ arr = StaticArray (capacity = 5 )
284284 arr .append (1 )
285285 arr .append (2 )
286286 assert repr (arr ) == "StaticArray([1, 2])"
287287
288288
289289def test_static_repr_empty ():
290- assert repr (StaticArray (5 )) == "StaticArray([])"
290+ assert repr (StaticArray (capacity = 5 )) == "StaticArray([])"
291291
292292
293293def test_static_str ():
294- arr = StaticArray ([ 1 , 2 , 3 ] )
294+ arr = StaticArray (1 , 2 , 3 )
295295 assert str (arr ) == "[1, 2, 3]"
296296
297297
298298def test_static_str_empty ():
299- assert str (StaticArray (5 )) == "[]"
299+ assert str (StaticArray (capacity = 5 )) == "[]"
300300
301301
302- def test_static_init_from_list ():
303- arr = StaticArray ([ 10 , 20 , 30 ] )
302+ def test_static_init_from_args ():
303+ arr = StaticArray (10 , 20 , 30 )
304304 assert list (arr ) == [10 , 20 , 30 ]
305305 assert arr .capacity == 3
306306 assert len (arr ) == 3
307307
308308
309- def test_static_init_from_iterable ():
310- arr = StaticArray (range (4 ))
311- assert list (arr ) == [0 , 1 , 2 , 3 ]
312- assert arr .capacity == 4
313-
314-
315- def test_static_init_empty_iterable_raises ():
316- with pytest .raises (ValueError ):
317- StaticArray ([])
309+ def test_static_init_no_args_raises ():
310+ with pytest .raises (TypeError ):
311+ StaticArray ()
318312
319313
320314# ── DynamicArray-specific tests ──────────────────────────────────────
@@ -388,32 +382,27 @@ def test_dynamic_repr_empty():
388382
389383
390384def test_dynamic_str ():
391- arr = DynamicArray ([ 1 , 2 , 3 ] )
385+ arr = DynamicArray (1 , 2 , 3 )
392386 assert str (arr ) == "[1, 2, 3]"
393387
394388
395389def test_dynamic_str_empty ():
396390 assert str (DynamicArray ()) == "[]"
397391
398392
399- def test_dynamic_init_from_list ():
400- arr = DynamicArray ([ 10 , 20 , 30 ] )
393+ def test_dynamic_init_from_args ():
394+ arr = DynamicArray (10 , 20 , 30 )
401395 assert list (arr ) == [10 , 20 , 30 ]
402396 assert len (arr ) == 3
403397
404398
405- def test_dynamic_init_from_iterable ():
406- arr = DynamicArray (range (4 ))
407- assert list (arr ) == [0 , 1 , 2 , 3 ]
408-
409-
410- def test_dynamic_init_empty_iterable ():
411- arr = DynamicArray ([])
399+ def test_dynamic_init_empty ():
400+ arr = DynamicArray ()
412401 assert arr .is_empty ()
413402 assert arr .capacity == 4
414403
415404
416405def test_dynamic_init_large_sets_capacity ():
417- arr = DynamicArray (range (10 ))
406+ arr = DynamicArray (* range (10 ))
418407 assert arr .capacity >= 10
419408 assert len (arr ) == 10
0 commit comments