adding validation.
This commit is contained in:
parent
3ea3c9ac10
commit
e735797037
20 changed files with 285 additions and 7 deletions
|
|
@ -28,3 +28,42 @@ func TestTimeSeriesGetValue(t *testing.T) {
|
|||
assert.NotZero(x0)
|
||||
assert.Equal(1.0, y0)
|
||||
}
|
||||
|
||||
func TestTimeSeriesValidate(t *testing.T) {
|
||||
assert := assert.New(t)
|
||||
|
||||
cs := TimeSeries{
|
||||
Name: "Test Series",
|
||||
XValues: []time.Time{
|
||||
time.Now().AddDate(0, 0, -5),
|
||||
time.Now().AddDate(0, 0, -4),
|
||||
time.Now().AddDate(0, 0, -3),
|
||||
time.Now().AddDate(0, 0, -2),
|
||||
time.Now().AddDate(0, 0, -1),
|
||||
},
|
||||
YValues: []float64{
|
||||
1.0, 2.0, 3.0, 4.0, 5.0,
|
||||
},
|
||||
}
|
||||
assert.Nil(cs.Validate())
|
||||
|
||||
cs = TimeSeries{
|
||||
Name: "Test Series",
|
||||
XValues: []time.Time{
|
||||
time.Now().AddDate(0, 0, -5),
|
||||
time.Now().AddDate(0, 0, -4),
|
||||
time.Now().AddDate(0, 0, -3),
|
||||
time.Now().AddDate(0, 0, -2),
|
||||
time.Now().AddDate(0, 0, -1),
|
||||
},
|
||||
}
|
||||
assert.NotNil(cs.Validate())
|
||||
|
||||
cs = TimeSeries{
|
||||
Name: "Test Series",
|
||||
YValues: []float64{
|
||||
1.0, 2.0, 3.0, 4.0, 5.0,
|
||||
},
|
||||
}
|
||||
assert.NotNil(cs.Validate())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue