mirror of
https://github.com/haskell-nix/hnix-store.git
synced 2024-09-11 18:05:56 +03:00
tests: limit the size of list for OutputName, StorePath name generators
This commit is contained in:
parent
72de93d260
commit
225b4d3f5a
@ -6,14 +6,17 @@ import System.Nix.OutputName (OutputName)
|
||||
import qualified Data.Text
|
||||
import qualified System.Nix.OutputName
|
||||
|
||||
import Test.QuickCheck (Arbitrary(arbitrary), elements, listOf)
|
||||
import Test.QuickCheck (Arbitrary(arbitrary), choose, elements, vectorOf)
|
||||
|
||||
instance Arbitrary OutputName where
|
||||
arbitrary =
|
||||
either (error . show) id
|
||||
. System.Nix.OutputName.mkOutputName
|
||||
. Data.Text.pack <$> ((:) <$> s1 <*> listOf sn)
|
||||
. Data.Text.pack <$> ((:) <$> s1 <*> limited sn)
|
||||
where
|
||||
alphanum = ['a' .. 'z'] <> ['A' .. 'Z'] <> ['0' .. '9']
|
||||
s1 = elements $ alphanum <> "+-_?="
|
||||
sn = elements $ alphanum <> "+-._?="
|
||||
s1 = elements $ alphanum <> "+-_?="
|
||||
sn = elements $ alphanum <> "+-._?="
|
||||
limited n = do
|
||||
k <- choose (0, 210)
|
||||
vectorOf k n
|
||||
|
@ -15,7 +15,7 @@ import System.Nix.StorePath (StoreDir(..)
|
||||
)
|
||||
import qualified System.Nix.StorePath
|
||||
|
||||
import Test.QuickCheck (Arbitrary(arbitrary), elements, listOf, oneof)
|
||||
import Test.QuickCheck (Arbitrary(arbitrary), choose, elements, oneof, vectorOf)
|
||||
|
||||
instance Arbitrary StoreDir where
|
||||
arbitrary =
|
||||
@ -33,11 +33,14 @@ instance Arbitrary StorePathName where
|
||||
arbitrary =
|
||||
either undefined id
|
||||
. System.Nix.StorePath.mkStorePathName
|
||||
. Data.Text.pack <$> ((:) <$> s1 <*> listOf sn)
|
||||
. Data.Text.pack <$> ((:) <$> s1 <*> limited sn)
|
||||
where
|
||||
alphanum = ['a' .. 'z'] <> ['A' .. 'Z'] <> ['0' .. '9']
|
||||
s1 = elements $ alphanum <> "+-_?="
|
||||
sn = elements $ alphanum <> "+-._?="
|
||||
s1 = elements $ alphanum <> "+-_?="
|
||||
sn = elements $ alphanum <> "+-._?="
|
||||
limited n = do
|
||||
k <- choose (0, 210)
|
||||
vectorOf k n
|
||||
|
||||
instance Arbitrary StorePathHashPart where
|
||||
arbitrary =
|
||||
|
Loading…
Reference in New Issue
Block a user