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

Function TestLineNormal

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

Source from the content-addressed store, hash-verified

528}
529
530func TestLineNormal(t *testing.T) {
531 data := []struct {
532 l Line
533 exp Point
534 }{
535 {
536 l: Line{
537 P1: Point{X: 0, Y: 0},
538 P2: Point{X: 0, Y: 0},
539 },
540 exp: Point{X: 0, Y: 0},
541 },
542 {
543 l: Line{
544 P1: Point{X: 0, Y: 0},
545 P2: Point{X: 0, Y: 8},
546 },
547 exp: Point{X: 1, Y: 0},
548 },
549 {
550 l: Line{
551 P1: Point{X: 0, Y: 0},
552 P2: Point{X: 8, Y: 0},
553 },
554 exp: Point{X: 0, Y: -1},
555 },
556 {
557 l: Line{
558 P1: Point{X: 0, Y: 0},
559 P2: Point{X: 8, Y: 8},
560 },
561 exp: Point{X: math.Sqrt(2) / 2, Y: -1 * math.Sqrt(2) / 2},
562 },
563 }
564 for _, d := range data {
565 if res := d.l.Normal(); !res.Equal(d.exp) {
566 t.Errorf("Test Line.Normal failed. l: %v, wanted: %v, got: %v", d.l, d.exp, res)
567 }
568 }
569}
570
571func TestDotProduct(t *testing.T) {
572 data := []struct {

Callers

nothing calls this directly

Calls 3

SqrtFunction · 0.92
NormalMethod · 0.80
EqualMethod · 0.80

Tested by

no test coverage detected