haskell-hexstring/test/Data/HexStringSpec.hs
Leon Mergen 6eea89845d Don't expose the ByteString encode/decode anymore
By exposing a ByteString functions we actually make this library more
confusing; we will now only represent the hex string representation as
either Text or String, and any ByteString that goes in or out is always
the binary representation.
2015-04-20 13:30:58 +07:00

22 lines
720 B
Haskell

module Data.HexStringSpec where
import Data.HexString
import qualified Data.ByteString.Lazy.Char8 as BSL8
import qualified Data.Text as T
import qualified Data.Binary as B ( encode )
import Test.Hspec
spec :: Spec
spec = do
describe "when decoding hex data" $ do
it "should be able to parse basic hex data" $ do
(B.encode . decodeString) "ffff" `shouldBe` BSL8.pack "\255\255"
(B.encode . decodeText) (T.pack "ffff") `shouldBe` BSL8.pack "\255\255"
it "should be able to recode basic hex data to different formats" $ do
(encodeText . decodeString) "ffff" `shouldBe` T.pack "ffff"
(encodeString . decodeString) "ffff" `shouldBe` "ffff"