-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy patheote_test.go
87 lines (66 loc) · 1.89 KB
/
eote_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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package dice_test
import (
. "github.com/justinian/dice"
. "gopkg.in/check.v1"
)
/* =============================================================================
* Eote dice test suite
*/
type eoteSuite struct {
}
/*
func (s *DiceSuite) SetUpSuite(c *C) {
}
func (s *DiceSuite) SetUpTest(c *C) {
}
*/
var _ = Suite(&eoteSuite{})
/* =============================================================================
* Eote dice test cases
*/
func (s *eoteSuite) TestPositive(c *C) {
var roller EoteRoller
r, err := roller.Roll([]string{"100b 100g 100y", ""})
res := r.(EoteResult)
c.Assert(err, IsNil)
c.Assert(res.EoteDie.String(), Matches, "\\[s+a+T+\\]")
c.Assert(res.String(), Matches, "(?s).*\\d+ success \\d+ advantage \\(\\d+ triumph\\)(?s).*")
c.Check(res.D, Equals, 0)
c.Check(res.F, Equals, 0)
if res.S <= 0 {
c.Errorf("Total successes on positive-only roll: %d", res.S)
}
if res.A <= 0 {
c.Errorf("Total advantage on positive-only roll: %d", res.A)
}
}
func (s *eoteSuite) TestNegative(c *C) {
var roller EoteRoller
r, err := roller.Roll([]string{"100blk 100p 100r", ""})
res := r.(EoteResult)
c.Assert(err, IsNil)
c.Assert(res.EoteDie.String(), Matches, "\\[f+d+D+\\]")
c.Assert(res.String(), Matches, "(?s).*\\d+ failure \\d+ disadvantage \\(\\d+ despair\\)(?s).*")
c.Check(res.T, Equals, 0)
c.Check(res.F, Equals, 0)
if res.S >= 0 {
c.Errorf("Total successes on negative-only roll: %d", res.S)
}
if res.A >= 0 {
c.Errorf("Total advantage on negative-only roll: %d", res.A)
}
}
func (s *eoteSuite) TestForce(c *C) {
var roller EoteRoller
r, err := roller.Roll([]string{"100w", ""})
res := r.(EoteResult)
c.Assert(err, IsNil)
c.Check(res.T, Equals, 0)
c.Check(res.D, Equals, 0)
c.Check(res.S, Equals, 0)
c.Check(res.A, Equals, 0)
}
func (s *eoteSuite) TestBadRoll(c *C) {
var roller EoteRoller
c.Check(roller.Pattern().FindStringSubmatch("1l 1q"), IsNil)
}