2016-07-21 17:11:27 -04:00
|
|
|
package chart
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
2020-11-22 19:45:10 -05:00
|
|
|
"github.com/wcharczuk/go-chart/v2/testutil"
|
2016-07-21 17:11:27 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
func TestConcatSeries(t *testing.T) {
|
2020-11-22 19:45:10 -05:00
|
|
|
// replaced new assertions helper
|
2016-07-21 17:11:27 -04:00
|
|
|
|
|
|
|
s1 := ContinuousSeries{
|
2019-02-13 21:55:13 -05:00
|
|
|
XValues: LinearRange(1.0, 10.0),
|
|
|
|
YValues: LinearRange(1.0, 10.0),
|
2016-07-21 17:11:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
s2 := ContinuousSeries{
|
2019-02-13 21:55:13 -05:00
|
|
|
XValues: LinearRange(11, 20.0),
|
|
|
|
YValues: LinearRange(10.0, 1.0),
|
2016-07-21 17:11:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
s3 := ContinuousSeries{
|
2019-02-13 21:55:13 -05:00
|
|
|
XValues: LinearRange(21, 30.0),
|
|
|
|
YValues: LinearRange(1.0, 10.0),
|
2016-07-21 17:11:27 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
cs := ConcatSeries([]Series{s1, s2, s3})
|
2020-11-22 19:45:10 -05:00
|
|
|
testutil.AssertEqual(t, 30, cs.Len())
|
2016-07-21 17:11:27 -04:00
|
|
|
|
|
|
|
x0, y0 := cs.GetValue(0)
|
2020-11-22 19:45:10 -05:00
|
|
|
testutil.AssertEqual(t, 1.0, x0)
|
|
|
|
testutil.AssertEqual(t, 1.0, y0)
|
2016-07-21 17:11:27 -04:00
|
|
|
|
|
|
|
xm, ym := cs.GetValue(19)
|
2020-11-22 19:45:10 -05:00
|
|
|
testutil.AssertEqual(t, 20.0, xm)
|
|
|
|
testutil.AssertEqual(t, 1.0, ym)
|
2016-07-21 17:11:27 -04:00
|
|
|
|
|
|
|
xn, yn := cs.GetValue(29)
|
2020-11-22 19:45:10 -05:00
|
|
|
testutil.AssertEqual(t, 30.0, xn)
|
|
|
|
testutil.AssertEqual(t, 10.0, yn)
|
2016-07-21 17:11:27 -04:00
|
|
|
}
|