Update tests for new generate(Safe)Prime
Update generatePrime test to test smaller bit sizes Add test for generateSafePrime Remove -fobject-code
This commit is contained in:
parent
345f4cd141
commit
a218b4ea3b
@ -205,7 +205,7 @@ Library
|
|||||||
, bytestring
|
, bytestring
|
||||||
, memory >= 0.8
|
, memory >= 0.8
|
||||||
, ghc-prim
|
, ghc-prim
|
||||||
ghc-options: -Wall -fwarn-tabs -optc-O3 -fno-warn-unused-imports -fobject-code
|
ghc-options: -Wall -fwarn-tabs -optc-O3 -fno-warn-unused-imports
|
||||||
default-language: Haskell2010
|
default-language: Haskell2010
|
||||||
cc-options: -std=gnu99
|
cc-options: -std=gnu99
|
||||||
if flag(old_toolchain_inliner)
|
if flag(old_toolchain_inliner)
|
||||||
|
|||||||
@ -42,17 +42,19 @@ tests = testGroup "number"
|
|||||||
in 0 <= r && r < range
|
in 0 <= r && r < range
|
||||||
, testProperty "generate-prime" $ \testDRG (Int0_2901 baseBits') ->
|
, testProperty "generate-prime" $ \testDRG (Int0_2901 baseBits') ->
|
||||||
let baseBits = baseBits' `mod` 800
|
let baseBits = baseBits' `mod` 800
|
||||||
bits = 48 + baseBits -- no point generating lower than 48 bits ..
|
bits = 5 + baseBits -- generating lower than 5 bits causes an error ..
|
||||||
prime = withTestDRG testDRG $ generatePrime bits
|
prime = withTestDRG testDRG $ generatePrime bits
|
||||||
-- with small base bits numbers, the probability that we "cross" this bit size ness
|
in bits == numBits prime
|
||||||
-- to the next is quite high, as the number generated has two highest bit set.
|
, testProperty "generate-safe-prime" $ \testDRG (Int0_2901 baseBits') ->
|
||||||
--
|
let baseBits = baseBits' `mod` 200
|
||||||
in bits == numBits prime || (if baseBits < 64 then (bits + 1) == numBits prime else False)
|
bits = 6 + baseBits
|
||||||
|
prime = withTestDRG testDRG $ generateSafePrime bits
|
||||||
|
in bits == numBits prime
|
||||||
, testProperty "marshalling" $ \qaInt ->
|
, testProperty "marshalling" $ \qaInt ->
|
||||||
getQAInteger qaInt == os2ip (i2osp (getQAInteger qaInt) :: Bytes)
|
getQAInteger qaInt == os2ip (i2osp (getQAInteger qaInt) :: Bytes)
|
||||||
, testGroup "marshalling-kat-to-bytearray" $ map toSerializationKat $ zip [katZero..] serializationVectors
|
, testGroup "marshalling-kat-to-bytearray" $ map toSerializationKat $ zip [katZero..] serializationVectors
|
||||||
, testGroup "marshalling-kat-to-integer" $ map toSerializationKatInteger $ zip [katZero..] serializationVectors
|
, testGroup "marshalling-kat-to-integer" $ map toSerializationKatInteger $ zip [katZero..] serializationVectors
|
||||||
]
|
]
|
||||||
where
|
where
|
||||||
toSerializationKat (i, (sz, n, ba)) = testCase (show i) (ba @=? i2ospOf_ sz n)
|
toSerializationKat (i, (sz, n, ba)) = testCase (show i) (ba @=? i2ospOf_ sz n)
|
||||||
toSerializationKatInteger (i, (_, n, ba)) = testCase (show i) (n @=? os2ip ba)
|
toSerializationKatInteger (i, (_, n, ba)) = testCase (show i) (n @=? os2ip ba)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user