#15 Write tests
This commit is contained in:
parent
68facc87f5
commit
7e2448c8b9
3 changed files with 56 additions and 15 deletions
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)
|
||||
|
Reference in a new issue