streaming-base64 0.1.0.0 → 0.1.1.0
raw patch · 4 files changed
+43/−43 lines, 4 filesdep +base-compat-batteriesdep +filepathdep +streaming-withdep −tasty-hunitdep ~basePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: base-compat-batteries, filepath, streaming-with, tasty-golden
Dependencies removed: tasty-hunit
Dependency ranges changed: base
API changes (from Hackage documentation)
- Streaming.Base64: instance GHC.Exception.Exception Streaming.Base64.Base64Exception
+ Streaming.Base64: instance GHC.Exception.Type.Exception Streaming.Base64.Base64Exception
Files
- src/Streaming/Base64.hs +2/−1
- streaming-base64.cabal +9/−11
- test/GoldenTests.hs +32/−0
- test/UnitTests.hs +0/−31
src/Streaming/Base64.hs view
@@ -12,8 +12,9 @@ import Data.Char import Data.Function import Data.Maybe-import Data.Semigroup import Data.Word+import Prelude ()+import Prelude.Compat import Streaming.Prelude (Of (..), Stream, cons, for, next, yield) import qualified Streaming.Prelude as Stream
streaming-base64.cabal view
@@ -1,16 +1,14 @@-cabal-version: 2.2--- cabal-version: >=1.10 name: streaming-base64-version: 0.1.0.0+version: 0.1.1.0 synopsis: Streaming conversion from/to base64 -- description:--- license: PublicDomain-license: CC0-1.0-author: koral-maintainer: koral@mailoo.org+license: PublicDomain+author: chahine.moreau@gmail.com+maintainer: chahine.moreau@gmail.com -- category: build-type: Simple -- extra-source-files: ChangeLog.md+cabal-version: >=1.10 source-repository head type: git@@ -21,14 +19,14 @@ Streaming.Base64 -- other-modules: -- other-extensions:- build-depends: base >=4.9 && <5, safe-exceptions, streaming, streaming-bytestring, transformers+ build-depends: base >=4.7 && <5, base-compat-batteries, safe-exceptions, streaming, streaming-bytestring, transformers hs-source-dirs: src default-language: Haskell2010 -test-suite unit-tests+test-suite golden-tests type: exitcode-stdio-1.0- main-is: UnitTests.hs- build-depends: base >=4.9 && <5, streaming-base64, streaming-bytestring, tasty, tasty-hunit+ main-is: GoldenTests.hs+ build-depends: base >=4.7 && <5, base-compat-batteries, filepath, streaming-base64, streaming-bytestring, streaming-with, tasty, tasty-golden default-language: Haskell2010 hs-source-dirs: test -- other-modules:
+ test/GoldenTests.hs view
@@ -0,0 +1,32 @@+{-# LANGUAGE OverloadedStrings #-}+import qualified Streaming.Base64 as Base64++import Control.Arrow+import Control.Monad+import Data.ByteString.Streaming (ByteString)+import qualified Data.ByteString.Streaming as Bytes+import Streaming.With+import System.FilePath+import Prelude ()+import Prelude.Compat+import Test.Tasty+import Test.Tasty.Golden (findByExtension, goldenVsString)++main :: IO ()+main = defaultMain =<< do+ decodedFiles <- findByExtension [".decoded"] "."+ encodedFiles <- findByExtension [".encoded"] "."++ return $ testGroup "Golden tests" $ map encodingTest decodedFiles <> map decodingTest encodedFiles++encodingTest :: FilePath -> TestTree+encodingTest decodedFile = goldenVsString name encodedFile f where+ encodedFile = replaceExtension decodedFile "encoded"+ name = "Encoding " <> dropExtension decodedFile+ f = withBinaryFileContents decodedFile (Bytes.toLazy_ <<< Bytes.pack <<< Base64.encode)++decodingTest :: FilePath -> TestTree+decodingTest encodedFile = goldenVsString name decodedFile f where+ decodedFile = replaceExtension encodedFile "decoded"+ name = "Decoding " <> dropExtension encodedFile+ f = withBinaryFileContents encodedFile (Bytes.toLazy_ <<< Base64.decode <<< Bytes.unpack)
− test/UnitTests.hs
@@ -1,31 +0,0 @@-{-# LANGUAGE OverloadedStrings #-}-import qualified Streaming.Base64 as Base64--import Control.Arrow-import Control.Monad-import Data.ByteString.Streaming (ByteString)-import qualified Data.ByteString.Streaming as Bytes-import Test.Tasty-import Test.Tasty.HUnit--main :: IO ()-main = defaultMain $ testGroup "Unit tests"- [ encodeCase- , decodeCase- ]--examples =- [ ("Man is distinguished, not only by his reason, but by this singular passion from other animals, which is a lust of the mind, that by a perseverance of delight in the continued and indefatigable generation of knowledge, exceeds the short vehemence of any carnal pleasure.", "TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdlLCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=")- ]--encodeCase :: TestTree-encodeCase = testCase "encode" $ do- forM_ examples $ \(input, expected) -> do- result <- (Bytes.toLazy_ <<< Bytes.pack <<< Base64.encode <<< Bytes.fromLazy) input- result @?= expected--decodeCase :: TestTree-decodeCase = testCase "decode" $ do- forM_ examples $ \(expected, input) -> do- result <- (Bytes.toLazy_ <<< Base64.decode <<< Bytes.unpack <<< Bytes.fromLazy) input- result @?= expected