2015-04-20 02:39:58 +00:00
|
|
|
module Data.HexStringSpec where
|
|
|
|
|
|
|
|
import Data.HexString
|
|
|
|
|
2015-04-20 06:25:01 +00:00
|
|
|
import qualified Data.ByteString.Lazy.Char8 as BSL8
|
2015-04-20 02:39:58 +00:00
|
|
|
import qualified Data.Text as T
|
|
|
|
|
2015-04-20 06:25:01 +00:00
|
|
|
import qualified Data.Binary as B ( encode )
|
|
|
|
|
2015-04-20 02:39:58 +00:00
|
|
|
import Test.Hspec
|
|
|
|
|
|
|
|
spec :: Spec
|
|
|
|
spec = do
|
|
|
|
describe "when decoding hex data" $ do
|
|
|
|
it "should be able to parse basic hex data" $ do
|
2015-04-20 06:30:58 +00:00
|
|
|
(B.encode . decodeString) "ffff" `shouldBe` BSL8.pack "\255\255"
|
|
|
|
(B.encode . decodeText) (T.pack "ffff") `shouldBe` BSL8.pack "\255\255"
|
2015-04-20 02:39:58 +00:00
|
|
|
|
2015-04-20 06:30:58 +00:00
|
|
|
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"
|