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) {
|
2020-11-22 19:45:10 -05:00
|
|
|
// 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++ {
|
2017-05-12 20:12:23 -04:00
|
|
|
csx, csy := cs.GetValues(0)
|
|
|
|
hsx, hsy1, hsy2 := hs.GetBoundedValues(0)
|
2020-11-22 19:45:10 -05:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|