@@ -10,13 +10,19 @@ import Control.Applicative
10
10
import Control.Concurrent
11
11
import qualified Control.Exception as E
12
12
import Control.Monad
13
+ import qualified Data.ByteString as B
14
+ import qualified Data.ByteString.Short as Sh
13
15
import Data.List (sort )
14
16
import System.Exit
15
17
import System.IO
18
+ import System.OsString.Internal.Types
16
19
import System.Posix
17
20
import qualified System.Posix.Env.ByteString as ByteString
21
+ import qualified System.Posix.ByteString.FilePath as BSFP
22
+ import qualified System.Posix.PosixPath.FilePath as PPFP
18
23
import Test.Tasty
19
24
import Test.Tasty.HUnit
25
+ import Test.Tasty.QuickCheck
20
26
21
27
import qualified FileStatus
22
28
import qualified FileStatusByteString
@@ -49,6 +55,7 @@ main = defaultMain $ testGroup "All"
49
55
, posix010 -- JS: missing "sysconf"
50
56
]
51
57
#endif
58
+ , testWithFilePath
52
59
]
53
60
54
61
executeFile001 :: TestTree
@@ -245,6 +252,19 @@ posix010 = testCase "posix010" $ do
245
252
246
253
homeDirectory root @?= homeDirectory root'
247
254
255
+ testWithFilePath :: TestTree
256
+ testWithFilePath =
257
+ testGroup " withFilePath"
258
+ [ testProperty " ByteString" $
259
+ \ xs -> let ys = B. pack $ filter (/= 0 ) xs in
260
+ ioProperty $ BSFP. withFilePath ys
261
+ (\ ptr -> (=== ys) <$> B. packCString ptr)
262
+ , testProperty " PosixPath" $
263
+ \ xs -> let ys = Sh. pack $ filter (/= 0 ) xs in
264
+ ioProperty $ PPFP. withFilePath (PosixString ys)
265
+ (\ ptr -> (=== ys) <$> Sh. packCString ptr)
266
+ ]
267
+
248
268
-------------------------------------------------------------------------------
249
269
-- Utils
250
270
0 commit comments