Add a test for a very simple CSV encoding

This commit is contained in:
Andrew Martin 2019-09-20 09:23:08 -04:00
parent 459c48a2d9
commit cd3631e5fd
6 changed files with 82 additions and 3 deletions

View file

@ -403,7 +403,7 @@ word8PaddedUpperHex w =
-- | Encode an ASCII char.
-- Precondition: Input must be an ASCII character. This is not checked.
ascii :: Char -> Builder
ascii c = fromBounded Nat.constant (Bounded.char c)
ascii c = fromBounded Nat.constant (Bounded.ascii c)
-- | Encode an UTF8 char. This only uses as much space as is required.
char :: Char -> Builder

View file

@ -507,10 +507,12 @@ word8LowerHex# w#
where
w = W# w#
-- | Encode an ASCII char.
-- | Encode an ASCII character.
-- Precondition: Input must be an ASCII character. This is not checked.
ascii :: Char -> Builder 1
ascii c = word8 (fromIntegral @Int @Word8 (ord c))
ascii (C# c) = Unsafe.construct $ \(MutableByteArray arr) (I# off) -> do
primitive_ (writeCharArray# arr off c)
pure (I# (off +# 1# ))
-- | Encode a character as UTF-8. This only uses as much space as is required.
char :: Char -> Builder 4