-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdie_test.go
47 lines (44 loc) · 821 Bytes
/
die_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
package dice
import (
"context"
"testing"
)
// ensure Die implements Roller
var _ Roller = (*Die)(nil)
func TestDie_Roll(t *testing.T) {
type args struct {
ctx context.Context
}
tests := []struct {
name string
d *Die
args args
wantErr bool
}{
{
name: "0-sided",
d: MustNewDie(&RollerProperties{
Type: TypePolyhedron,
Size: 0,
Count: 1,
}).(*Die),
args: args{context.TODO()},
},
{
name: "1-sided",
d: MustNewDie(&RollerProperties{
Type: TypePolyhedron,
Size: 1,
Count: 1,
}).(*Die),
args: args{context.TODO()},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if err := tt.d.Roll(tt.args.ctx); (err != nil) != tt.wantErr {
t.Errorf("Die.Roll() error = %v, wantErr %v", err, tt.wantErr)
}
})
}
}