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

Function TestPointPointDistance

math_test.go:224–241  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

222}
223
224func TestPointPointDistance(t *testing.T) {
225 data := []struct {
226 p1, p2 Point
227 exp float32
228 }{
229 {p1: Point{X: 0, Y: 0}, p2: Point{X: 0, Y: 0}, exp: 0.0},
230 {p1: Point{X: 0, Y: 0}, p2: Point{X: 3, Y: 4}, exp: 5.0},
231 {p1: Point{X: -4, Y: -3}, p2: Point{X: 0, Y: 0}, exp: 5.0},
232 {p1: Point{X: 2, Y: 4}, p2: Point{X: -1, Y: 0}, exp: 5.0},
233 {p1: Point{X: -9, Y: -2}, p2: Point{X: -16, Y: -26}, exp: 25.0},
234 {p1: Point{X: 161, Y: 240}, p2: Point{X: 322, Y: 480}, exp: 289.0},
235 }
236 for _, d := range data {
237 if actual := d.p1.PointDistance(d.p2); actual != d.exp {
238 t.Errorf("Test Point.PointDistance failed. p1: %v, p2: %v, wanted: %v, got: %v", d.p1, d.p2, d.exp, actual)
239 }
240 }
241}
242
243func TestPointProjectOnto(t *testing.T) {
244 data := []struct {

Callers

nothing calls this directly

Calls 1

PointDistanceMethod · 0.45

Tested by

no test coverage detected