feat: add unit test
This commit is contained in:
@@ -17,7 +17,7 @@ const (
|
||||
const (
|
||||
TotalGestationPeriod = 15
|
||||
MinChild = 5
|
||||
MaxCild = 9
|
||||
MaxChild = 9
|
||||
GestationCooldown = (3 * 7) + 2
|
||||
GestationMinAge = 10 * 6
|
||||
MaxAge = 365 * 2
|
||||
@@ -114,7 +114,7 @@ func Born(father *Hamster, mother *Hamster) ([]*Hamster, error) {
|
||||
}
|
||||
|
||||
func randNumberChild() int {
|
||||
return randNumber(MinChild, MaxCild)
|
||||
return randNumber(MinChild, MaxChild)
|
||||
}
|
||||
|
||||
func randSexe() string {
|
||||
@@ -128,5 +128,5 @@ func randSexe() string {
|
||||
}
|
||||
|
||||
func randNumber(min int, max int) int {
|
||||
return min + randomizer.Rand(max-min)
|
||||
return min + randomizer.Rand(max)
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user