implemented encodeRawRows
This commit is contained in:
@@ -23,6 +23,7 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
module Data.CSV.SipSpec (spec) where
|
||||
|
||||
import Conduit (runConduit, (.|))
|
||||
import qualified Data.ByteString as BS
|
||||
import Data.Char (ord)
|
||||
import Data.Conduit.List (consume, sourceList)
|
||||
import qualified Data.Map as M
|
||||
@@ -32,12 +33,31 @@ import Data.CSV.Sip
|
||||
|
||||
spec :: Spec
|
||||
spec = describe "Data.CSV.Sip" $ do
|
||||
encodeRawRowsSpec
|
||||
labelFieldsSpec
|
||||
decodeRowsSpec
|
||||
decodeRawRowsSpec
|
||||
decodeUTF8Spec
|
||||
toBytesSpec
|
||||
|
||||
encodeRawRowsSpec :: Spec
|
||||
encodeRawRowsSpec = describe "encodeRawRows" $ do
|
||||
result <- BS.concat <$> runConduit
|
||||
(sourceList input .| encodeRawRows .| consume)
|
||||
it ("should be " ++ 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"
|
||||
]
|
||||
|
||||
labelFieldsSpec :: Spec
|
||||
labelFieldsSpec = describe "labelFields" $ mapM_
|
||||
( \(label, input, expected) -> context label $ do
|
||||
|
||||
Reference in New Issue
Block a user