-
Notifications
You must be signed in to change notification settings - Fork 5
/
card_test.go
62 lines (52 loc) · 1.66 KB
/
card_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
54
55
56
57
58
59
60
61
62
package deck
import (
"fmt"
"testing"
"github.com/stretchr/testify/assert"
)
func TestCardToString(t *testing.T) {
card := NewCard(ACE, HEART)
result := fmt.Sprintf("%s", card)
assert.Equal(t, "A♥", result, "These should be equal")
}
func TestCardSignature(t *testing.T) {
card := NewCard(ACE, HEART)
result := card.GetSignature()
assert.Equal(t, "02", result, "These should be equal")
}
func TestCardCompare(t *testing.T) {
card1 := NewCard(ACE, HEART)
card2 := NewCard(KING, HEART)
result := DefaultCompare(card1, card2)
assert.Equal(t, CompareResult(-1), result, "These should be equal")
}
func TestCardIsLessThan(t *testing.T) {
card1 := NewCard(ACE, HEART)
card2 := NewCard(KING, HEART)
result := DefaultCompare(card1, card2).IsLessThan()
assert.Equal(t, true, result, "These should be equal")
}
func TestCardIsEqual(t *testing.T) {
card1 := NewCard(ACE, HEART)
card2 := NewCard(ACE, HEART)
result := DefaultCompare(card1, card2).IsEqualTo()
assert.Equal(t, true, result, "These should be equal")
}
func TestCardIsGreaterThan(t *testing.T) {
card1 := NewCard(ACE, HEART)
card2 := NewCard(KING, HEART)
result := DefaultCompare(card2, card1).IsGreaterThan()
assert.Equal(t, true, result, "These should be equal")
}
func TestCardIsGreaterThanWithSuit(t *testing.T) {
card1 := NewCard(ACE, SPADE)
card2 := NewCard(ACE, HEART)
result := DefaultCompare(card1, card2).IsGreaterThan()
assert.Equal(t, true, result, "These should be equal")
}
func TestCardIsLessThanWithSuit(t *testing.T) {
card1 := NewCard(ACE, HEART)
card2 := NewCard(ACE, SPADE)
result := DefaultCompare(card1, card2).IsLessThan()
assert.Equal(t, true, result, "These should be equal")
}