diff options
Diffstat (limited to 'tests/Data/ByteString/Base32Spec.hs')
-rw-r--r-- | tests/Data/ByteString/Base32Spec.hs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/tests/Data/ByteString/Base32Spec.hs b/tests/Data/ByteString/Base32Spec.hs index 66df53a..148539a 100644 --- a/tests/Data/ByteString/Base32Spec.hs +++ b/tests/Data/ByteString/Base32Spec.hs | |||
@@ -52,4 +52,22 @@ spec = do | |||
52 | evaluate (decode "0=======") `shouldThrow` anyErrorCall | 52 | evaluate (decode "0=======") `shouldThrow` anyErrorCall |
53 | evaluate (decode "AAAAAAAA0=======") `shouldThrow` anyErrorCall | 53 | evaluate (decode "AAAAAAAA0=======") `shouldThrow` anyErrorCall |
54 | 54 | ||
55 | -- describe "decodeLenient" $ do | 55 | describe "decodeLenient" $ do |
56 | it "conform RFC examples" $ do | ||
57 | decodeLenient "" `shouldBe` "" | ||
58 | decodeLenient "MY======" `shouldBe` "f" | ||
59 | decodeLenient "MZXQ====" `shouldBe` "fo" | ||
60 | decodeLenient "MZXW6===" `shouldBe` "foo" | ||
61 | decodeLenient "MZXW6YQ=" `shouldBe` "foob" | ||
62 | decodeLenient "MZXW6YTB" `shouldBe` "fooba" | ||
63 | decodeLenient "MZXW6YTBOI======" `shouldBe` "foobar" | ||
64 | |||
65 | it "inverse for encode" $ property $ \bs -> | ||
66 | decodeLenient (encode bs) == bs | ||
67 | |||
68 | it "case insensitive" $ property $ \bs -> | ||
69 | decodeLenient (BC.map toLower (encode bs)) == bs | ||
70 | |||
71 | it "skip non alphabet chars" $ do | ||
72 | decodeLenient "|" `shouldBe` "" | ||
73 | decodeLenient "M|Y" `shouldBe` "f" | ||