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

Function TestLinePointDistance

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

Source from the content-addressed store, hash-verified

474}
475
476func TestLinePointDistance(t *testing.T) {
477 data := []struct {
478 l Line
479 p Point
480 exp float32
481 }{
482 {
483 l: Line{
484 P1: Point{X: 0, Y: 0},
485 P2: Point{X: 0, Y: 0},
486 },
487 p: Point{X: 0, Y: 0},
488 exp: 0,
489 },
490 {
491 l: Line{
492 P1: Point{X: 0, Y: 0},
493 P2: Point{X: 8, Y: 8},
494 },
495 p: Point{X: 3, Y: 4},
496 exp: 0.70710677,
497 },
498 {
499 l: Line{
500 P1: Point{X: 0, Y: 0},
501 P2: Point{X: 8, Y: 8},
502 },
503 p: Point{X: 3, Y: 3},
504 exp: 0,
505 },
506 {
507 l: Line{
508 P1: Point{X: 0, Y: 0},
509 P2: Point{X: 8, Y: 8},
510 },
511 p: Point{X: 13, Y: 10},
512 exp: 5.3851647,
513 },
514 {
515 l: Line{
516 P1: Point{X: 0, Y: 0},
517 P2: Point{X: 8, Y: 8},
518 },
519 p: Point{X: -13, Y: -10},
520 exp: 16.40122,
521 },
522 }
523 for _, d := range data {
524 if res := d.l.PointDistance(d.p); res != d.exp {
525 t.Errorf("Test Line.PointDistance failed. l: %v, p: %v, wanted: %v, got: %v", d.l, d.p, d.exp, res)
526 }
527 }
528}
529
530func TestLineNormal(t *testing.T) {
531 data := []struct {

Callers

nothing calls this directly

Calls 1

PointDistanceMethod · 0.45

Tested by

no test coverage detected