1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
{-# LANGUAGE DeriveGeneric #-}
module Spec.Json (testJson) where
import Hedgehog
import Hedgehog.Classes
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range
import GHC.Generics (Generic)
import Data.Aeson (FromJSON, ToJSON)
testJson :: [(String, [Laws])]
testJson =
[ ("Person", listPerson)
]
data Person = Person { name :: String, age :: Int }
deriving (Eq, Show, Generic)
instance FromJSON Person where
instance ToJSON Person where
listPerson :: [Laws]
listPerson = [jsonLaws genPerson]
genPerson :: Gen Person
genPerson = Person <$> (Gen.string (Range.linear 3 7) Gen.alpha) <*> (Gen.int (Range.linear 0 65))
|