feat: add unit test

This commit is contained in:
2019-09-20 01:57:35 +02:00
parent 779cd1da6e
commit dc396a300f
3 changed files with 40 additions and 61 deletions

View File

@@ -7,7 +7,7 @@ import (
"testing"
)
func TestDie(t *testing.T) {
func TestHamster_Die(t *testing.T) {
testCases := []struct {
caseName string
hamster *Hamster
@@ -39,7 +39,7 @@ func TestDie(t *testing.T) {
}
}
func TestFuck(t *testing.T) {
func TestHamster_Fuck(t *testing.T) {
testCases := []struct {
caseName string
hamster1 *Hamster
@@ -180,43 +180,6 @@ func TestFuck(t *testing.T) {
}
}
func TestHamster_Die(t *testing.T) {
tests := []struct {
name string
h *Hamster
}{
// TODO: Add test cases.
}
for _, tt := range tests {
tt.h.Die()
}
}
func TestHamster_Fuck(t *testing.T) {
type args struct {
another *Hamster
}
tests := []struct {
name string
h *Hamster
args args
want bool
wantErr bool
}{
// TODO: Add test cases.
}
for _, tt := range tests {
got, err := tt.h.Fuck(tt.args.another)
if (err != nil) != tt.wantErr {
t.Errorf("%q. Hamster.Fuck() error = %v, wantErr %v", tt.name, err, tt.wantErr)
continue
}
if got != tt.want {
t.Errorf("%q. Hamster.Fuck() = %v, want %v", tt.name, got, tt.want)
}
}
}
func TestBorn(t *testing.T) {
type args struct {
father *Hamster
@@ -242,28 +205,26 @@ func TestBorn(t *testing.T) {
}
}
func Test_randNumberChild(t *testing.T) {
tests := []struct {
name string
want int
}{
// TODO: Add test cases.
}
for _, tt := range tests {
if got := randNumberChild(); got != tt.want {
t.Errorf("%q. randNumberChild() = %v, want %v", tt.name, got, tt.want)
}
}
}
func Test_randSexe(t *testing.T) {
tests := []struct {
name string
want string
fakeGen int
}{
// TODO: Add test cases.
{
name: "Should be a male",
fakeGen: 1,
want: MALE,
},
{
name: "Should be a female",
fakeGen: 0,
want: FEMALE,
},
}
for _, tt := range tests {
randomizer.FakeRandomizer(tt.fakeGen)
if got := randSexe(); got != tt.want {
t.Errorf("%q. randSexe() = %v, want %v", tt.name, got, tt.want)
}
@@ -278,11 +239,21 @@ func Test_randNumber(t *testing.T) {
tests := []struct {
name string
args args
fakeGen int
want int
}{
// TODO: Add test cases.
{
name: "Should add min to result",
args: args{
min: 1,
max: 2,
},
fakeGen: 0,
want: 1,
},
}
for _, tt := range tests {
randomizer.FakeRandomizer(tt.fakeGen)
if got := randNumber(tt.args.min, tt.args.max); got != tt.want {
t.Errorf("%q. randNumber() = %v, want %v", tt.name, got, tt.want)
}