Skip to content

Commit

Permalink
Clean up gob tests and move into plot/gob
Browse files Browse the repository at this point in the history
It was getting in the way of other tests in plot and it is really a gob
test, not a plot test.
  • Loading branch information
kortschak committed Mar 16, 2015
1 parent 14d0ba1 commit a47d458
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions plot_test.go → gob/gob_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
package plot_test
// Copyright ©2015 The gonum Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package gob_test

import (
"bytes"
Expand All @@ -8,25 +12,16 @@ import (
"os"
"testing"

"github.com/gonum/plot"
_ "github.com/gonum/plot/gob"

"github.com/gonum/plot"
"github.com/gonum/plot/plotter"
"github.com/gonum/plot/vg"
"github.com/gonum/plot/vg/draw"
)

// randomPoints returns some random x, y points.
func randomPoints(n int) plotter.XYs {
pts := make(plotter.XYs, n)
for i := range pts {
if i == 0 {
pts[i].X = rand.Float64()
} else {
pts[i].X = pts[i-1].X + rand.Float64()
}
pts[i].Y = pts[i].X + rand.Float64()*1e4
}
return pts
func init() {
gob.Register(commaTicks{})
}

func TestPersistency(t *testing.T) {
Expand Down Expand Up @@ -115,6 +110,20 @@ func TestPersistency(t *testing.T) {

}

// randomPoints returns some random x, y points.
func randomPoints(n int) plotter.XYs {
pts := make(plotter.XYs, n)
for i := range pts {
if i == 0 {
pts[i].X = rand.Float64()
} else {
pts[i].X = pts[i-1].X + rand.Float64()
}
pts[i].Y = pts[i].X + rand.Float64()*1e4
}
return pts
}

// CommaTicks computes the default tick marks, but inserts commas
// into the labels for the major tick marks.
type commaTicks struct{}
Expand Down Expand Up @@ -149,7 +158,3 @@ func addCommas(s string) string {
}
return s
}

func init() {
gob.Register(commaTicks{})
}

0 comments on commit a47d458

Please sign in to comment.