This test ensures that the plotter doesn't panic if there are polygons wholly outside of the plotting range.
(t *testing.T)
| 27 | // This test ensures that the plotter doesn't panic if there are |
| 28 | // polygons wholly outside of the plotting range. |
| 29 | func TestPolygon_clip(t *testing.T) { |
| 30 | poly, err := plotter.NewPolygon( |
| 31 | plotter.XYs{{0, 0}, {1, 0}, {1, 1}, {0, 1}, {0, 0}}, |
| 32 | ) |
| 33 | if err != nil { |
| 34 | t.Fatal(err) |
| 35 | } |
| 36 | poly.Color = color.Black // Give the polygon a color to fill. |
| 37 | p := plot.New() |
| 38 | // Set the plotting range so that the polygon is outside of it. |
| 39 | p.X.Min = 2 |
| 40 | p.X.Max = 5 |
| 41 | |
| 42 | p.Add(poly) |
| 43 | c := new(recorder.Canvas) |
| 44 | dc := draw.NewCanvas(c, vg.Centimeter, vg.Centimeter) |
| 45 | p.Draw(dc) // If this does not panic, then the test passes. |
| 46 | } |
nothing calls this directly
no test coverage detected