diff --git a/tests/Test.hs b/tests/Test.hs
index be08e5e7cfbdd2baf546b9b2c6cb7580871b395d..4c41b2e7822d6e6bbf10029b509e9d0d9f8d9a4c 100644
--- a/tests/Test.hs
+++ b/tests/Test.hs
@@ -10,13 +10,19 @@ import Control.Applicative
 import Control.Concurrent
 import qualified Control.Exception as E
 import Control.Monad
+import qualified Data.ByteString as B
+import qualified Data.ByteString.Short as Sh
 import Data.List (sort)
 import System.Exit
 import System.IO
+import System.OsString.Internal.Types
 import System.Posix
 import qualified System.Posix.Env.ByteString as ByteString
+import qualified System.Posix.ByteString.FilePath as BSFP
+import qualified System.Posix.PosixPath.FilePath as PPFP
 import Test.Tasty
 import Test.Tasty.HUnit
+import Test.Tasty.QuickCheck
 
 import qualified FileStatus
 import qualified FileStatusByteString
@@ -49,6 +55,7 @@ main = defaultMain $ testGroup "All"
     , posix010                     -- JS: missing "sysconf"
     ]
 #endif
+  , testWithFilePath
   ]
 
 executeFile001 :: TestTree
@@ -245,6 +252,19 @@ posix010 = testCase "posix010" $ do
 
   homeDirectory root @?= homeDirectory root'
 
+testWithFilePath :: TestTree
+testWithFilePath =
+  testGroup "withFilePath"
+    [ testProperty "ByteString" $
+      \xs -> let ys = B.pack $ filter (/= 0) xs in
+        ioProperty $ BSFP.withFilePath ys
+          (\ptr -> (=== ys) <$> B.packCString ptr)
+    , testProperty "PosixPath" $
+      \xs -> let ys = Sh.pack $ filter (/= 0) xs in
+        ioProperty $ PPFP.withFilePath (PosixString ys)
+          (\ptr -> (=== ys) <$> Sh.packCString ptr)
+    ]
+
 -------------------------------------------------------------------------------
 -- Utils
 
diff --git a/unix.cabal b/unix.cabal
index 8facf86f764a22ad46e96170812c4fb33db5205b..0b6642da95b1640388fe0853ded929e2d6210fc4 100644
--- a/unix.cabal
+++ b/unix.cabal
@@ -171,7 +171,7 @@ test-suite unix-tests
         Signals001
     type: exitcode-stdio-1.0
     default-language: Haskell2010
-    build-depends: base, tasty, tasty-hunit, unix
+    build-depends: base, bytestring, filepath, tasty, tasty-hunit, tasty-quickcheck, unix
     ghc-options: -Wall -with-rtsopts=-V0
 
 test-suite FdReadBuf001