MCPcopy Index your code
hub / github.com/tdewolff/canvas / TestPathSplitAt

Function TestPathSplitAt

path_test.go:599–637  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

597}
598
599func TestPathSplitAt(t *testing.T) {
600 var tts = []struct {
601 p string
602 d []float64
603 rs []string
604 }{
605 {"L4 3L8 0z", []float64{}, []string{"L4 3L8 0z"}},
606 {"M2 0L4 3Q10 10 20 0C20 10 30 10 30 0A10 10 0 0 0 50 0z", []float64{0.0}, []string{"M2 0L4 3Q10 10 20 0C20 10 30 10 30 0A10 10 0 0 0 50 0L2 0"}},
607 {"L4 3L8 0z", []float64{0.0, 5.0, 10.0, 18.0}, []string{"L4 3", "M4 3L8 0", "M8 0L0 0"}},
608 {"L4 3L8 0z", []float64{5.0, 20.0}, []string{"L4 3", "M4 3L8 0L0 0"}},
609 {"L4 3L8 0z", []float64{2.5, 7.5, 14.0}, []string{"L2 1.5", "M2 1.5L4 3L6 1.5", "M6 1.5L8 0L4 0", "M4 0L0 0"}},
610 {"Q10 10 20 0", []float64{11.477858}, []string{"Q5 5 10 5", "M10 5Q15 5 20 0"}},
611 {"C0 10 20 10 20 0", []float64{13.947108}, []string{"C0 5 5 7.5 10 7.5", "M10 7.5C15 7.5 20 5 20 0"}},
612 {"A10 10 0 0 1 -20 0", []float64{15.707963}, []string{"A10 10 0 0 1 -10 10", "M-10 10A10 10 0 0 1 -20 0"}},
613 {"A10 10 0 0 0 20 0", []float64{15.707963}, []string{"A10 10 0 0 0 10 10", "M10 10A10 10 0 0 0 20 0"}},
614 {"A10 10 0 1 0 2.9289 -7.0711", []float64{15.707963}, []string{"A10 10 0 0 0 10.024 9.9999", "M10.024 9.9999A10 10 0 1 0 2.9289 -7.0711"}},
615 }
616 origEpsilon := Epsilon
617 for _, tt := range tts {
618 t.Run(tt.p, func(t *testing.T) {
619 Epsilon = origEpsilon
620 p := MustParseSVGPath(tt.p)
621 ps := p.SplitAt(tt.d...)
622 Epsilon = 1e-3
623 if len(ps) != len(tt.rs) {
624 origs := []string{}
625 for _, p := range ps {
626 origs = append(origs, p.String())
627 }
628 test.T(t, strings.Join(origs, "\n"), strings.Join(tt.rs, "\n"))
629 } else {
630 for i, p := range ps {
631 test.T(t, p, MustParseSVGPath(tt.rs[i]))
632 }
633 }
634 })
635 }
636 Epsilon = origEpsilon
637}
638
639func TestDashCanonical(t *testing.T) {
640 var tts = []struct {

Callers

nothing calls this directly

Calls 6

MustParseSVGPathFunction · 0.85
TMethod · 0.80
JoinMethod · 0.65
RunMethod · 0.45
SplitAtMethod · 0.45
StringMethod · 0.45

Tested by

no test coverage detected