exp. last value and test.

This commit is contained in:
Will Charczuk 2016-07-16 13:25:21 -07:00
parent 8bd5cdfe17
commit 2adc3c7fdd
2 changed files with 11 additions and 1 deletions

View file

@ -78,7 +78,13 @@ func (mas ExponentialMovingAverageSeries) GetLastValue() (x float64, y float64)
return
}
return 0.0, 0.0 //this one is going to be a bitch.
seriesLength := mas.InnerSeries.Len()
for index := 0; index < seriesLength; index++ {
x, _ = mas.GetValue(index)
}
y = mas.valueBuffer[seriesLength-1]
return
}
// Render renders the series.

View file

@ -28,4 +28,8 @@ func TestExponentialMovingAverageSeries(t *testing.T) {
assert.Equal(10.0, yvalues[0])
assert.True(math.Abs(yvalues[9]-3.77) < 0.01)
lvx, lvy := mas.GetLastValue()
assert.Equal(10.0, lvx)
assert.True(math.Abs(lvy-3.77) < 0.01)
}