-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcard_test.go
42 lines (37 loc) · 1.11 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
package main
import (
"slices"
"testing"
)
func TestGenerateFull(t *testing.T) {
ct := CardTemplate{Card: Card{Name: "test"}, FoodSlice: []int{0, 1, 2}}
want := []Card{{Name: "test", FoodPoints: 0}, {Name: "test", FoodPoints: 1}, {Name: "test", FoodPoints: 2}}
got := ct.generate()
if !slices.Equal(got, want) {
t.Errorf("Generate() = %v, want %v", got, want)
}
}
func TestGenerateFoodSliceDouble(t *testing.T) {
ct := CardTemplate{Card: Card{Name: "test"}, FoodSlice: []int{1, 1}}
want := []Card{{Name: "test", FoodPoints: 1}, {Name: "test", FoodPoints: 1}}
got := ct.generate()
if !slices.Equal(got, want) {
t.Errorf("Generate() = %v, want %v", got, want)
}
}
func TestGenerateFoodSliceEmpty(t *testing.T) {
ct := CardTemplate{Card: Card{Name: "test"}, FoodSlice: []int{}}
want := []Card{}
got := ct.generate()
if !slices.Equal(got, want) {
t.Errorf("Generate() = %v, want %v", got, want)
}
}
func TestGenerateFoodSliceNil(t *testing.T) {
ct := CardTemplate{Card: Card{Name: "test"}}
want := []Card{}
got := ct.generate()
if !slices.Equal(got, want) {
t.Errorf("Generate() = %v, want %v", got, want)
}
}