go-chart/percent_change_series_test.go

36 lines
746 B
Go
Raw Permalink Normal View History

2019-09-09 22:57:56 -04:00
package chart
import (
"testing"
2024-10-27 22:52:38 -04:00
"git.smarteching.com/zeni/go-chart/v2/testutil"
2019-09-09 22:57:56 -04:00
)
func TestPercentageDifferenceSeries(t *testing.T) {
// replaced new assertions helper
2019-09-09 22:57:56 -04:00
cs := ContinuousSeries{
XValues: LinearRange(1.0, 10.0),
YValues: LinearRange(1.0, 10.0),
}
pcs := PercentChangeSeries{
Name: "Test Series",
InnerSeries: cs,
}
testutil.AssertEqual(t, "Test Series", pcs.GetName())
testutil.AssertEqual(t, 10, pcs.Len())
2019-09-09 22:57:56 -04:00
x0, y0 := pcs.GetValues(0)
testutil.AssertEqual(t, 1.0, x0)
testutil.AssertEqual(t, 0, y0)
2019-09-09 22:57:56 -04:00
xn, yn := pcs.GetValues(9)
testutil.AssertEqual(t, 10.0, xn)
testutil.AssertEqual(t, 9.0, yn)
2019-09-09 22:57:56 -04:00
xn, yn = pcs.GetLastValues()
testutil.AssertEqual(t, 10.0, xn)
testutil.AssertEqual(t, 9.0, yn)
2019-09-09 22:57:56 -04:00
}