genvalidity-hspec-binary-1.0.0.0: Standard spec's for binary-related Instances
Safe HaskellNone
LanguageHaskell2010

Test.Validity.Binary

Description

Standard test Specs and raw Propertys for Binary instances.

You will need TypeApplications to use these.

Synopsis

Documentation

binarySpec :: forall a. (Show a, Eq a, Typeable a, GenValid a, Binary a) => Spec Source #

Standard test spec for properties of Binary-related functions for valid values

Example usage:

binarySpec @Int

binarySpecOnArbitrary :: forall a. (Show a, Eq a, Typeable a, Arbitrary a, Binary a) => Spec Source #

Standard test spec for properties of Binary-related functions for arbitrary values

Example usage:

binarySpecOnArbitrary @Int

binarySpecOnGen :: forall a. (Show a, Eq a, Typeable a, Binary a) => Gen a -> String -> (a -> [a]) -> Spec Source #

Standard test spec for properties of Binary-related functions for a given generator (and a name for that generator).

Example usage:

binarySpecOnGen (genListOf $ pure 'a') "sequence of 'a's" (const [])

neverFailsToEncodeOnGen :: (Show a, Binary a) => Gen a -> (a -> [a]) -> Property Source #

neverFailsToEncodeOnGen @Bool arbitrary shrink
neverFailsToEncodeOnGen @Bool genValid shrinkValid
neverFailsToEncodeOnGen @Bool genValid shrinkValid
neverFailsToEncodeOnGen @Int arbitrary shrink
neverFailsToEncodeOnGen @Int genValid shrinkValid
neverFailsToEncodeOnGen @Int genValid shrinkValid

encodeAndDecodeAreInversesOnGen :: (Show a, Eq a, Binary a) => Gen a -> (a -> [a]) -> Property Source #

encodeAndDecodeAreInversesOnGen @Bool arbitrary shrinkValid
encodeAndDecodeAreInversesOnGen @Bool genValid shrinkValid
encodeAndDecodeAreInversesOnGen @Bool genValid shrinkValid
encodeAndDecodeAreInversesOnGen @Int arbitrary shrink
encodeAndDecodeAreInversesOnGen @Int genValid shrinkValid
encodeAndDecodeAreInversesOnGen @Int genValid shrinkValid