forked from hironobu-s/conohasay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cow_test.go
43 lines (35 loc) · 859 Bytes
/
cow_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
package main
import (
"sort"
"testing"
)
func TestListCows(t *testing.T) {
names := []string{"conoha", "anzu", "umemiya", "logo"}
cows := ListCows()
sort.Strings(names)
sort.Strings(cows)
if len(names) != len(cows) {
t.Errorf("Number of cows is not match the defined size.")
}
for i := 0; i < len(names); i++ {
if names[i] != cows[i] {
t.Errorf("[%s] is undefined or Extra cow?", cows[i])
}
}
}
func TestNewCow(t *testing.T) {
names := []string{"conoha", "anzu", "umemiya", "logo"}
sizes := []string{"s", "m", "l"}
for i := 0; i < len(names); i++ {
for j := 0; j < len(sizes); j++ {
cow, err := NewCow(names[i], sizes[j])
if err != nil {
t.Error(err)
} else if cow.Name != names[i] {
t.Errorf("cow has the wrong name.")
} else if cow.Size != sizes[j] {
t.Errorf("cow has the wrong size.")
}
}
}
}