fix failing test case

An empty list of [ContentIdenfier] serialized to the same thing
as a single ContentIdentifier "". Avoid this ambiguity by requiring the
list be non-empty.
This commit is contained in:
Joey Hess 2019-03-06 14:17:33 -04:00
parent be6085cfe5
commit c0bd202147
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
3 changed files with 34 additions and 15 deletions

View file

@ -17,6 +17,7 @@ import Test.QuickCheck as X
import Data.Time.Clock.POSIX
import Data.Ratio
import System.Posix.Types
import Data.List.NonEmpty (NonEmpty(..))
import Prelude
{- Times before the epoch are excluded. Half with decimal and half without. -}
@ -41,6 +42,10 @@ instance Arbitrary FileID where
instance Arbitrary FileOffset where
arbitrary = nonNegative arbitrarySizedIntegral
{- Quickcheck lacks this instance. -}
instance Arbitrary l => Arbitrary (NonEmpty l) where
arbitrary = (:|) <$> arbitrary <*> arbitrary
nonNegative :: (Num a, Ord a) => Gen a -> Gen a
nonNegative g = g `suchThat` (>= 0)