base16

Pure Haskell base16 encoding/decoding (docs.ppad.tech/base16).
git clone git://git.ppad.tech/base16.git
Log | Files | Refs | README | LICENSE

commit d0c31a2715b3ca83197deaadee223978ab746dc0
parent 0e26869730d8c417d7f7786275ff59feae661a19
Author: Jared Tobin <jared@jtobin.io>
Date:   Mon, 10 Mar 2025 20:50:26 +0400

test: uppercase.. case

Diffstat:
MREADME.md | 7+++----
Mppad-base16.cabal | 1+
Mtest/Main.hs | 12++++++++++++
3 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/README.md b/README.md @@ -4,8 +4,7 @@ ![](https://img.shields.io/badge/license-MIT-brightgreen) [![](https://img.shields.io/badge/haddock-base16-lightblue)](https://docs.ppad.tech/base16) -A pure implementation of base16 encoding & decoding on strict -ByteStrings. +Pure base16 encoding & decoding on strict ByteStrings. ## Usage @@ -33,8 +32,8 @@ Haddocks (API documentation, etc.) are hosted at ## Performance The aim is best-in-class performance for pure, highly-auditable Haskell -code. We could go slightly faster by direct allocation and writes, but -we get pretty close to the best impure versions with only builders. +code. We could go slightly faster by using direct allocation and writes, +but we get pretty close to the best impure versions with only builders. Current benchmark figures on 1kb inputs on a relatively-beefy NixOS VPS look like (use `cabal bench` to run the benchmark suite): diff --git a/ppad-base16.cabal b/ppad-base16.cabal @@ -43,6 +43,7 @@ test-suite base16-tests , bytestring , ppad-base16 , tasty + , tasty-hunit , tasty-quickcheck benchmark base16-bench diff --git a/test/Main.hs b/test/Main.hs @@ -9,6 +9,7 @@ import qualified "ppad-base16" Data.ByteString.Base16 as B16 import qualified "base16-bytestring" Data.ByteString.Base16 as R0 import Test.Tasty import qualified Test.Tasty.QuickCheck as Q +import qualified Test.Tasty.HUnit as H newtype BS = BS BS.ByteString deriving (Eq, Show) @@ -48,6 +49,14 @@ decode_matches_reference (BS bs) = Left _ -> False Right d0 -> du == d0 +case_handled :: TestTree +case_handled = H.testCase "decodes uppercase hex" $ do + let lhex = "deadbeef" + uhex = "DEADBEEF" + case liftA2 (,) (B16.decode lhex) (B16.decode uhex) of + Nothing -> H.assertBool mempty False + Just (a, b) -> H.assertEqual mempty a b + main :: IO () main = defaultMain $ testGroup "ppad-base16" [ @@ -59,5 +68,8 @@ main = defaultMain $ , Q.testProperty "decode matches reference" $ Q.withMaxSuccess 5000 decode_matches_reference ] + , testGroup "unit tests" [ + case_handled + ] ]