Skip to content

Commit

Permalink
Add test for #393
Browse files Browse the repository at this point in the history
  • Loading branch information
phadej committed May 24, 2021
1 parent d6813ab commit 2d18efc
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/Properties/ByteString.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ import qualified Data.ByteString.Lazy.Char8 as B
import qualified Data.ByteString.Lazy.Internal as B (invariant)
#endif

import Data.Char
import Text.Read

#endif

import Control.Arrow
import Data.Char
import Data.Foldable
import Data.List as L
import Data.Semigroup
Expand Down Expand Up @@ -536,6 +536,14 @@ tests =
\n f (toElem -> a) -> B.take (fromIntegral (n :: Int)) (B.iterate (toElem . f) a) ===
B.take (fromIntegral n) (B.unfoldr (\x -> Just (toElem (f x), toElem (f x))) a)
#endif

#ifndef BYTESTRING_CHAR8
-- issue #393
, testProperty "fromString non-char8" $
\s -> fromString s == B.pack (map (fromIntegral . ord :: Char -> Word8) s)
, testProperty "fromString literal" $
fromString "\0\1\2\3\4" == B.pack [0,1,2,3,4]
#endif
]

unsnoc :: [a] -> Maybe ([a], a)
Expand Down

0 comments on commit 2d18efc

Please sign in to comment.