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

Function TestPathSplit

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

Source from the content-addressed store, hash-verified

564}
565
566func TestPathSplit(t *testing.T) {
567 var tts = []struct {
568 p string
569 rs []string
570 }{
571 {"M5 5L6 6z", []string{"M5 5L6 6z"}},
572 {"L5 5M10 10L20 20z", []string{"L5 5", "M10 10L20 20z"}},
573 {"L5 5zL10 10", []string{"L5 5z", "L10 10"}},
574 {"M5 5L15 5zL10 10zL20 20", []string{"M5 5L15 5z", "M5 5L10 10z", "M5 5L20 20"}},
575 }
576 for _, tt := range tts {
577 t.Run(tt.p, func(t *testing.T) {
578 p := MustParseSVGPath(tt.p)
579 ps := p.Split()
580 if len(ps) != len(tt.rs) {
581 origs := []string{}
582 for _, p := range ps {
583 origs = append(origs, p.String())
584 }
585 test.T(t, strings.Join(origs, "\n"), strings.Join(tt.rs, "\n"))
586 } else {
587 for i, p := range ps {
588 test.T(t, p, MustParseSVGPath(tt.rs[i]))
589 }
590 }
591 })
592 }
593
594 ps := (&Path{[]float64{MoveToCmd, 5.0, 5.0, MoveToCmd, MoveToCmd, 10.0, 10.0, MoveToCmd, CloseCmd, 10.0, 10.0, CloseCmd}}).Split()
595 test.T(t, ps[0].String(), "M5 5")
596 test.T(t, ps[1].String(), "M10 10z")
597}
598
599func TestPathSplitAt(t *testing.T) {
600 var tts = []struct {

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected