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