This commit is contained in:
Will Charczuk 2016-07-06 18:55:00 -07:00
parent 2dd44d3675
commit b6b0409dbc

View file

@ -10,11 +10,9 @@ import (
func TestRangeTranslate(t *testing.T) {
assert := assert.New(t)
values := []float64{1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0}
r := NewRange(1000, values...)
assert.Equal(1.0, r.MinValue)
assert.Equal(8.0, r.MaxValue)
assert.Equal(7.0, r.MinMaxDelta)
assert.Equal(1000, r.Domain)
r := NewRangeOfFloat64(1000, values...)
assert.Equal(1.0, r.GetMin())
assert.Equal(8.0, r.GetMax())
assert.Equal(428, r.Translate(5.0))
}
@ -31,9 +29,7 @@ func TestRangeOfTimeTranslate(t *testing.T) {
time.Now().AddDate(0, 0, -8),
}
r := NewRangeOfTime(1000, values...)
assert.Equal(values[7], r.MinValue)
assert.Equal(values[0], r.MaxValue)
assert.Equal(values[0].Unix()-values[7].Unix(), r.MinMaxDelta)
assert.Equal(1000, r.Domain)
assert.Equal(values[7], r.GetMin())
assert.Equal(values[0], r.GetMax())
assert.Equal(571, r.Translate(time.Now().AddDate(0, 0, -5)))
}