tests catching bugs.

This commit is contained in:
Will Charczuk 2016-08-05 21:31:41 -07:00
parent 129cbad0fa
commit 22e4431c82

View File

@ -235,6 +235,8 @@ func TestBarChartCalculateEffectiveBarWidth(t *testing.T) {
}, },
} }
cb := bc.box()
spacing := bc.calculateEffectiveBarSpacing(bc.box()) spacing := bc.calculateEffectiveBarSpacing(bc.box())
assert.NotZero(spacing) assert.NotZero(spacing)
@ -243,8 +245,15 @@ func TestBarChartCalculateEffectiveBarWidth(t *testing.T) {
bc.BarWidth = 250 bc.BarWidth = 250
spacing = bc.calculateEffectiveBarSpacing(bc.box()) spacing = bc.calculateEffectiveBarSpacing(bc.box())
assert.Zero(spacing)
barWidth = bc.calculateEffectiveBarWidth(bc.box(), spacing) barWidth = bc.calculateEffectiveBarWidth(bc.box(), spacing)
assert.Equal(199, barWidth) assert.Equal(199, barWidth)
assert.Equal(1024, bc.calculateTotalBarWidth(barWidth, spacing)) assert.Equal(cb.Width()+1, bc.calculateTotalBarWidth(barWidth, spacing))
bw, bs, total := bc.calculateScaledTotalWidth(cb)
assert.Equal(spacing, bs)
assert.Equal(barWidth, bw)
assert.Equal(cb.Width()+1, total)
} }