Prevented test results order mattering

This commit is contained in:
Ben Cragg 2019-04-04 15:31:34 +01:00
parent bcda85acd2
commit 364a7a84ae
1 changed files with 18 additions and 2 deletions

View File

@ -839,6 +839,16 @@ func TestRect_IntersectCircle(t *testing.T) {
}
func TestRect_IntersectionPoints(t *testing.T) {
in := func(v pixel.Vec, vs []pixel.Vec) bool {
for _, vec := range vs {
if vec == v {
return true
}
}
return false
}
type fields struct {
Min pixel.Vec
Max pixel.Vec
@ -877,8 +887,14 @@ func TestRect_IntersectionPoints(t *testing.T) {
Min: tt.fields.Min,
Max: tt.fields.Max,
}
if got := r.IntersectionPoints(tt.args.l); !reflect.DeepEqual(got, tt.want) {
t.Errorf("Rect.IntersectPoints() = %v, want %v", got, tt.want)
got := r.IntersectionPoints(tt.args.l)
if len(got) != len(tt.want) {
t.Errorf("Rect.IntersectPoints() has incorrect length. Expected %d, got %d", len(tt.want), len(got))
}
for _, v := range got {
if !in(v, tt.want) {
t.Errorf("Rect.IntersectPoints(): got unexpected result = %v", v)
}
}
})
}