go-chart/concat_series_test.go

43 lines
801 B
Go
Raw Normal View History

package chart
import (
"testing"
assert "github.com/blendlabs/go-assert"
2017-04-30 03:39:38 -04:00
"github.com/wcharczuk/go-chart/sequence"
)
func TestConcatSeries(t *testing.T) {
assert := assert.New(t)
s1 := ContinuousSeries{
2017-04-30 03:39:38 -04:00
XValues: sequence.Values(1.0, 10.0),
YValues: sequence.Values(1.0, 10.0),
}
s2 := ContinuousSeries{
2017-04-30 03:39:38 -04:00
XValues: sequence.Values(11, 20.0),
YValues: sequence.Values(10.0, 1.0),
}
s3 := ContinuousSeries{
2017-04-30 03:39:38 -04:00
XValues: sequence.Values(21, 30.0),
YValues: sequence.Values(1.0, 10.0),
}
cs := ConcatSeries([]Series{s1, s2, s3})
assert.Equal(30, cs.Len())
x0, y0 := cs.GetValue(0)
assert.Equal(1.0, x0)
assert.Equal(1.0, y0)
xm, ym := cs.GetValue(19)
assert.Equal(20.0, xm)
assert.Equal(1.0, ym)
xn, yn := cs.GetValue(29)
assert.Equal(30.0, xn)
assert.Equal(10.0, yn)
}