packages feed

ptr 0.15.5 → 0.15.6

raw patch · 3 files changed

+21/−1 lines, 3 files

Files

library/Ptr/Poking.hs view
@@ -100,6 +100,19 @@             (quot, rem) ->               loop (word8 (48 + fromIntegral rem) <> builder) quot +{-# INLINABLE paddedAndTrimmedAsciiIntegral #-}+paddedAndTrimmedAsciiIntegral :: Integral a => Int -> a -> Poking+paddedAndTrimmedAsciiIntegral !length !integral =+  if length > 0+    then+      if integral >= 0+        then case quotRem integral 10 of+          (quot, rem) ->+            paddedAndTrimmedAsciiIntegral (pred length) quot <>+            word8 (48 + fromIntegral rem)+        else stimes length (word8 48)+    else mempty+ {-# INLINE asciiChar #-} asciiChar :: Char -> Poking asciiChar =
ptr.cabal view
@@ -1,7 +1,7 @@ name:   ptr version:-  0.15.5+  0.15.6 category:   Ptr, Data synopsis:
tests/Main.hs view
@@ -10,6 +10,8 @@ import qualified Ptr.Poke as B import qualified Ptr.Peek as C import qualified Ptr.PokeAndPeek as E+import qualified Ptr.ByteString as A+import qualified Ptr.Poking as F import qualified Data.ByteString as D  @@ -26,6 +28,11 @@     testProperty "Poke and peek (beWord64)" $ \input -> input === fromJust (pokeThenPeek B.beWord64 C.beWord64) input     ,     testProperty "PokeAndPeek composition" $ \input -> input === pokeAndPeek ((,) <$> lmap fst E.word8 <*> lmap snd E.beWord32) input+    ,+    testCase "paddedAndTrimmedAsciiIntegral" $ do+      assertEqual "" "001" (A.poking (F.paddedAndTrimmedAsciiIntegral 3 1))+      assertEqual "" "001" (A.poking (F.paddedAndTrimmedAsciiIntegral 3 2001))+      assertEqual "" "000" (A.poking (F.paddedAndTrimmedAsciiIntegral 3 (-1)))   ]  pokeThenPeek :: B.Poke a -> C.Peek a -> Maybe (a -> a)