packages feed

jwt-0.7.2: tests/src/Data/ByteString/ExtendedTests.hs

{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TemplateHaskell     #-}
module Data.ByteString.ExtendedTests
  (
    main
  , defaultTestGroup
) where

import           Control.Applicative
import qualified Data.ByteString.Extended as BS
import           Data.String              (fromString)
import qualified Test.QuickCheck          as QC
import           Test.Tasty
import           Test.Tasty.QuickCheck
import           Test.Tasty.TH

defaultTestGroup :: TestTree
defaultTestGroup = $(testGroupGenerator)

main :: IO ()
main = defaultMain defaultTestGroup

prop_constTimeCompare :: BS.ByteString -> BS.ByteString  -> Bool
prop_constTimeCompare a b = (a == b) == (a `BS.constTimeCompare` b)

instance Arbitrary BS.ByteString where
    arbitrary = BS.pack <$> arbitrary
    shrink xs = BS.pack <$> shrink (BS.unpack xs)