#15 Write tests
This commit is contained in:
parent
68facc87f5
commit
7e2448c8b9
3 changed files with 56 additions and 15 deletions
|
@ -6,18 +6,18 @@ build-type: Simple
|
|||
|
||||
library
|
||||
hs-source-dirs: lib
|
||||
build-depends: base >= 4.7 && <5, random >= 1.1 && < 1.4
|
||||
exposed-modules: CardDeck, PatienceBoard, Shuffle
|
||||
build-depends: base >= 4.7 && <5, gloss >= 1.11 && < 1.14, gloss-juicy >= 0.2.3, random >= 1.1 && < 1.4
|
||||
exposed-modules: CardDeck, CardRenderer, InputHandler, Patience, PatienceBoard, PatienceRenderer, PNGRenderer, Selector, SelectorRenderer, Shuffle
|
||||
|
||||
executable patience
|
||||
main-is: Main.hs
|
||||
hs-source-dirs: src
|
||||
default-language: Haskell2010
|
||||
build-depends: base >= 4.7 && <5, gloss >= 1.11 && < 1.14, gloss-juicy >= 0.2.3, patience
|
||||
build-depends: base >= 4.7 && <5, gloss >= 1.11 && < 1.14, patience
|
||||
|
||||
test-suite patience-test
|
||||
type: exitcode-stdio-1.0
|
||||
main-is: VoorbeeldTest.hs
|
||||
main-is: PatienceTest.hs
|
||||
hs-source-dirs: test
|
||||
default-language: Haskell2010
|
||||
build-depends: base >=4.7 && <5, hspec <= 2.10.6, patience
|
||||
|
|
52
test/PatienceTest.hs
Normal file
52
test/PatienceTest.hs
Normal file
|
@ -0,0 +1,52 @@
|
|||
import Test.Hspec
|
||||
|
||||
import CardDeck
|
||||
import PatienceBoard
|
||||
import Selector
|
||||
|
||||
main :: IO ()
|
||||
main = hspec $ do
|
||||
describe "Testing CardDeck" $ do
|
||||
it "generateDeck generates a full sized deck" $ do
|
||||
length generateDeck == 52
|
||||
|
||||
it "showCard shows card" $ do
|
||||
showCard (Hearts, Ace, Hidden) `shouldBe` (Hearts, Ace, Visible)
|
||||
showCard (Clubs, King, Visible) `shouldBe` (Clubs, King, Visible)
|
||||
|
||||
it "hideCard hides card" $ do
|
||||
hideCard (Hearts, King, Hidden) `shouldBe` (Hearts, King, Hidden)
|
||||
hideCard (Spades, Ace, Visible) `shouldBe` (Spades, Ace, Hidden)
|
||||
|
||||
it "flipCard flips card" $ do
|
||||
flipCard (Hearts, Ace, Hidden) `shouldBe` (Hearts, Ace, Visible)
|
||||
flipCard (Hearts, Ace, Visible) `shouldBe` (Hearts, Ace, Hidden)
|
||||
|
||||
it "matchType checks types" $ do
|
||||
matchType (Hearts, Ace, Visible) (Hearts, King, Hidden) `shouldBe` True
|
||||
matchType (Hearts, Ace, Visible) (Clubs, Ace, Visible) `shouldBe` False
|
||||
matchType (NoneType, Ace, Hidden) (Spades, King, Hidden) `shouldBe` False
|
||||
|
||||
it "matchColor checks colors" $ do
|
||||
matchColor (Hearts, Ace, Visible) (Hearts, King, Hidden) `shouldBe` True
|
||||
matchColor (Hearts, Ace, Visible) (Diamonds, King, Hidden) `shouldBe` True
|
||||
matchColor (Spades, King, Hidden) (Clubs, Two, Visible) `shouldBe` True
|
||||
matchColor (Spades, King, Hidden) (Hearts, Three, Visible) `shouldBe` False
|
||||
matchColor (Diamonds, Four, Visible) (Clubs, Five, Hidden) `shouldBe` False
|
||||
|
||||
describe "Testing PatienceBoard" $ do
|
||||
it "Starts with empty endingStacks" $ do
|
||||
endingStacks (board initGame) `shouldBe` [[],[],[],[]]
|
||||
it "Check size of pile at start of game" $ do
|
||||
length (pile (board initGame)) `shouldBe` foldl (-) 52 [0 .. amountOfGameStacks]
|
||||
it "First gameStack should be smallest" $ do
|
||||
length (head (gameStacks (board initGame))) `shouldBe` 1
|
||||
it "Last gameStack should be biggest" $ do
|
||||
length (gameStacks (board initGame) !! (amountOfGameStacks - 1)) `shouldBe` amountOfGameStacks
|
||||
|
||||
describe "Testing Selector" $ do
|
||||
it "initSelector is empty" $ do
|
||||
selected initSelector `shouldBe` Nothing
|
||||
it "select selects" $ do
|
||||
selected (toggleSelection initSelector) `shouldBe` Just (0,0)
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
import Test.Hspec
|
||||
|
||||
import VoorbeeldModule (hoi, hallo)
|
||||
|
||||
main :: IO ()
|
||||
main = hspec $ do
|
||||
it "Returns correct string for hoi" $ do
|
||||
hoi `shouldBe` "Hoi"
|
||||
|
||||
it "Returns correct string for hallo" $ do
|
||||
hallo `shouldBe` "Hallo"
|
Reference in a new issue