module Tests.Util (tests) where import Distribution.TestSuite.QuickCheck import Tests.Test import Passman.Core.Internal.Util import Passman.Core.Internal.Compat (Natural) import Test.QuickCheck import Data.List tests :: IO [Test] tests = return [ testProperty "prop_toBase10" prop_toBase10 , testProperty "prop_toFromBase" prop_toFromBase , testProperty "prop_intercalateSplit" prop_intercalateSplit ] prop_toBase10 :: GT1 Natural -> Bool prop_toBase10 (GT1 k) = map ((['0'..'9']!!) . fromEnum) (toBase 10 k) == show k prop_toFromBase :: GT1 Natural -> Natural -> Bool prop_toFromBase (GT1 b) k = fromBase b (toBase b k) == k prop_intercalateSplit :: Integer -> [[Integer]] -> Bool prop_intercalateSplit x xs = xs' == splitOn x (intercalate [x] xs') where xs' = filter (not . null) $ fmap (filter (x/=)) xs