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) {
|
2020-11-22 19:45:10 -05:00
|
|
|
// 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,
|
|
|
|
}
|
|
|
|
|
2020-11-22 19:45:10 -05:00
|
|
|
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)
|
2020-11-22 19:45:10 -05:00
|
|
|
testutil.AssertEqual(t, 1.0, x0)
|
|
|
|
testutil.AssertEqual(t, 0, y0)
|
2019-09-09 22:57:56 -04:00
|
|
|
|
|
|
|
xn, yn := pcs.GetValues(9)
|
2020-11-22 19:45:10 -05:00
|
|
|
testutil.AssertEqual(t, 10.0, xn)
|
|
|
|
testutil.AssertEqual(t, 9.0, yn)
|
2019-09-09 22:57:56 -04:00
|
|
|
|
|
|
|
xn, yn = pcs.GetLastValues()
|
2020-11-22 19:45:10 -05:00
|
|
|
testutil.AssertEqual(t, 10.0, xn)
|
|
|
|
testutil.AssertEqual(t, 9.0, yn)
|
2019-09-09 22:57:56 -04:00
|
|
|
}
|