MCPcopy Create free account
hub / github.com/tdewolff/canvas / TestBentleyOttmannSortV

Function TestBentleyOttmannSortV

path_intersection_test.go:595–635  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

593}
594
595func TestBentleyOttmannSortV(t *testing.T) {
596 var tts = []struct {
597 a, b *SweepPoint
598 cmp int
599 }{
600 // common
601 {boSP(Point{0, 0}, Point{10, 0}, false), boSP(Point{-5, -5}, Point{5, -5}, false), 1},
602 {boSP(Point{0, 0}, Point{10, 0}, false), boSP(Point{-5, 5}, Point{5, 5}, false), -1},
603
604 // same left-endpoint X
605 {boSP(Point{0, 0}, Point{10, 0}, false), boSP(Point{0, -5}, Point{10, -5}, false), 1},
606 {boSP(Point{0, 0}, Point{10, 0}, false), boSP(Point{0, 5}, Point{10, 5}, false), -1},
607
608 // same left-endpoint X and Y
609 {boSP(Point{0, 0}, Point{10, 0}, false), boSP(Point{0, 0}, Point{10, -1}, false), 1},
610 {boSP(Point{0, 0}, Point{10, 0}, false), boSP(Point{0, 0}, Point{10, 1}, false), -1},
611
612 // horizontal equal
613 {boSP(Point{0, 0}, Point{10, 0}, false), boSP(Point{0, 0}, Point{0, 10}, true), -1},
614
615 // vertical
616 {boSP(Point{0, 0}, Point{0, 10}, false), boSP(Point{0, 0}, Point{10, 0}, false), 1},
617 {boSP(Point{0, 0}, Point{0, 10}, false), boSP(Point{0, 0}, Point{0, 5}, true), -1},
618
619 // vertical equal
620 {boSP(Point{0, 0}, Point{0, 10}, false), boSP(Point{0, 0}, Point{0, 10}, true), -1},
621
622 // special cases
623 {boSP(Point{0, 0}, Point{0, 10}, false), boSP(Point{-1, 20}, Point{0, 10}, true), -1},
624 {boSP(Point{0, 0}, Point{0, 10}, false), boSP(Point{-1, 0}, Point{0, 10}, true), -1},
625 {boSP(Point{0, 0}, Point{0, 10}, false), boSP(Point{-1, 5}, Point{0, 5}, true), -1},
626 {boSP(Point{0, 0}, Point{0, 10}, false), boSP(Point{-1, 10}, Point{0, 10}, true), -1},
627 {boSP(Point{0, -10}, Point{0, 10}, false), boSP(Point{-1e-12, 0}, Point{2e-12, 0}, true), -1},
628 }
629 for _, tt := range tts {
630 t.Run(fmt.Sprint(tt.a, "x", tt.b), func(t *testing.T) {
631 test.T(t, tt.a.CompareV(tt.b), tt.cmp)
632 test.T(t, tt.b.CompareV(tt.a), -tt.cmp)
633 })
634 }
635}
636
637func TestBentleyOttmannPrecision(t *testing.T) {
638 var tts = []struct {

Callers

nothing calls this directly

Calls 4

boSPFunction · 0.85
TMethod · 0.80
CompareVMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected