Skip to content

Commit

Permalink
Test withFilePath
Browse files Browse the repository at this point in the history
  • Loading branch information
Bodigrim committed Sep 15, 2023
1 parent fadc6e1 commit 87c4b73
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions tests/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -49,6 +55,7 @@ main = defaultMain $ testGroup "All"
, posix010 -- JS: missing "sysconf"
]
#endif
, testWithFilePath
]

executeFile001 :: TestTree
Expand Down Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion unix.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 87c4b73

Please sign in to comment.