implemented encodeCSV and encodeRawCSV
This commit is contained in:
@@ -33,6 +33,8 @@ import Data.CSV.Sip
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "Data.CSV.Sip" $ do
|
||||
encodeCSVSpec
|
||||
encodeRawCSVSpec
|
||||
encodeRowsSpec
|
||||
encodeRawRowsSpec
|
||||
labelFieldsSpec
|
||||
@@ -41,6 +43,42 @@ spec = describe "Data.CSV.Sip" $ do
|
||||
decodeUTF8Spec
|
||||
toBytesSpec
|
||||
|
||||
encodeCSVSpec :: Spec
|
||||
encodeCSVSpec = describe "encodeCSV" $ do
|
||||
result <- BS.concat <$> runConduit
|
||||
(encodeCSV input .| consume)
|
||||
it ("shouldBe " ++ show expected) $
|
||||
result `shouldBe` expected
|
||||
where
|
||||
|
||||
input =
|
||||
[ [ "foo", "a\"b" ]
|
||||
, [ "a\rb", "a\nb" ]
|
||||
]
|
||||
|
||||
expected = BS.concat
|
||||
[ "\"foo\",\"a\"\"b\"\r\n"
|
||||
, "\"a\rb\",\"a\nb\"\r\n"
|
||||
]
|
||||
|
||||
encodeRawCSVSpec :: Spec
|
||||
encodeRawCSVSpec = describe "encodeRawCSV" $ do
|
||||
result <- BS.concat <$> runConduit
|
||||
(encodeRawCSV input .| consume)
|
||||
it ("shouldBe " ++ show expected) $
|
||||
result `shouldBe` expected
|
||||
where
|
||||
|
||||
input =
|
||||
[ [ "foo", "a\"b" ]
|
||||
, [ "a\rb", "a\nb" ]
|
||||
]
|
||||
|
||||
expected = BS.concat
|
||||
[ "\"foo\",\"a\"\"b\"\r\n"
|
||||
, "\"a\rb\",\"a\nb\"\r\n"
|
||||
]
|
||||
|
||||
encodeRowsSpec :: Spec
|
||||
encodeRowsSpec = describe "encodeRows" $ do
|
||||
result <- BS.concat <$> runConduit
|
||||
|
||||
Reference in New Issue
Block a user