@@ -0,0 +1,65 @@
1+module Servant.Common.TextSpec where
3+import Servant.Common.Text
6+import Test.QuickCheck.Instances ()
7+import Data.Int ( Int8, Int16, Int32, Int64 )
8+import Data.Text ( Text )
9+import Data.Word ( Word, Word8, Word16, Word32, Word64 )
12+spec = describe "Servant.Common.Text" $ do
14+ context "FromText and ToText laws" $ do
16+ it "holds for Text" $
17+ property $ \x -> textLaw (x :: Text)
19+ it "holds for String" $
20+ property $ \x -> textLaw (x :: String)
22+ it "holds for Bool" $
23+ property $ \x -> textLaw (x :: Bool)
26+ property $ \x -> textLaw (x :: Int)
28+ it "holds for Int8" $
29+ property $ \x -> textLaw (x :: Int8)
31+ it "holds for Int16" $
32+ property $ \x -> textLaw (x :: Int16)
34+ it "holds for Int32" $
35+ property $ \x -> textLaw (x :: Int32)
37+ it "holds for Int64" $
38+ property $ \x -> textLaw (x :: Int64)
40+ it "holds for Word" $
41+ property $ \x -> textLaw (x :: Word)
43+ it "holds for Word8" $
44+ property $ \x -> textLaw (x :: Word8)
46+ it "holds for Word16" $
47+ property $ \x -> textLaw (x :: Word16)
49+ it "holds for Word32" $
50+ property $ \x -> textLaw (x :: Word32)
52+ it "holds for Word64" $
53+ property $ \x -> textLaw (x :: Word64)
55+ it "holds for Integer" $
56+ property $ \x -> textLaw (x :: Integer)
58+ it "holds for Double" $
59+ property $ \x -> textLaw (x :: Double)
61+ it "holds for Float" $
62+ property $ \x -> textLaw (x :: Float)
64+textLaw :: (FromText a, ToText a, Eq a) => a -> Bool
65+textLaw a = fromText (toText a) == Just a