go-chart/histogram_series_test.go

32 lines
682 B
Go
Raw Permalink Normal View History

2016-07-28 19:36:30 -04:00
package chart
import (
"testing"
2024-10-27 22:52:38 -04:00
"git.smarteching.com/zeni/go-chart/v2/testutil"
2016-07-28 19:36:30 -04:00
)
func TestHistogramSeries(t *testing.T) {
// replaced new assertions helper
2016-07-28 19:36:30 -04:00
cs := ContinuousSeries{
Name: "Test Series",
2019-02-13 21:55:13 -05:00
XValues: LinearRange(1.0, 20.0),
YValues: LinearRange(10.0, -10.0),
2016-07-28 19:36:30 -04:00
}
hs := HistogramSeries{
InnerSeries: cs,
}
for x := 0; x < hs.Len(); x++ {
csx, csy := cs.GetValues(0)
hsx, hsy1, hsy2 := hs.GetBoundedValues(0)
testutil.AssertEqual(t, csx, hsx)
testutil.AssertTrue(t, hsy1 > 0)
testutil.AssertTrue(t, hsy2 <= 0)
testutil.AssertTrue(t, csy < 0 || (csy > 0 && csy == hsy1))
testutil.AssertTrue(t, csy > 0 || (csy < 0 && csy == hsy2))
2016-07-28 19:36:30 -04:00
}
}