implemented decodeUTF8

This commit is contained in:
2022-04-19 16:31:04 -04:00
parent 08c77d4d0f
commit eea4710b80
2 changed files with 21 additions and 3 deletions

View File

@@ -24,13 +24,14 @@ module Data.CSV.SlurpSpec (spec) where
import Conduit (runConduit, (.|))
import Data.Conduit.List (consume, sourceList)
import Test.Hspec (Spec, context, describe, shouldBe, xit)
import Test.Hspec (Spec, context, describe, it, shouldBe, xit)
import Data.CSV.Slurp
spec :: Spec
spec = describe "Data.CSV.Slurp"
spec = describe "Data.CSV.Slurp" $ do
decodeRowsSpec
decodeUTF8Spec
decodeRowsSpec :: Spec
decodeRowsSpec = describe "decodeRows" $ mapM_
@@ -59,4 +60,18 @@ decodeRowsSpec = describe "decodeRows" $ mapM_
invalidIn = ["\"a"]
validRes = [["foo", "bar"], ["baz", "quux"]]
decodeUTF8Spec :: Spec
decodeUTF8Spec = describe "decodeUTF8" $ mapM_
( \(label, input, expected) -> context label $
it ("should be " ++ show expected) $
decodeUTF8 input `shouldBe` expected
)
-- label, input, expected
[ ( "plain ASCII", "hello", Just "hello" )
, ( "valid UTF8", "\xc3\xa9", Just "é" )
, ( "invalid UTF8", "\xff", Nothing )
, ( "blank", "", Just "" )
]
--jl