mirror of
https://github.com/Yvee1/hascard.git
synced 2024-11-22 04:33:06 +03:00
add some tests
This commit is contained in:
parent
4519a7bc2c
commit
fffaba062a
@ -17,5 +17,6 @@ before_install:
|
|||||||
script:
|
script:
|
||||||
- stack setup
|
- stack setup
|
||||||
- stack build
|
- stack build
|
||||||
|
- stack test
|
||||||
after_success:
|
after_success:
|
||||||
- sh travis/attach-binary.sh
|
- sh travis/attach-binary.sh
|
@ -38,6 +38,11 @@ dependencies:
|
|||||||
- vector >= 0.12.0 && < 0.13
|
- vector >= 0.12.0 && < 0.13
|
||||||
- vty >= 5.28.2 && < 5.31
|
- vty >= 5.28.2 && < 5.31
|
||||||
- word-wrap >= 0.4.1 && < 0.5
|
- word-wrap >= 0.4.1 && < 0.5
|
||||||
|
# - QuickCheck >= 2.13 && < 2.14
|
||||||
|
# - HUnit >= 1.6.0 && < 1.7
|
||||||
|
- tasty
|
||||||
|
- tasty-hunit
|
||||||
|
- tasty-quickcheck
|
||||||
|
|
||||||
library:
|
library:
|
||||||
source-dirs: src
|
source-dirs: src
|
||||||
|
80
test/Spec.hs
80
test/Spec.hs
@ -1,2 +1,80 @@
|
|||||||
|
import Test.Tasty
|
||||||
|
import Test.Tasty.HUnit
|
||||||
|
import Test.Tasty.QuickCheck
|
||||||
|
import DeckHandling
|
||||||
|
import Parser
|
||||||
|
import States
|
||||||
|
import Recents
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = putStrLn "Test suite not yet implemented"
|
main = defaultMain tests
|
||||||
|
|
||||||
|
tests :: TestTree
|
||||||
|
tests = testGroup "Tests" [unitTests]
|
||||||
|
|
||||||
|
unitTests :: TestTree
|
||||||
|
unitTests = testGroup "Unit tests"
|
||||||
|
[ testRecents
|
||||||
|
, testChunking
|
||||||
|
]
|
||||||
|
|
||||||
|
testRecents :: TestTree
|
||||||
|
testRecents = testGroup "Shortening filepaths"
|
||||||
|
[ testCase "empty recents" $
|
||||||
|
shortenFilepaths [] @?= []
|
||||||
|
, testRecentsExtension ".txt"
|
||||||
|
, testRecentsExtension ".md"
|
||||||
|
, testRecentsMix
|
||||||
|
]
|
||||||
|
|
||||||
|
testRecentsExtension :: String -> TestTree
|
||||||
|
testRecentsExtension ext = testGroup ("Extension " <> ext)
|
||||||
|
[ testCase "different file names" $
|
||||||
|
shortenFilepaths ["some/path/deck1" <> ext, "some/other/path/deck2" <> ext, "some/new/path/deck3" <> ext]
|
||||||
|
@?=
|
||||||
|
["deck1", "deck2", "deck3"]
|
||||||
|
|
||||||
|
, testCase "recents same file name" $
|
||||||
|
shortenFilepaths ["/path/to/deck" <> ext, "/path/to/another/deck" <> ext, "other/path/normal" <> ext]
|
||||||
|
@?=
|
||||||
|
["to/deck", "another/deck", "normal"]
|
||||||
|
|
||||||
|
, testCase "recents same directory and file name" $
|
||||||
|
shortenFilepaths ["/some/directory/deck" <> ext, "/another/directory/deck" <> ext, "other/path/normal" <> ext]
|
||||||
|
@?=
|
||||||
|
["some/directory/deck", "another/directory/deck", "normal"]
|
||||||
|
]
|
||||||
|
|
||||||
|
testRecentsMix :: TestTree
|
||||||
|
testRecentsMix = testGroup "Mixed extensions"
|
||||||
|
[ testCase "different file names" $
|
||||||
|
shortenFilepaths ["some/path/deck1.txt", "some/other/path/deck2.txt", "some/new/path/deck3.md"]
|
||||||
|
@?=
|
||||||
|
["deck1.txt", "deck2.txt", "deck3.md"]
|
||||||
|
|
||||||
|
, testCase "recents same file name, same extension" $
|
||||||
|
shortenFilepaths ["/path/to/deck.txt", "/path/to/another/deck.txt", "other/path/normal.md"]
|
||||||
|
@?=
|
||||||
|
["to/deck.txt", "another/deck.txt", "normal.md"]
|
||||||
|
|
||||||
|
, testCase "recents same file name, different extension" $
|
||||||
|
shortenFilepaths ["/path/to/deck.md", "/path/to/another/deck.txt", "other/path/normal.md"]
|
||||||
|
@?=
|
||||||
|
["deck.md", "deck.txt", "normal.md"]
|
||||||
|
|
||||||
|
, testCase "recents same directory and file name, same extension" $
|
||||||
|
shortenFilepaths ["/some/directory/deck.md", "/another/directory/deck.md", "other/path/normal.txt"]
|
||||||
|
@?=
|
||||||
|
["some/directory/deck.md", "another/directory/deck.md", "normal.txt"]
|
||||||
|
|
||||||
|
, testCase "recents same directory and file name, different extension" $
|
||||||
|
shortenFilepaths ["/some/directory/deck.txt", "/another/directory/deck.md", "other/path/normal.txt"]
|
||||||
|
@?=
|
||||||
|
["deck.txt", "deck.md", "normal.txt"]
|
||||||
|
]
|
||||||
|
|
||||||
|
testChunking :: TestTree
|
||||||
|
testChunking = testGroup "QuickCheck"
|
||||||
|
[ testProperty "concat . doChunking n == id" $
|
||||||
|
\xs n -> n > 0 ==> concat (splitIntoNChunks n xs) == (xs :: [Int])
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user