31 lines
876 B
Go
31 lines
876 B
Go
package input
|
|
|
|
import (
|
|
"testing"
|
|
|
|
fightinfo "blazing/logic/service/fight/info"
|
|
"blazing/modules/player/model"
|
|
)
|
|
|
|
func TestLivingTeammatesFiltersSelfAndDeadSlots(t *testing.T) {
|
|
owner := &Input{CurPet: []*fightinfo.BattlePetEntity{{Info: model.PetInfo{Hp: 10}}}}
|
|
aliveMate := &Input{CurPet: []*fightinfo.BattlePetEntity{{Info: model.PetInfo{Hp: 5}}}}
|
|
deadMate := &Input{CurPet: []*fightinfo.BattlePetEntity{{Info: model.PetInfo{Hp: 0}}}}
|
|
|
|
team := []*Input{owner, aliveMate, deadMate}
|
|
owner.Team = team
|
|
aliveMate.Team = team
|
|
deadMate.Team = team
|
|
|
|
teammates := owner.LivingTeammates()
|
|
if len(teammates) != 1 {
|
|
t.Fatalf("expected 1 living teammate, got %d", len(teammates))
|
|
}
|
|
if teammates[0] != aliveMate {
|
|
t.Fatalf("expected alive teammate to be returned")
|
|
}
|
|
if owner.HasLivingTeammate() != true {
|
|
t.Fatalf("expected owner to detect living teammate")
|
|
}
|
|
}
|