Skip to content

Commit

Permalink
Fix t_peek_cstring test
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Aug 18, 2024
1 parent 6ed3cae commit 910fc38
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Data/Text/Foreign.hs
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ asForeignPtr t@(Text _arr _off len) = do
-- | Marshal a 'Text' into a C string with a trailing NUL byte,
-- encoded as UTF-8 in temporary storage.
--
-- The 'Text' itself must not contain any NUL bytes, this precondition
-- is not checked. Cf. 'withCStringLen'.
--
-- The temporary storage is freed when the subcomputation terminates
-- (either normally or via an exception), so the pointer to the
-- temporary storage must /not/ be used after this function returns.
Expand Down
2 changes: 1 addition & 1 deletion tests/Tests/Properties/LowLevel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ t_use_from0 t = ioProperty $ do
let t' = t `T.snoc` '\0'
(== T.takeWhile (/= '\0') t') <$> useAsPtr t' (const . fromPtr0)

t_peek_cstring t = ioProperty $ do
t_peek_cstring t = T.all (/= '\0') t ==> ioProperty $ do
roundTrip <- T.withCString t T.peekCString
assertEqual "cstring" t roundTrip

Expand Down

0 comments on commit 910fc38

Please sign in to comment.