diff options
Diffstat (limited to 'test/System/Utility/H9Clock')
| -rw-r--r-- | test/System/Utility/H9Clock/DrawSpec.hs | 30 | ||||
| -rw-r--r-- | test/System/Utility/H9Clock/Test/Util.hs | 34 | ||||
| -rw-r--r-- | test/System/Utility/H9Clock/TypeSpec.hs | 17 |
3 files changed, 81 insertions, 0 deletions
diff --git a/test/System/Utility/H9Clock/DrawSpec.hs b/test/System/Utility/H9Clock/DrawSpec.hs new file mode 100644 index 0000000..48d026c --- /dev/null +++ b/test/System/Utility/H9Clock/DrawSpec.hs @@ -0,0 +1,30 @@ +module System.Utility.H9Clock.DrawSpec + ( spec + ) +where + +import Test.Hspec +import System.Utility.H9Clock +import System.Utility.H9Clock.Test.Util + +spec :: Spec +spec = do + let rect = Rectangle (0, 0) (250, 250) + describe "mkHandPts" $ do + it "should create hourHand and minHand points" $ do + mkHandsPts rect 16 30 `shouldBe` handPts + + describe "Clock color" $ do + context "of the hour hand" $ do + it "should be Dark Blue" $ do + getRGB darkBlue `shouldBe` (0, 0, 85) + context "of the min hand" $ do + it "should be Pale Blue" $ do + getRGB paleBlue `shouldBe` (0, 0, 187) + context "of the background" $ do + it "should be Pale Blue Green" $ do + getRGB paleBlueGreen `shouldBe` (236, 254, 252) + + describe "Clock dots" $ do + it "should be produced by 23 points" $ do + dotsPts 4 4 rect `shouldBe` dPts diff --git a/test/System/Utility/H9Clock/Test/Util.hs b/test/System/Utility/H9Clock/Test/Util.hs new file mode 100644 index 0000000..96780f0 --- /dev/null +++ b/test/System/Utility/H9Clock/Test/Util.hs @@ -0,0 +1,34 @@ +module System.Utility.H9Clock.Test.Util + ( + handPts + , getRGB + , dPts + ) +where + +import Graphics.HGL + +handPts :: ([Point], [Point]) +handPts = (hourHandPts, minHandPts) + +minHandPts = [(125,125),(128,128),(128,215),(125,212)] +hourHandPts = [(125,125),(128,128),(167,171),(164,168)] + +dPts :: [(Point, Point)] +dPts = [ + ((238,129),(246,121)) + ,((222,71),(230,63)) + ,((180,28),(188,20)) + ,((121,12),(129,4)) + ,((63,28),(71,20)) + ,((20,71),(28,63)) + ,((4,129),(12,121)) + ,((20,188),(28,180)) + ,((62,230),(70,222)) + ,((121,246),(129,238)) + ,((180,230),(188,222)) + ,((222,188),(230,180)) + ] + +getRGB (RGB r g b) = (r, g, b) + diff --git a/test/System/Utility/H9Clock/TypeSpec.hs b/test/System/Utility/H9Clock/TypeSpec.hs new file mode 100644 index 0000000..1d4334d --- /dev/null +++ b/test/System/Utility/H9Clock/TypeSpec.hs @@ -0,0 +1,17 @@ +module System.Utility.H9Clock.TypeSpec + ( spec + ) +where + +import Test.Hspec +import System.Utility.H9Clock + +spec :: Spec +spec = do + let rect = Rectangle (0, 0) (250, 250) + describe "the Rectangle record" $ do + it "should have a string representation" $ do + show rect + `shouldBe` "Rectangle {min = (0,0), max = (250,250)}" + it "should have a equal instance" $ do + rect `shouldBe` rect |
