module Line.DrawSpec where import Line.Draw import Test.Hspec main :: IO () main = hspec spec spec :: Spec spec = do describe "bresenham" $ do it "rasterises a simple line" $ bresenham (0 :: Int, 0) (4, 4) `shouldBe` [(0,0), (1,1), (2,2), (3,3), (4,4)] it "rasterises a simple line starting from (1, 1)" $ bresenham (1 :: Int, 1) (4, 4) `shouldBe` [(1,1), (2,2), (3,3), (4,4)] it "rasterises a line" $ bresenham (0 :: Int, 0) (4, 2) `shouldBe` [(0,0), (1,0), (2,1), (3,1), (4,2)] it "rasterises a line, quadrant 2, m<1" $ bresenham (0 :: Int, 0) (-4, 2) `shouldBe` [(0,0), (-1,0), (-2,1), (-3,1), (-4,2)] it "rasterises a line, quadrant 3, m<1" $ bresenham (0 :: Int, 0) (-4, -2) `shouldBe` [(0,0), (-1,0), (-2,-1), (-3,-1), (-4,-2)] it "rasterises a line, quadrant 1, m>1" $ bresenham (0 :: Int, 0) (2, 4) `shouldBe` [(0,0), (0,1), (1,2), (1,3), (2,4)] it "rasterises a line, quadrant 4, m>1" $ bresenham (0 :: Int, 0) (2, -4) `shouldBe` [(0,0), (0,-1), (1,-2), (1,-3), (2,-4)]