From 72d8609674854f0e0ea19919bbd7d4661fabf7ea Mon Sep 17 00:00:00 2001 From: Jonathan Lamothe Date: Mon, 17 Dec 2018 20:20:08 -0500 Subject: [PATCH] better tests for newSalt --- test/Spec/NewSalt.hs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/test/Spec/NewSalt.hs b/test/Spec/NewSalt.hs index b4f4a35..f144874 100644 --- a/test/Spec/NewSalt.hs +++ b/test/Spec/NewSalt.hs @@ -24,12 +24,21 @@ module Spec.NewSalt (tests) where import qualified Data.ByteString as B import System.Random (mkStdGen) -import Test.HUnit (Test(..), (~?=)) +import Test.HUnit (Test(..), assertBool, (~?=)) import Password -tests = TestLabel "newSalt" $ B.length salt ~?= 256 where - (salt, _) = newSalt g - g = mkStdGen 1 +tests = TestLabel "newSalt" $ TestList + [ testLength salt + , testDiff salt salt' + ] where + (salt, g') = newSalt g + (salt', _) = newSalt g' + g = mkStdGen 1 + +testLength x = TestLabel "salt length" $ B.length x ~?= 256 + +testDiff x y = TestLabel "different generators" $ TestCase $ + assertBool "salts match" $ x /= y --jl