-
Notifications
You must be signed in to change notification settings - Fork 13
/
fudge_test.go
75 lines (53 loc) · 1.49 KB
/
fudge_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
package dice_test
import (
"testing"
. "github.com/justinian/dice"
. "gopkg.in/check.v1"
)
/* =============================================================================
* Fudge dice test suite
*/
func TestFudge(t *testing.T) { TestingT(t) }
type fudgeSuite struct{}
var _ = Suite(&fudgeSuite{})
/* =============================================================================
* Fudge dice test cases
*/
func (s *fudgeSuite) TestBounds(c *C) {
var roller FudgeRoller
r, err := roller.Roll([]string{"100df", "100", "", ""})
res := r.(FudgeResult)
c.Assert(err, IsNil)
for _, v := range res.Rolls {
if v < -1 || v > +1 {
c.Errorf("Rolled out of bounds on a dF: %d", v)
}
}
}
func (s *fudgeSuite) TestCount(c *C) {
var roller FudgeRoller
r, err := roller.Roll([]string{"100df", "100", "", ""})
res := r.(FudgeResult)
c.Assert(err, IsNil)
c.Assert(res.Rolls, HasLen, 100)
}
func (s *fudgeSuite) TestAdd(c *C) {
var roller FudgeRoller
r, err := roller.Roll([]string{"1df+13", "1", "+13"})
res := r.(FudgeResult)
if res.Total < 12 || res.Total > 14 {
c.Errorf("Added roll out of bounds on a dF: %d", res.Total)
}
c.Assert(err, IsNil)
c.Assert(res.Rolls, HasLen, 1)
}
func (s *fudgeSuite) TestSubtract(c *C) {
var roller FudgeRoller
r, err := roller.Roll([]string{"1df+13", "1", "-13"})
res := r.(FudgeResult)
if res.Total < -14 || res.Total > -12 {
c.Errorf("Added roll out of bounds on a dF: %d", res.Total)
}
c.Assert(err, IsNil)
c.Assert(res.Rolls, HasLen, 1)
}