Spec for "reasonably random" appearance.
This commit is contained in:
parent
7b3d69f657
commit
c9cb50b34b
@ -12,9 +12,14 @@ import Test.Hspec
|
||||
|
||||
randomStringSpecs :: [Spec]
|
||||
randomStringSpecs = describe "Yesod.Internal.Request.randomString"
|
||||
[ it "does not repeat itself" $ noRepeat 10 100
|
||||
[ it "looks reasonably random" looksRandom
|
||||
, it "does not repeat itself" $ noRepeat 10 100
|
||||
]
|
||||
|
||||
-- NOTE: this testcase may break on other systems/architectures if
|
||||
-- mkStdGen is not identical everywhere (is it?).
|
||||
looksRandom = randomString 20 (mkStdGen 0) == "VH9SkhtptqPs6GqtofVg"
|
||||
|
||||
noRepeat len n = length (nub $ map (randomString len . mkStdGen) [1..n]) == n
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user