Feel free to use this or ignore and close. I wrote some tests for a function called "removeByIndex" which is similar to "removeAt"
module Tests.Array.Extra exposing (all)
import Array
import Array.Extra exposing (removeByIndex, withDefault)
import Expect
import Test exposing (Test, describe, test)
all : Test
all =
describe "all"
[ describe "removeByIndex"
[ test "typical usage" <|
\_ ->
Expect.equal
(Array.fromList [ 0, 2 ])
(removeByIndex 1 (Array.fromList [ 0, 1, 2 ]))
, test "handles first element deletion" <|
\_ ->
Expect.equal
(Array.fromList [ 1, 2 ])
(removeByIndex 0 (Array.fromList [ 0, 1, 2 ]))
, test "handles last element deletion" <|
\_ ->
Expect.equal
(Array.fromList [ 0, 1 ])
(removeByIndex 2 (Array.fromList [ 0, 1, 2 ]))
, test "ignores index out of bounds - too large" <|
\_ ->
Expect.equal
(Array.fromList [ 0, 1, 2 ])
(removeByIndex 5 (Array.fromList [ 0, 1, 2 ]))
, test "ignores index out of bounds - too small - empty" <|
\_ ->
Expect.equal
Array.empty
(removeByIndex -1 Array.empty)
, test "undefined behavior when index out of bounds - too small - non empty" <|
\_ ->
Expect.notEqual
(Array.fromList [ 0, 1, 2 ])
(removeByIndex -1 (Array.fromList [ 0, 1, 2 ]))
]
]