diff options
Diffstat (limited to 'tests/Data/ByteString/Base32')
-rw-r--r-- | tests/Data/ByteString/Base32/HexSpec.hs | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/tests/Data/ByteString/Base32/HexSpec.hs b/tests/Data/ByteString/Base32/HexSpec.hs index 2cdadef..7cddb69 100644 --- a/tests/Data/ByteString/Base32/HexSpec.hs +++ b/tests/Data/ByteString/Base32/HexSpec.hs | |||
@@ -1,3 +1,4 @@ | |||
1 | {-# LANGUAGE OverloadedStrings #-} | ||
1 | {-# OPTIONS -fno-warn-orphans #-} | 2 | {-# OPTIONS -fno-warn-orphans #-} |
2 | module Data.ByteString.Base32.HexSpec ( spec ) where | 3 | module Data.ByteString.Base32.HexSpec ( spec ) where |
3 | 4 | ||
@@ -28,19 +29,19 @@ spec = do | |||
28 | 29 | ||
29 | describe "decode" $ do | 30 | describe "decode" $ do |
30 | it "conform rfc examples" $ do | 31 | it "conform rfc examples" $ do |
31 | decode "" `shouldBe` "" | 32 | decode "" `shouldBe` Right "" |
32 | decode "CO======" `shouldBe` "f" | 33 | decode "CO======" `shouldBe` Right "f" |
33 | decode "CPNG====" `shouldBe` "fo" | 34 | decode "CPNG====" `shouldBe` Right "fo" |
34 | decode "CPNMU===" `shouldBe` "foo" | 35 | decode "CPNMU===" `shouldBe` Right "foo" |
35 | decode "CPNMUOG=" `shouldBe` "foob" | 36 | decode "CPNMUOG=" `shouldBe` Right "foob" |
36 | decode "CPNMUOJ1" `shouldBe` "fooba" | 37 | decode "CPNMUOJ1" `shouldBe` Right "fooba" |
37 | decode "CPNMUOJ1E8======" `shouldBe` "foobar" | 38 | decode "CPNMUOJ1E8======" `shouldBe` Right "foobar" |
38 | 39 | ||
39 | it "inverse for encode" $ property $ \bs -> | 40 | it "inverse for encode" $ property $ \bs -> |
40 | decode (encode bs) == bs | 41 | decode (encode bs) == Right bs |
41 | 42 | ||
42 | it "case insensitive" $ property $ \bs -> | 43 | it "case insensitive" $ property $ \bs -> |
43 | decode (BC.map toLower (encode bs)) == bs | 44 | decode (BC.map toLower (encode bs)) == Right bs |
44 | 45 | ||
45 | it "fail gracefully if encoded data contains non alphabet chars" $ do | 46 | it "fail gracefully if encoded data contains non alphabet chars" $ do |
46 | evaluate (decode "#=======") `shouldThrow` anyErrorCall | 47 | evaluate (decode "#=======") `shouldThrow` anyErrorCall |
@@ -48,20 +49,20 @@ spec = do | |||
48 | 49 | ||
49 | describe "decodeLenient" $ do | 50 | describe "decodeLenient" $ do |
50 | it "conform RFC examples" $ do | 51 | it "conform RFC examples" $ do |
51 | decode "" `shouldBe` "" | 52 | decode "" `shouldBe` Right "" |
52 | decode "CO======" `shouldBe` "f" | 53 | decode "CO======" `shouldBe` Right "f" |
53 | decode "CPNG====" `shouldBe` "fo" | 54 | decode "CPNG====" `shouldBe` Right "fo" |
54 | decode "CPNMU===" `shouldBe` "foo" | 55 | decode "CPNMU===" `shouldBe` Right "foo" |
55 | decode "CPNMUOG=" `shouldBe` "foob" | 56 | decode "CPNMUOG=" `shouldBe` Right "foob" |
56 | decode "CPNMUOJ1" `shouldBe` "fooba" | 57 | decode "CPNMUOJ1" `shouldBe` Right "fooba" |
57 | decode "CPNMUOJ1E8======" `shouldBe` "foobar" | 58 | decode "CPNMUOJ1E8======" `shouldBe` Right "foobar" |
58 | 59 | ||
59 | it "inverse for encode" $ property $ \bs -> | 60 | it "inverse for encode" $ property $ \bs -> |
60 | decodeLenient (encode bs) == bs | 61 | decodeLenient (encode bs) == Right bs |
61 | 62 | ||
62 | it "case insensitive" $ property $ \bs -> | 63 | it "case insensitive" $ property $ \bs -> |
63 | decodeLenient (BC.map toLower (encode bs)) == bs | 64 | decodeLenient (BC.map toLower (encode bs)) == Right bs |
64 | 65 | ||
65 | it "skip non alphabet chars" $ do | 66 | it "skip non alphabet chars" $ do |
66 | decodeLenient "|" `shouldBe` "" | 67 | decodeLenient "|" `shouldBe` Right "" |
67 | decodeLenient "C|O" `shouldBe` "f" | 68 | decodeLenient "C|O" `shouldBe` Right "f" |