MCPcopy Index your code
hub / github.com/gonum/plot / TestCrop

Function TestCrop

vg/draw/draw_test.go:24–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22)
23
24func TestCrop(t *testing.T) {
25 ls := draw.LineStyle{
26 Color: color.NRGBA{0, 20, 0, 123},
27 Width: 0.1 * vg.Inch,
28 }
29 var r1 recorder.Canvas
30 c1 := draw.NewCanvas(&r1, 6, 3)
31 c11 := draw.Crop(c1, 0, -3, 0, 0)
32 c12 := draw.Crop(c1, 3, 0, 0, 0)
33
34 var r2 recorder.Canvas
35 c2 := draw.NewCanvas(&r2, 6, 3)
36 c21 := draw.Canvas{
37 Canvas: c2.Canvas,
38 Rectangle: vg.Rectangle{
39 Min: vg.Point{X: 0, Y: 0},
40 Max: vg.Point{X: 3, Y: 3},
41 },
42 }
43 c22 := draw.Canvas{
44 Canvas: c2.Canvas,
45 Rectangle: vg.Rectangle{
46 Min: vg.Point{X: 3, Y: 0},
47 Max: vg.Point{X: 6, Y: 3},
48 },
49 }
50 str := "unexpected result: %+v != %+v"
51 if c11.Rectangle != c21.Rectangle {
52 t.Errorf(str, c11.Rectangle, c21.Rectangle)
53 }
54 if c12.Rectangle != c22.Rectangle {
55 t.Errorf(str, c11.Rectangle, c21.Rectangle)
56 }
57
58 c11.StrokeLine2(ls, c11.Min.X, c11.Min.Y,
59 c11.Min.X+3*vg.Inch, c11.Min.Y+3*vg.Inch)
60 c12.StrokeLine2(ls, c12.Min.X, c12.Min.Y,
61 c12.Min.X+3*vg.Inch, c12.Min.Y+3*vg.Inch)
62 c21.StrokeLine2(ls, c21.Min.X, c21.Min.Y,
63 c21.Min.X+3*vg.Inch, c21.Min.Y+3*vg.Inch)
64 c22.StrokeLine2(ls, c22.Min.X, c22.Min.Y,
65 c22.Min.X+3*vg.Inch, c22.Min.Y+3*vg.Inch)
66
67 if !reflect.DeepEqual(r1.Actions, r2.Actions) {
68 t.Errorf(str, r1.Actions, r2.Actions)
69 }
70}
71
72func TestTile(t *testing.T) {
73 var r recorder.Canvas

Callers

nothing calls this directly

Calls 3

StrokeLine2Method · 0.95
NewCanvasFunction · 0.92
CropFunction · 0.92

Tested by

no test coverage detected