1
Fork 0
This repository has been archived on 2023-12-08. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
2022FuncProg-project2-patience/test/PatienceTest.hs
2022-11-15 21:59:29 +01:00

52 lines
2.4 KiB
Haskell

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)