mirror of
https://github.com/haskell-nix/hnix-store.git
synced 2024-09-11 18:05:56 +03:00
tests: add custom Arbitrary (Maybe Text) that doesn't generate Just mempty
This commit is contained in:
parent
a7fbcf7a02
commit
c815068e60
@ -62,9 +62,7 @@ spec = parallel $ do
|
||||
prop "Bool" $ roundtripS bool
|
||||
prop "ByteString" $ roundtripS byteString
|
||||
prop "Text" $ roundtripS text
|
||||
prop "Maybe Text"
|
||||
$ forAll (arbitrary `suchThat` (/= Just ""))
|
||||
$ roundtripS maybeText
|
||||
prop "Maybe Text" $ roundtripS maybeText
|
||||
prop "UTCTime" $ roundtripS @UTCTime @() time
|
||||
|
||||
describe "Combinators" $ do
|
||||
|
@ -2,9 +2,15 @@
|
||||
module Data.Text.Arbitrary () where
|
||||
|
||||
import Data.Text (Text)
|
||||
import Test.QuickCheck (Arbitrary(..))
|
||||
import Test.QuickCheck (Arbitrary(..), frequency, suchThat)
|
||||
import qualified Data.Text
|
||||
|
||||
instance Arbitrary Text where
|
||||
arbitrary = Data.Text.pack <$> arbitrary
|
||||
shrink xs = Data.Text.pack <$> shrink (Data.Text.unpack xs)
|
||||
|
||||
instance {-# OVERLAPPING #-} Arbitrary (Maybe Text) where
|
||||
arbitrary = frequency
|
||||
[ (1, pure Nothing)
|
||||
, (3, Just <$> arbitrary `suchThat` (/= mempty))
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user