1 {-# LANGUAGE AllowAmbiguousTypes #-}
2 {-# LANGUAGE OverloadedStrings #-}
3 {-# LANGUAGE TypeApplications #-}
4 module HUnit.Credential where
6 import qualified Control.Monad.Trans.State.Strict as S
7 import qualified System.Random as Random
9 import Protocol.Credential
13 hunit = testGroup "Credential"
14 [ testGroup "randomCredential"
16 S.evalState randomCredential (Random.mkStdGen 0) @?=
17 Credential "xLcs7ev6Jy6FHHE"
19 , testGroup "readCredential" $
21 testCase (show inp) $ readCredential inp @?= exp in
22 [ "" ==> Left CredentialError_Length
23 , "xLcs7ev6Jy6FH_E" ==> Left (CredentialError_BadChar '_')
24 , "xLcs7ev6Jy6FHIE" ==> Left (CredentialError_BadChar 'I')
25 , "xLcs7ev6Jy6FH0E" ==> Left (CredentialError_BadChar '0')
26 , "xLcs7ev6Jy6FHOE" ==> Left (CredentialError_BadChar 'O')
27 , "xLcs7ev6Jy6FHlE" ==> Left (CredentialError_BadChar 'l')
28 , "xLcs7ev6Jy6FH6" ==> Left CredentialError_Length
29 , "xLcs7ev6Jy6FHHy1" ==> Left CredentialError_Length
30 , "xLcs7ev6Jy6FHHF" ==> Left CredentialError_Checksum
31 , "xLcs7ev6Jy6FHHE" ==> Right (Credential "xLcs7ev6Jy6FHHE")