aboutsummaryrefslogtreecommitdiff
path: root/tests/Tests/Shared.hs
blob: 4ff1dc837cc2adb63aa066c482a5b5253df8b75b (plain)
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
40
module Tests.Shared (tests) where

import Text.Pandoc.Shared
import Test.Framework
import Text.Pandoc.Arbitrary()
import Test.Framework.Providers.HUnit
import Test.HUnit ( assertBool, (@?=) )
import Text.Pandoc.Builder
import System.FilePath.Posix (joinPath)

tests :: [Test]
tests = [ testGroup "compactify'DL"
          [ testCase "compactify'DL with empty def" $
              assertBool "compactify'DL"
              (let x = [(str "word", [para (str "def"), mempty])]
               in  compactify'DL x == x)
          ]
        , testGroup "collapseFilePath" testCollapse
        ]

testCollapse :: [Test]
testCollapse = map (testCase "collapse")
 [  (collapseFilePath (joinPath [ ""]) @?= (joinPath [ ""]))
 ,  (collapseFilePath (joinPath [ ".","foo"]) @?= (joinPath [ "foo"]))
 ,  (collapseFilePath (joinPath [ ".",".","..","foo"]) @?= (joinPath [ joinPath ["..", "foo"]]))
 ,  (collapseFilePath (joinPath [ "..","foo"]) @?= (joinPath [ "..","foo"]))
 ,  (collapseFilePath (joinPath [ "","bar","..","baz"]) @?= (joinPath [ "","baz"]))
 ,  (collapseFilePath (joinPath [ "","..","baz"]) @?= (joinPath [ "","..","baz"]))
 ,  (collapseFilePath (joinPath [ ".","foo","..",".","bar","..",".",".","baz"]) @?= (joinPath [ "baz"]))
 ,  (collapseFilePath (joinPath [ ".",""]) @?= (joinPath [ ""]))
 ,  (collapseFilePath (joinPath [ ".",".",""]) @?= (joinPath [ ""]))
 ,  (collapseFilePath (joinPath [ "..",""]) @?= (joinPath [ ".."]))
 ,  (collapseFilePath (joinPath [ "..",".",""]) @?= (joinPath [ ".."]))
 ,  (collapseFilePath (joinPath [ ".","..",""]) @?= (joinPath [ ".."]))
 ,  (collapseFilePath (joinPath [ "..","..",""]) @?= (joinPath [ "..",".."]))
 ,  (collapseFilePath (joinPath [ "parent","foo","baz","..","bar"]) @?= (joinPath [ "parent","foo","bar"]))
 ,  (collapseFilePath (joinPath [ "parent","foo","baz","..","..","bar"]) @?= (joinPath [ "parent","bar"]))
 ,  (collapseFilePath (joinPath [ "parent","foo",".."]) @?= (joinPath [ "parent"]))
 ,  (collapseFilePath (joinPath [ "","parent","foo","..","..","bar"]) @?= (joinPath [ "","bar"]))
 ,  (collapseFilePath (joinPath [ "",".","parent","foo"]) @?= (joinPath [ "","parent","foo"]))]