| 1 |
package chart |
| 2 |
|
| 3 |
import ( |
| 4 |
"testing" |
| 5 |
|
| 6 |
"github.com/wcharczuk/go-chart/v2/testutil" |
| 7 |
) |
| 8 |
|
| 9 |
func TestHistogramSeries(t *testing.T) { |
| 10 |
|
| 11 |
|
| 12 |
cs := ContinuousSeries{ |
| 13 |
Name: "Test Series", |
| 14 |
XValues: LinearRange(1.0, 20.0), |
| 15 |
YValues: LinearRange(10.0, -10.0), |
| 16 |
} |
| 17 |
|
| 18 |
hs := HistogramSeries{ |
| 19 |
InnerSeries: cs, |
| 20 |
} |
| 21 |
|
| 22 |
for x := 0; x < hs.Len(); x++ { |
| 23 |
csx, csy := cs.GetValues(0) |
| 24 |
hsx, hsy1, hsy2 := hs.GetBoundedValues(0) |
| 25 |
testutil.AssertEqual(t, csx, hsx) |
| 26 |
testutil.AssertTrue(t, hsy1 > 0) |
| 27 |
testutil.AssertTrue(t, hsy2 <= 0) |
| 28 |
testutil.AssertTrue(t, csy < 0 || (csy > 0 && csy == hsy1)) |
| 29 |
testutil.AssertTrue(t, csy > 0 || (csy < 0 && csy == hsy2)) |
| 30 |
} |
| 31 |
} |