about summary refs log tree commit diff
path: root/haskell-file/tests.hs
blob: e3967b77de1f033522ba5cb30f6fbc3e2c47b809 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
module FTest where
--------------------------------------------------------------------------------
import Test.Tasty
import Test.Tasty.Hedgehog
import Hedgehog
--------------------------------------------------------------------------------
import qualified Hedgehog as H
import qualified Hedgehog.Gen as Gen
import qualified Hedgehog.Range as Range
--------------------------------------------------------------------------------
import Data.List (intercalate)
import System.FilePath (pathSeparator)
--------------------------------------------------------------------------------
import F
--------------------------------------------------------------------------------
main :: IO ()
main
  = defaultMain
  . localOption (HedgehogTestLimit $ Just 50)
  $ testGroup "f functions"
  [ test_split
  ]
--------------------------------------------------------------------------------
test_split :: TestTree
test_split
  = testGroup "split function"
  [ testProperty "splits parts properly" splitSuccess
  ]
splitSuccess :: Property
splitSuccess = property $ do
  -- separator
  --   <- H.forAll
  --   $ Gen.element ['/', '\\']
  parts
    <- H.forAll
    . Gen.list (Range.linear 0 10)
    $ Gen.list (Range.linear 1 10) Gen.alphaNum
  let path = intercalate [pathSeparator] parts
  F.split path === parts