File: Binary.hs

package info (click to toggle)
haskell-hedgehog-classes 0.2.5.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 508 kB
  • sloc: haskell: 6,010; makefile: 8
file content (27 lines) | stat: -rw-r--r-- 617 bytes parent folder | download | duplicates (2)
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
{-# LANGUAGE DeriveGeneric #-}

module Spec.Binary (testBinary) where

import Hedgehog
import Hedgehog.Classes
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range

import Data.Binary
import GHC.Generics (Generic(..))

testBinary :: [(String, [Laws])]
testBinary =
  [ ("Person", listPerson)
  ]

data Person = Person { name :: String, age :: Int }
  deriving (Eq, Show, Generic)

instance Binary Person where

listPerson :: [Laws]
listPerson = [binaryLaws genPerson]

genPerson :: Gen Person
genPerson = Person <$> (Gen.string (Range.linear 3 7) Gen.alpha) <*> (Gen.int (Range.linear 0 65))