coverage goal is 70% by the end of the night.

This commit is contained in:
Will Charczuk 2016-08-05 20:44:40 -07:00
parent 95d0bcca4b
commit 54f3bd4d3a
4 changed files with 77 additions and 1 deletions

View file

@ -142,3 +142,33 @@ func TestBarChartHasAxes(t *testing.T) {
assert.True(bc.hasAxes())
}
func TestBarChartGetDefaultCanvasBox(t *testing.T) {
assert := assert.New(t)
bc := BarChart{}
b := bc.getDefaultCanvasBox()
assert.False(b.IsZero())
}
func TestBarChartSetRangeDomains(t *testing.T) {
assert := assert.New(t)
bc := BarChart{}
cb := bc.box()
yr := bc.getRanges()
yr2 := bc.setRangeDomains(cb, yr)
assert.NotZero(yr2.GetDomain())
}
func TestBarChartGetValueFormatters(t *testing.T) {
assert := assert.New(t)
bc := BarChart{}
vf := bc.getValueFormatters()
assert.NotNil(vf)
assert.Equal("1234.00", vf(1234.0))
bc.YAxis.ValueFormatter = func(_ interface{}) string { return "test" }
assert.Equal("test", bc.getValueFormatters()(1234))
}

View file

@ -126,3 +126,20 @@ func TestBoxOuterConstrain(t *testing.T) {
assert.Equal(85, d.Right, d.String())
assert.Equal(95, d.Bottom, d.String())
}
func TestBoxShift(t *testing.T) {
assert := assert.New(t)
b := Box{
Top: 5,
Left: 5,
Right: 10,
Bottom: 10,
}
shifted := b.Shift(1, 2)
assert.Equal(7, shifted.Top)
assert.Equal(6, shifted.Left)
assert.Equal(11, shifted.Right)
assert.Equal(12, shifted.Bottom)
}

View file

@ -56,5 +56,14 @@ func FloatValueFormatterWithFormat(v interface{}, floatFormat string) string {
if typed, isTyped := v.(float64); isTyped {
return fmt.Sprintf(floatFormat, typed)
}
if typed, isTyped := v.(float32); isTyped {
return fmt.Sprintf(floatFormat, typed)
}
if typed, isTyped := v.(int); isTyped {
return fmt.Sprintf(floatFormat, float64(typed))
}
if typed, isTyped := v.(int64); isTyped {
return fmt.Sprintf(floatFormat, float64(typed))
}
return ""
}

View file

@ -28,11 +28,31 @@ func TestTimeValueFormatterWithFormat(t *testing.T) {
assert.Equal(s, sdf)
}
func TestFloatValueFormatter(t *testing.T) {
assert := assert.New(t)
assert.Equal("1234.00", FloatValueFormatter(1234.00))
}
func TestFloatValueFormatterWithFloat32Input(t *testing.T) {
assert := assert.New(t)
assert.Equal("1234.00", FloatValueFormatter(float32(1234.00)))
}
func TestFloatValueFormatterWithIntegerInput(t *testing.T) {
assert := assert.New(t)
assert.Equal("1234.00", FloatValueFormatter(1234))
}
func TestFloatValueFormatterWithInt64Input(t *testing.T) {
assert := assert.New(t)
assert.Equal("1234.00", FloatValueFormatter(int64(1234)))
}
func TestFloatValueFormatterWithFormat(t *testing.T) {
assert := assert.New(t)
v := 123.456
sv := FloatValueFormatterWithFormat(v, "%.3f")
assert.Equal("123.456", sv)
assert.Equal("", FloatValueFormatterWithFormat(123, "%.3f"))
assert.Equal("123.000", FloatValueFormatterWithFormat(123, "%.3f"))
}