| 19 | } |
| 20 | |
| 21 | func TestSingletonHistogram(t *testing.T) { |
| 22 | done := make(chan struct{}, 1) |
| 23 | go func() { |
| 24 | defer close(done) |
| 25 | p := plot.New() |
| 26 | hist, err := plotter.NewHist(plotter.Values([]float64{1.0}), 60) |
| 27 | if err != nil { |
| 28 | t.Errorf("unexpected error from NewHist: %v", err) |
| 29 | return |
| 30 | } |
| 31 | hist.Normalize(1) |
| 32 | |
| 33 | p.Add(hist) |
| 34 | |
| 35 | _, err = p.WriterTo(4*vg.Inch, 4*vg.Inch, "png") |
| 36 | if err != nil { |
| 37 | t.Errorf("unexpected error from WriterTo: %v", err) |
| 38 | return |
| 39 | } |
| 40 | }() |
| 41 | |
| 42 | select { |
| 43 | case <-time.After(10 * time.Second): |
| 44 | t.Error("histogram timed out") |
| 45 | case <-done: |
| 46 | } |
| 47 | } |
| 48 | func TestHistogramLogScale(t *testing.T) { |
| 49 | cmpimg.CheckPlot(ExampleHistogram_logScaleY, t, "histogram_logy.png") |
| 50 | } |