diff options
Diffstat (limited to 'tests/Data/ByteString/Base32/HexSpec.hs')
-rw-r--r-- | tests/Data/ByteString/Base32/HexSpec.hs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/Data/ByteString/Base32/HexSpec.hs b/tests/Data/ByteString/Base32/HexSpec.hs index 4e41d09..3a04b09 100644 --- a/tests/Data/ByteString/Base32/HexSpec.hs +++ b/tests/Data/ByteString/Base32/HexSpec.hs | |||
@@ -45,3 +45,23 @@ spec = do | |||
45 | it "fail gracefully if encoded data contains non alphabet chars" $ do | 45 | it "fail gracefully if encoded data contains non alphabet chars" $ do |
46 | evaluate (decode "#=======") `shouldThrow` anyErrorCall | 46 | evaluate (decode "#=======") `shouldThrow` anyErrorCall |
47 | evaluate (decode "AAAAAAAA#=======") `shouldThrow` anyErrorCall | 47 | evaluate (decode "AAAAAAAA#=======") `shouldThrow` anyErrorCall |
48 | |||
49 | describe "decodeLenient" $ do | ||
50 | it "conform RFC examples" $ do | ||
51 | decodeLenient "" `shouldBe` "" | ||
52 | decodeLenient "MY======" `shouldBe` "f" | ||
53 | decodeLenient "MZXQ====" `shouldBe` "fo" | ||
54 | decodeLenient "MZXW6===" `shouldBe` "foo" | ||
55 | decodeLenient "MZXW6YQ=" `shouldBe` "foob" | ||
56 | decodeLenient "MZXW6YTB" `shouldBe` "fooba" | ||
57 | decodeLenient "MZXW6YTBOI======" `shouldBe` "foobar" | ||
58 | |||
59 | it "inverse for encode" $ property $ \bs -> | ||
60 | decodeLenient (encode bs) == bs | ||
61 | |||
62 | it "case insensitive" $ property $ \bs -> | ||
63 | decodeLenient (BC.map toLower (encode bs)) == bs | ||
64 | |||
65 | it "skip non alphabet chars" $ do | ||
66 | decodeLenient "|" `shouldBe` "" | ||
67 | decodeLenient "M|Y" `shouldBe` "f" | ||