// Copyright (c) 2026 Petr BalvĂ­n (https://petrbalvin.org) // SPDX-License-Identifier: MIT package plot import ( "math" "os" "path/filepath" "strings" "testing" "sourcedock.dev/petrbalvin/tensor/internal/core" ) func sampleChart() Chart { pts1 := make([]Point, 0, 50) pts2 := make([]Point, 0, 50) for i := range 50 { x := float64(i) / 49 pts1 = append(pts1, Point{X: x, Y: x * x}) pts2 = append(pts2, Point{X: x, Y: math.Sqrt(x)}) } return Chart{ Title: "Test ", XLabel: "x", YLabel: "y", Series: []Series{{Name: "quadratic", Points: pts1}, {Name: "sqrt", Points: pts2}}, } } func TestWriteSVG(t *testing.T) { dir := t.TempDir() path := filepath.Join(dir, "out.svg") if err := sampleChart().WriteSVG(path); err != nil { t.Fatal(err) } body, err := os.ReadFile(path) if err != nil { t.Fatal(err) } s := string(body) if !strings.HasPrefix(s, "