geomancy-0.4.0.0: test/Support/Property.hs
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE NumericUnderscores #-}
{-# LANGUAGE PatternSynonyms #-}
module Support.Property
( pattern PROP_TESTS
, pattern PROP_TESTS_BRUTAL
, storableRoundtrip
, layout140
) where
import Hedgehog
import Data.Proxy (Proxy)
import Foreign (Storable, peek, with)
import Graphics.Gl.Block qualified as Block
-- | Enough tests to cover the principles
pattern PROP_TESTS :: TestLimit
pattern PROP_TESTS = 10_000
-- | Try harder to catch FP precision errors
pattern PROP_TESTS_BRUTAL :: TestLimit
pattern PROP_TESTS_BRUTAL = 10_000_000
storableRoundtrip :: Storable a => a -> PropertyT IO a
storableRoundtrip x = evalIO $ with x peek
layout140 :: Block.Block a => Proxy a -> (Int, Int)
layout140 p = (Block.alignment140 p, Block.sizeOf140 p)