using Test
import Bresenham

function test_line(args...)
  points = Vector{Tuple{Int, Int}}()
  Bresenham.line(args...) do x, y
    push!(points, (x, y))
  end
  points
end

# Low slope (X major)
@test test_line(1, 1, 5, 3) == [ (1, 1), (2, 1), (3, 2), (4, 2), (5, 3) ]
# Reverse low slope (X major)
@test test_line(5, 3, 1, 1) == reverse!([ (1, 1), (2, 1), (3, 2), (4, 2), (5, 3) ])

# Oblique slope (X major)
@test test_line(1, 1, 5, 5) == [ (1, 1), (2, 2), (3, 3), (4, 4), (5, 5) ]
# Reverse oblique slope (X major)
@test test_line(5, 5, 1, 1) == reverse!([ (1, 1), (2, 2), (3, 3), (4, 4), (5, 5) ])

# High slope (Y major)
@test test_line(1, 1, 3, 5) == [ (1, 1), (1, 2), (2, 3), (2, 4), (3, 5) ]
# Reverse high slope (Y major)
@test test_line(3, 5, 1, 1) == reverse!([ (1, 1), (1, 2), (2, 3), (2, 4), (3, 5) ])

# Horizontal
@test test_line(1, 1, 5, 1) == [ (1, 1), (2, 1), (3, 1), (4, 1), (5, 1) ]
# Reverse horizontal
@test test_line(5, 1, 1, 1) == reverse!([ (1, 1), (2, 1), (3, 1), (4, 1), (5, 1) ])
# Vertical
@test test_line(1, 1, 1, 5) == [ (1, 1), (1, 2), (1, 3), (1, 4), (1, 5) ]
# Reverse vertical
@test test_line(1, 5, 1, 1) == reverse!([ (1, 1), (1, 2), (1, 3), (1, 4), (1, 5) ])
