Skip to content

Commit

Permalink
Add tests for Data.Text.Foreign peek
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanCacqueray authored and Lysxia committed Jul 22, 2024
1 parent ee87862 commit 1063d61
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion tests/Tests/Properties/LowLevel.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import Test.QuickCheck hiding ((.&.))
import Tests.QuickCheckUtils
import Tests.Utils
import qualified Data.Text as T
import qualified Data.Text.Foreign as T
import qualified Data.Text.IO as T
import qualified Data.Text.Lazy as TL
import qualified Data.Text.Lazy.IO as TL
Expand Down Expand Up @@ -72,6 +73,14 @@ 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
roundTrip <- T.withCString t T.peekCString
assertEqual "cstring" t roundTrip

t_peek_cstring_len t = ioProperty $ do
roundTrip <- T.withCStringLen t T.peekCStringLen
assertEqual "cstring_len" t roundTrip

t_copy t = T.copy t === t

t_literal_length1 = assertEqual xs (length xs) byteLen
Expand Down Expand Up @@ -125,6 +134,8 @@ testLowLevel =
testProperty "t_use_from" t_use_from,
testProperty "t_use_from0" t_use_from0,
testProperty "t_copy" t_copy,
testProperty "t_peek_cstring" t_peek_cstring,
testProperty "t_peek_cstring_len" t_peek_cstring_len,
testCase "t_literal_length1" t_literal_length1,
testCase "t_literal_length2" t_literal_length2,
testCase "t_literal_surrogates" t_literal_surrogates
Expand All @@ -151,4 +162,3 @@ testLowLevel =
-- testProperty "tl_put_get" tl_put_get
]
]

0 comments on commit 1063d61

Please sign in to comment.