updates
This commit is contained in:
parent
c47025edf6
commit
41d81c82db
4 changed files with 30 additions and 6 deletions
|
@ -505,8 +505,8 @@ func TestChartE2ELine(t *testing.T) {
|
||||||
},
|
},
|
||||||
Series: []Series{
|
Series: []Series{
|
||||||
ContinuousSeries{
|
ContinuousSeries{
|
||||||
XValues: sequence.Values(0, 4, 1),
|
XValues: sequence.ValuesWithStep(0, 4, 1),
|
||||||
YValues: sequence.Values(0, 4, 1),
|
YValues: sequence.ValuesWithStep(0, 4, 1),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -550,8 +550,8 @@ func TestChartE2ELineWithFill(t *testing.T) {
|
||||||
StrokeColor: drawing.ColorBlue,
|
StrokeColor: drawing.ColorBlue,
|
||||||
FillColor: drawing.ColorRed,
|
FillColor: drawing.ColorRed,
|
||||||
},
|
},
|
||||||
XValues: sequence.Values(0, 4, 1),
|
XValues: sequence.ValuesWithStep(0, 4, 1),
|
||||||
YValues: sequence.Values(0, 4, 1),
|
YValues: sequence.ValuesWithStep(0, 4, 1),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,7 +24,7 @@ type Linear struct {
|
||||||
|
|
||||||
// Len returns the number of elements in the sequence.
|
// Len returns the number of elements in the sequence.
|
||||||
func (lg Linear) Len() int {
|
func (lg Linear) Len() int {
|
||||||
return int((lg.limit - lg.offset) / lg.step)
|
return (int((lg.limit - lg.offset) / lg.step)) + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetValue returns the value at a given index.
|
// GetValue returns the value at a given index.
|
||||||
|
|
24
sequence/linear_test.go
Normal file
24
sequence/linear_test.go
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
package sequence
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
assert "github.com/blendlabs/go-assert"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestValues(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
values := Values(1, 100)
|
||||||
|
assert.Len(values, 100)
|
||||||
|
assert.Equal(1, values[0])
|
||||||
|
assert.Equal(100, values[99])
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestValueWithStep(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
values := ValuesWithStep(0, 100, 5)
|
||||||
|
assert.Equal(100, values[20])
|
||||||
|
assert.Len(values, 21)
|
||||||
|
}
|
|
@ -21,7 +21,7 @@ func (m mockValuesProvider) GetValues(index int) (x, y float64) {
|
||||||
if index < 0 {
|
if index < 0 {
|
||||||
panic("negative index at GetValue()")
|
panic("negative index at GetValue()")
|
||||||
}
|
}
|
||||||
if index > util.Math.MinInt(len(m.X), len(m.Y)) {
|
if index >= util.Math.MinInt(len(m.X), len(m.Y)) {
|
||||||
panic("index is outside the length of m.X or m.Y")
|
panic("index is outside the length of m.X or m.Y")
|
||||||
}
|
}
|
||||||
x = m.X[index]
|
x = m.X[index]
|
||||||
|
|
Loading…
Reference in a new issue