2016-07-21 17:11:27 -04:00
|
|
|
package chart
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2018-04-05 03:42:38 -04:00
|
|
|
assert "github.com/blend/go-sdk/assert"
|
2016-07-21 17:11:27 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestConcatSeries(t *testing.T) {
|
|
|
|
assert := assert.New(t)
|
|
|
|
|
|
|
|
s1 := ContinuousSeries{
|
2019-02-13 19:09:26 -05:00
|
|
|
XValues: SeqRange(1.0, 10.0),
|
|
|
|
YValues: SeqRange(1.0, 10.0),
|
2016-07-21 17:11:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
s2 := ContinuousSeries{
|
2019-02-13 19:09:26 -05:00
|
|
|
XValues: SeqRange(11, 20.0),
|
|
|
|
YValues: SeqRange(10.0, 1.0),
|
2016-07-21 17:11:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
s3 := ContinuousSeries{
|
2019-02-13 19:09:26 -05:00
|
|
|
XValues: SeqRange(21, 30.0),
|
|
|
|
YValues: SeqRange(1.0, 10.0),
|
2016-07-21 17:11:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
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)
|
|
|
|
}
|