summaryrefslogtreecommitdiff
path: root/tests/Data/ByteString/Base32Spec.hs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Data/ByteString/Base32Spec.hs')
-rw-r--r--tests/Data/ByteString/Base32Spec.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/tests/Data/ByteString/Base32Spec.hs b/tests/Data/ByteString/Base32Spec.hs
index ff3e13c..60e340c 100644
--- a/tests/Data/ByteString/Base32Spec.hs
+++ b/tests/Data/ByteString/Base32Spec.hs
@@ -4,8 +4,9 @@ module Data.ByteString.Base32Spec (spec) where
4import Control.Applicative 4import Control.Applicative
5import Control.Exception 5import Control.Exception
6import Data.ByteString as BS 6import Data.ByteString as BS
7import Data.ByteString.Internal as BS 7import Data.ByteString.Char8 as BC
8import Data.ByteString.Base32 as Base32 8import Data.ByteString.Base32 as Base32
9import Data.Char
9import Test.Hspec 10import Test.Hspec
10import Test.QuickCheck 11import Test.QuickCheck
11 12
@@ -29,7 +30,7 @@ spec = do
29 (BS.length (encode bs) `rem` 8) `shouldBe` 0 30 (BS.length (encode bs) `rem` 8) `shouldBe` 0
30 31
31 it "padding less than" $ property $ \bs -> 32 it "padding less than" $ property $ \bs ->
32 count (c2w '=') bs `shouldSatisfy` (< 8) 33 BC.count '=' bs `shouldSatisfy` (< 8)
33 34
34 describe "decode" $ do 35 describe "decode" $ do
35 it "conform RFC examples" $ do 36 it "conform RFC examples" $ do
@@ -44,6 +45,9 @@ spec = do
44 it "inverse for encode" $ property $ \bs -> 45 it "inverse for encode" $ property $ \bs ->
45 decode (encode bs) == bs 46 decode (encode bs) == bs
46 47
48 it "case insensitive" $ property $ \bs ->
49 decode (BC.map toLower (encode bs)) == bs
50
47 it "fail gracefully if encoded data contains non alphabet chars" $ do 51 it "fail gracefully if encoded data contains non alphabet chars" $ do
48 evaluate (decode "0=======") `shouldThrow` anyErrorCall 52 evaluate (decode "0=======") `shouldThrow` anyErrorCall
49 evaluate (decode "AAAAAAAA0=======") `shouldThrow` anyErrorCall 53 evaluate (decode "AAAAAAAA0=======") `shouldThrow` anyErrorCall