-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStack_test.go
More file actions
42 lines (33 loc) · 812 Bytes
/
Stack_test.go
File metadata and controls
42 lines (33 loc) · 812 Bytes
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
41
42
package main
import "testing"
func TestStackInitializes(t *testing.T) {
deck := Deck{
{13, "Clubs", "K"},
}
stack := deck.InitializeStack()
if len(stack) != 1 {
t.Error("Stack did not initialize.")
}
return
}
func TestStackTopCard(t *testing.T) {
deck := Deck{
{13, "Clubs", "K"},
}
stack := deck.InitializeStack()
if stack.PeekAtStack() != "KC" {
t.Error("Stack did not return correct card.")
}
h := Hand{}
h.DrawCard(&stack)
if stack.PeekAtStack() != "No cards in the stack." {
t.Error("Stack did not notify player that there are no cards in the stack.")
}
if !stack.IsEmpty() {
t.Error("Stack did not notify player that it is empty.")
}
_, err := h.DrawCard(&stack)
if err == nil {
t.Error("Stack did not throw error when we tried to draw from an empty stack.")
}
}