figure out further issues in get
parent
2186d69d2a
commit
7da990be18
|
@ -159,7 +159,9 @@ cropWrapping bounds (Grid grid) =
|
|||
|
||||
get : { row : Int, column : Int } -> Grid a -> Maybe a
|
||||
get coords (Grid { items, width }) =
|
||||
if coords.row < 0 || coords.column < 0 then
|
||||
-- we don't need to check row; a row above the max will be a Nothing in the
|
||||
-- lookup below anyway.
|
||||
if coords.row < 0 || coords.column < 0 || coords.column > width - 1 then
|
||||
Nothing
|
||||
|
||||
else
|
||||
|
|
|
@ -111,6 +111,28 @@ compatibilityTest =
|
|||
|> Grid.toArrays
|
||||
in
|
||||
Expect.equal expected actual
|
||||
, fuzz2
|
||||
(Fuzz.map2 (\rows columns -> { rows = rows, columns = columns })
|
||||
(Fuzz.intRange 0 2)
|
||||
(Fuzz.intRange 0 2)
|
||||
)
|
||||
(Fuzz.map2 (\row column -> { row = row, column = column })
|
||||
(Fuzz.intRange -1 3)
|
||||
(Fuzz.intRange -1 3)
|
||||
)
|
||||
"get"
|
||||
<|
|
||||
\size coords ->
|
||||
let
|
||||
expected =
|
||||
SlowGrid.initialize size identity
|
||||
|> SlowGrid.get coords
|
||||
|
||||
actual =
|
||||
Grid.initialize size identity
|
||||
|> Grid.get coords
|
||||
in
|
||||
Expect.equal expected actual
|
||||
]
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue