-
Notifications
You must be signed in to change notification settings - Fork 4
/
rules_test.go
53 lines (43 loc) · 1.28 KB
/
rules_test.go
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
43
44
45
46
47
48
49
50
51
52
53
package main
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestRuleCanMoveToBuild_Empty(t *testing.T) {
g := NewGame()
card := NewCard(1, SuitClubs)
assert.True(t, g.ruleCanMoveToBuild(g.Build1, card))
card.Value = 3
assert.False(t, g.ruleCanMoveToBuild(g.Build1, card))
}
func TestRuleCanMoveToBuild_Over(t *testing.T) {
g := NewGame()
card := NewCard(1, SuitClubs)
g.Build1.Push(card)
card = NewCard(2, SuitClubs)
assert.True(t, g.ruleCanMoveToBuild(g.Build1, card))
card.Suit = SuitDiamonds
assert.False(t, g.ruleCanMoveToBuild(g.Build1, card))
}
func TestRuleCanMoveToStack_Empty(t *testing.T) {
g := NewGame()
card := NewCard(ValueKing, SuitClubs)
g.Stack1.Cards = []*Card{}
assert.True(t, g.ruleCanMoveToStack(g.Stack1, card))
card.Value = 3
assert.False(t, g.ruleCanMoveToStack(g.Build1, card))
}
func TestRuleCanMoveToStack_Over(t *testing.T) {
g := NewGame()
card := NewCard(10, SuitClubs)
g.Stack1.Cards = []*Card{card}
card = NewCard(9, SuitHearts)
assert.True(t, g.ruleCanMoveToStack(g.Stack1, card))
card.Value = 3
assert.False(t, g.ruleCanMoveToStack(g.Stack1, card))
card.Value = 9
card.Suit = SuitSpades
assert.False(t, g.ruleCanMoveToStack(g.Stack1, card))
card.Suit = SuitDiamonds
assert.True(t, g.ruleCanMoveToStack(g.Stack1, card))
}