MCPcopy Index your code
hub / github.com/EngoEngine/engo / TestSpaceComponent_Contains

Function TestSpaceComponent_Contains

common/collision_test.go:12–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestSpaceComponent_Contains(t *testing.T) {
13 space := SpaceComponent{Width: 100, Height: 100}
14 pass := []engo.Point{
15 {X: 10, Y: 10},
16 {X: 50, Y: 50},
17 {X: 10, Y: 50},
18 {X: 99, Y: 99},
19 }
20 fail := []engo.Point{
21 // Totally not within:
22 {X: -10, Y: -10},
23 {X: 120, Y: 120},
24
25 // Only one axis within:
26 {X: 50, Y: 120},
27 {X: 120, Y: 50},
28
29 // On the edge:
30 {X: 0, Y: 0},
31 {X: 0, Y: 50},
32 {X: 0, Y: 100},
33 {X: 50, Y: 0},
34 {X: 50, Y: 100},
35 {X: 100, Y: 0},
36 {X: 100, Y: 50},
37 {X: 100, Y: 100},
38 }
39
40 for _, p := range pass {
41 assert.True(t, space.Contains(p), fmt.Sprintf("point %v should be within area", p))
42 }
43
44 for _, f := range fail {
45 assert.False(t, space.Contains(f), fmt.Sprintf("point %v should not be within area", f))
46 }
47}
48
49func TestSpaceComponent_Contains_Hitboxes(t *testing.T) {
50 scs := []SpaceComponent{}

Callers

nothing calls this directly

Calls 1

ContainsMethod · 0.95

Tested by

no test coverage detected