-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a routine for path normalization
- Loading branch information
Showing
5 changed files
with
167 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
-- | | ||
-- Module : Streamly.Test.FileSystem.Path | ||
-- Copyright : (c) 2021 Composewell Technologies | ||
-- License : BSD-3-Clause | ||
-- Maintainer : [email protected] | ||
-- Stability : experimental | ||
-- Portability : GHC | ||
-- | ||
|
||
module Streamly.Test.FileSystem.Path (main) where | ||
|
||
import qualified System.FilePath as FilePath | ||
import qualified Streamly.Internal.FileSystem.Path as Path | ||
|
||
import Test.Hspec as H | ||
|
||
moduleName :: String | ||
moduleName = "FileSystem.Path" | ||
|
||
testNormalize :: String -> Spec | ||
testNormalize inp = | ||
it ("normalize: " ++ show inp) $ do | ||
p <- Path.fromString inp | ||
let expected = FilePath.normalise inp | ||
got = Path.toString (Path.normalize p) | ||
got `shouldBe` expected | ||
|
||
main :: IO () | ||
main = | ||
hspec $ | ||
H.parallel $ | ||
describe moduleName $ do | ||
describe "normalize" $ do | ||
testNormalize "/file/\\test////" | ||
testNormalize "/file/./test" | ||
testNormalize "/test/file/../bob/fred/" | ||
testNormalize "../bob/fred/" | ||
testNormalize "/a/../c" | ||
testNormalize "./bob/fred/" | ||
testNormalize "." | ||
testNormalize "./" | ||
testNormalize "./." | ||
testNormalize "/./" | ||
testNormalize "/" | ||
testNormalize "bob/fred/." | ||
testNormalize "//home" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters