fixing tests
This commit is contained in:
parent
70e6cfddc5
commit
7c3982fe3d
|
@ -242,7 +242,7 @@ func TestBarChartGetAxesTicks(t *testing.T) {
|
|||
|
||||
bc.YAxis.Style.Show = true
|
||||
ticks = bc.getAxesTicks(r, yr, yf)
|
||||
assert.Len(ticks, 2)
|
||||
assert.Len(2, ticks)
|
||||
}
|
||||
|
||||
func TestBarChartCalculateEffectiveBarSpacing(t *testing.T) {
|
||||
|
|
|
@ -17,7 +17,7 @@ func TestGenerateGridLines(t *testing.T) {
|
|||
}
|
||||
|
||||
gl := GenerateGridLines(ticks, Style{}, Style{})
|
||||
assert.Len(gl, 2)
|
||||
assert.Len(2, gl)
|
||||
|
||||
assert.Equal(2.0, gl[0].Value)
|
||||
assert.Equal(3.0, gl[1].Value)
|
||||
|
|
|
@ -67,7 +67,7 @@ func TestMarketHoursRangeGetTicks(t *testing.T) {
|
|||
|
||||
ticks := ra.GetTicks(r, defaults, TimeValueFormatter)
|
||||
assert.NotEmpty(ticks)
|
||||
assert.Len(ticks, 5)
|
||||
assert.Len(5, ticks)
|
||||
assert.NotEqual(util.Time.ToFloat64(ra.Min), ticks[0].Value)
|
||||
assert.NotEmpty(ticks[0].Label)
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ func TestPoly(t *testing.T) {
|
|||
|
||||
c, err := Poly(xGiven, yGiven, degree)
|
||||
assert.Nil(err)
|
||||
assert.Len(c, 3)
|
||||
assert.Len(3, c)
|
||||
|
||||
assert.InDelta(c[0], 0.999999999, DefaultEpsilon)
|
||||
assert.InDelta(c[1], 2, DefaultEpsilon)
|
||||
|
|
|
@ -132,7 +132,7 @@ func TestBufferArray(t *testing.T) {
|
|||
buffer.Enqueue(5)
|
||||
|
||||
contents := buffer.Array()
|
||||
assert.Len(contents, 5)
|
||||
assert.Len(5, contents)
|
||||
assert.Equal(1, contents[0])
|
||||
assert.Equal(2, contents[1])
|
||||
assert.Equal(3, contents[2])
|
||||
|
|
|
@ -10,7 +10,7 @@ func TestRange(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
|
||||
values := Range(1, 100)
|
||||
assert.Len(values, 100)
|
||||
assert.Len(100, values)
|
||||
assert.Equal(1, values[0])
|
||||
assert.Equal(100, values[99])
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ func TestRangeWithStep(t *testing.T) {
|
|||
|
||||
values := RangeWithStep(0, 100, 5)
|
||||
assert.Equal(100, values[20])
|
||||
assert.Len(values, 21)
|
||||
assert.Len(21, values)
|
||||
}
|
||||
|
||||
func TestRangeReversed(t *testing.T) {
|
||||
|
@ -42,7 +42,7 @@ func TestValuesRegression(t *testing.T) {
|
|||
assert.Equal(100, linearProvider.Len())
|
||||
|
||||
values := Seq{Provider: linearProvider}.Array()
|
||||
assert.Len(values, 100)
|
||||
assert.Len(100, values)
|
||||
assert.Equal(1.0, values[0])
|
||||
assert.Equal(100, values[99])
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ func RandomValues(count int) []float64 {
|
|||
return Seq{NewRandom().WithLen(count)}.Array()
|
||||
}
|
||||
|
||||
// RandomValuesWithAverage returns an array of random values with a given average.
|
||||
// RandomValuesWithMax returns an array of random values with a given average.
|
||||
func RandomValuesWithMax(count int, max float64) []float64 {
|
||||
return Seq{NewRandom().WithMax(max).WithLen(count)}.Array()
|
||||
}
|
||||
|
|
|
@ -15,6 +15,6 @@ func TestRandomRegression(t *testing.T) {
|
|||
|
||||
randomSequence := New(randomProvider)
|
||||
randomValues := randomSequence.Array()
|
||||
assert.Len(randomValues, 4096)
|
||||
assert.Len(4096, randomValues)
|
||||
assert.InDelta(128, randomSequence.Average(), 10.0)
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ func TestSequenceNormalize(t *testing.T) {
|
|||
normalized := Values(1, 2, 3, 4, 5).Normalize().Array()
|
||||
|
||||
assert.NotEmpty(normalized)
|
||||
assert.Len(normalized, 5)
|
||||
assert.Len(5, normalized)
|
||||
assert.Equal(0, normalized[0])
|
||||
assert.Equal(0.25, normalized[1])
|
||||
assert.Equal(1, normalized[4])
|
||||
|
|
|
@ -13,7 +13,7 @@ func TestTimeMarketHours(t *testing.T) {
|
|||
|
||||
today := time.Date(2016, 07, 01, 12, 0, 0, 0, util.Date.Eastern())
|
||||
mh := Time.MarketHours(today, today, util.NYSEOpen(), util.NYSEClose(), util.Date.IsNYSEHoliday)
|
||||
assert.Len(mh, 8)
|
||||
assert.Len(8, mh)
|
||||
assert.Equal(util.Date.Eastern(), mh[0].Location())
|
||||
}
|
||||
|
||||
|
@ -21,7 +21,7 @@ func TestTimeMarketHourQuarters(t *testing.T) {
|
|||
assert := assert.New(t)
|
||||
today := time.Date(2016, 07, 01, 12, 0, 0, 0, util.Date.Eastern())
|
||||
mh := Time.MarketHourQuarters(today, today, util.NYSEOpen(), util.NYSEClose(), util.Date.IsNYSEHoliday)
|
||||
assert.Len(mh, 4)
|
||||
assert.Len(4, mh)
|
||||
assert.Equal(9, mh[0].Hour())
|
||||
assert.Equal(30, mh[0].Minute())
|
||||
assert.Equal(util.Date.Eastern(), mh[0].Location())
|
||||
|
@ -42,7 +42,7 @@ func TestTimeHours(t *testing.T) {
|
|||
seq := Time.Hours(today, 24)
|
||||
|
||||
end := Time.End(seq)
|
||||
assert.Len(seq, 24)
|
||||
assert.Len(24, seq)
|
||||
assert.Equal(2016, end.Year())
|
||||
assert.Equal(07, int(end.Month()))
|
||||
assert.Equal(02, end.Day())
|
||||
|
@ -73,7 +73,8 @@ func TestSequenceHoursFill(t *testing.T) {
|
|||
}
|
||||
|
||||
filledTimes, filledValues := Time.HoursFilled(xdata, ydata)
|
||||
assert.Len(filledTimes, util.Date.DiffHours(Time.Start(xdata), Time.End(xdata))+1)
|
||||
expected := util.Date.DiffHours(Time.Start(xdata), Time.End(xdata)) + 1
|
||||
assert.Len(expected, filledTimes)
|
||||
assert.Equal(len(filledValues), len(filledTimes))
|
||||
|
||||
assert.NotZero(filledValues[0])
|
||||
|
|
10
text_test.go
10
text_test.go
|
@ -18,7 +18,7 @@ func TestTextWrapWord(t *testing.T) {
|
|||
|
||||
output := Text.WrapFitWord(r, "this is a test string", 100, basicTextStyle)
|
||||
assert.NotEmpty(output)
|
||||
assert.Len(output, 3)
|
||||
assert.Len(3, output)
|
||||
|
||||
for _, line := range output {
|
||||
basicTextStyle.WriteToRenderer(r)
|
||||
|
@ -30,16 +30,16 @@ func TestTextWrapWord(t *testing.T) {
|
|||
assert.Equal("string", output[2])
|
||||
|
||||
output = Text.WrapFitWord(r, "foo", 100, basicTextStyle)
|
||||
assert.Len(output, 1)
|
||||
assert.Len(1, output)
|
||||
assert.Equal("foo", output[0])
|
||||
|
||||
// test that it handles newlines.
|
||||
output = Text.WrapFitWord(r, "this\nis\na\ntest\nstring", 100, basicTextStyle)
|
||||
assert.Len(output, 5)
|
||||
assert.Len(5, output)
|
||||
|
||||
// test that it handles newlines and long lines.
|
||||
output = Text.WrapFitWord(r, "this\nis\na\ntest\nstring that is very long", 100, basicTextStyle)
|
||||
assert.Len(output, 8)
|
||||
assert.Len(8, output)
|
||||
}
|
||||
|
||||
func TestTextWrapRune(t *testing.T) {
|
||||
|
@ -54,7 +54,7 @@ func TestTextWrapRune(t *testing.T) {
|
|||
|
||||
output := Text.WrapFitRune(r, "this is a test string", 150, basicTextStyle)
|
||||
assert.NotEmpty(output)
|
||||
assert.Len(output, 2)
|
||||
assert.Len(2, output)
|
||||
assert.Equal("this is a t", output[0])
|
||||
assert.Equal("est string", output[1])
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func TestGenerateContinuousTicks(t *testing.T) {
|
|||
|
||||
ticks := GenerateContinuousTicks(r, ra, false, Style{}, vf)
|
||||
assert.NotEmpty(ticks)
|
||||
assert.Len(ticks, 11)
|
||||
assert.Len(11, ticks)
|
||||
assert.Equal(0.0, ticks[0].Value)
|
||||
assert.Equal(10, ticks[len(ticks)-1].Value)
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ func TestGenerateContinuousTicksDescending(t *testing.T) {
|
|||
|
||||
ticks := GenerateContinuousTicks(r, ra, false, Style{}, vf)
|
||||
assert.NotEmpty(ticks)
|
||||
assert.Len(ticks, 11)
|
||||
assert.Len(11, ticks)
|
||||
assert.Equal(10.0, ticks[0].Value)
|
||||
assert.Equal(9.0, ticks[1].Value)
|
||||
assert.Equal(1.0, ticks[len(ticks)-2].Value)
|
||||
|
|
|
@ -99,7 +99,7 @@ func TestNormalize(t *testing.T) {
|
|||
|
||||
values := []float64{10, 9, 8, 7, 6}
|
||||
normalized := Math.Normalize(values...)
|
||||
assert.Len(normalized, 5)
|
||||
assert.Len(5, normalized)
|
||||
assert.Equal(0.25, normalized[0])
|
||||
assert.Equal(0.1499, normalized[4])
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ func TestValuesValues(t *testing.T) {
|
|||
}
|
||||
|
||||
values := Values(vs).Values()
|
||||
assert.Len(values, 7)
|
||||
assert.Len(7, values)
|
||||
assert.Equal(10, values[0])
|
||||
assert.Equal(9, values[1])
|
||||
assert.Equal(8, values[2])
|
||||
|
@ -44,7 +44,7 @@ func TestValuesValuesNormalized(t *testing.T) {
|
|||
}
|
||||
|
||||
values := Values(vs).ValuesNormalized()
|
||||
assert.Len(values, 7)
|
||||
assert.Len(7, values)
|
||||
assert.Equal(0.2127, values[0])
|
||||
assert.Equal(0.0425, values[6])
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ func TestValuesNormalize(t *testing.T) {
|
|||
}
|
||||
|
||||
values := Values(vs).Normalize()
|
||||
assert.Len(values, 7)
|
||||
assert.Len(7, values)
|
||||
assert.Equal(0.2127, values[0].Value)
|
||||
assert.Equal(0.0425, values[6].Value)
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ func TestXAxisGetTicks(t *testing.T) {
|
|||
}
|
||||
vf := FloatValueFormatter
|
||||
ticks := xa.GetTicks(r, xr, styleDefaults, vf)
|
||||
assert.Len(ticks, 16)
|
||||
assert.Len(16, ticks)
|
||||
}
|
||||
|
||||
func TestXAxisGetTicksWithUserDefaults(t *testing.T) {
|
||||
|
@ -45,7 +45,7 @@ func TestXAxisGetTicksWithUserDefaults(t *testing.T) {
|
|||
}
|
||||
vf := FloatValueFormatter
|
||||
ticks := xa.GetTicks(r, xr, styleDefaults, vf)
|
||||
assert.Len(ticks, 1)
|
||||
assert.Len(1, ticks)
|
||||
}
|
||||
|
||||
func TestXAxisMeasure(t *testing.T) {
|
||||
|
|
|
@ -23,7 +23,7 @@ func TestYAxisGetTicks(t *testing.T) {
|
|||
}
|
||||
vf := FloatValueFormatter
|
||||
ticks := ya.GetTicks(r, yr, styleDefaults, vf)
|
||||
assert.Len(ticks, 32)
|
||||
assert.Len(32, ticks)
|
||||
}
|
||||
|
||||
func TestYAxisGetTicksWithUserDefaults(t *testing.T) {
|
||||
|
@ -45,7 +45,7 @@ func TestYAxisGetTicksWithUserDefaults(t *testing.T) {
|
|||
}
|
||||
vf := FloatValueFormatter
|
||||
ticks := ya.GetTicks(r, yr, styleDefaults, vf)
|
||||
assert.Len(ticks, 1)
|
||||
assert.Len(1, ticks)
|
||||
}
|
||||
|
||||
func TestYAxisMeasure(t *testing.T) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user