on 396eb06 help sign in
33 lines 1.2 kB history raw
1module Test.TypeRep.Map where
3import Prelude hiding (lookup)
5import Test.Tasty.Hspec
7import Data.TypeRep.Map
9-- Simple test for 'lookup', 'insert' and 'size' functions.
10spec_insertLookup :: Spec
11spec_insertLookup = do
12 describe "Lookup Test" $ do
13 it "returns the inserted element" $
14 lookup (insert 'a' empty) `shouldBe` Just 'a'
15 it "returns the second inserted value of the same type" $
16 lookup (insert 'b' $ insert 'a' empty) `shouldBe` Just 'b'
18 describe "Size Test" $ do
19 it "is empty" $
20 size empty `shouldBe` 0
21 it "is of size 1 when 1 element inserted" $
22 size (insert 'a' empty) `shouldBe` 1
23 it "doesn't increase size when element of the same type is added" $
24 size (insert 'b' $ insert 'a' empty) `shouldBe` 1
25 it "returns 10 when 10 different types are inserted" $
26 size mapOf10 `shouldBe` 10
29mapOf10 :: TypeRepMap
30mapOf10 = insert True $ insert [True, False] $ insert (Just True)
31 $ insert (Just ()) $ insert [()] $ insert ()
32 $ insert "aaa" $ insert (Just 'a') $ insert 'a'
33 $ insert (11 :: Int) empty