add newtypes for QuickCheck to avoid LANG=C issues

All properties changed to use them, except for
prop_encode_c_decode_c_roundtrip, which already filtered to ascii
for other reasons.

A few modules had to be split out, because Setup does not build-depend
on QuickCheck.
This commit is contained in:
Joey Hess 2020-11-09 20:07:31 -04:00
parent aad4129669
commit 885974be99
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
17 changed files with 211 additions and 130 deletions

View file

@ -18,6 +18,7 @@ import Data.ByteString.UTF8 (fromString)
import qualified Data.ByteString as S
import Utility.Hash
import Utility.QuickCheck
type Secret = S.ByteString
type HMACDigest = String
@ -38,8 +39,8 @@ verify v secret = v == mkVerifiable (verifiableVal v) secret
calcDigest :: String -> Secret -> HMACDigest
calcDigest v secret = calcMac HmacSha1 secret (fromString v)
{- for quickcheck -}
prop_verifiable_sane :: String -> String -> Bool
prop_verifiable_sane a s = verify (mkVerifiable a secret) secret
prop_verifiable_sane :: TestableString -> TestableString -> Bool
prop_verifiable_sane v ts =
verify (mkVerifiable (fromTestableString v) secret) secret
where
secret = fromString s
secret = fromString (fromTestableString ts)