The queen attack exercise instructions are about standard 8x8 chessboard.
a b c d e f g h
8 _ _ _ _ _ _ _ _ 8
7 _ _ _ _ _ _ _ _ 7
6 _ _ _ _ _ _ _ _ 6
5 _ _ W _ _ _ _ _ 5
4 _ _ _ _ _ _ _ _ 4
3 _ _ _ _ _ _ _ _ 3
2 _ _ _ _ _ B _ _ 2
1 _ _ _ _ _ _ _ _ 1
a b c d e f g h
Illustration shows that the correct indexes are from 1 to 8 inclusive.
But the tests are expecting errors when a row or a column is equal to 8.
it('queen must have row on board', function()
assert.has_error(function()
Queen({ row = 8, column = 4 })
end)
end)
it('queen must have column on board', function()
assert.has_error(function()
Queen({ row = 4, column = 8 })
end)
end)
I feel like these tests were originally written for a language with 0-based indexing. Simple fix would be to change 8 to 9. And there also should be checks for zero values, which are absent now.