diff --git a/bar_filler_bar.go b/bar_filler_bar.go index 3860d2f..fd6ef0f 100644 --- a/bar_filler_bar.go +++ b/bar_filler_bar.go @@ -233,7 +233,7 @@ var tip component var refilling, filling, padding []byte var fillCount int - curWidth := int(internal.PercentageRound(stat.Total, stat.Current, int64(width))) + curWidth := int(internal.PercentageRound(stat.Total, stat.Current, uint(width))) if curWidth != 0 { if !stat.Completed || s.tipOnComplete { @@ -243,7 +243,7 @@ } switch refWidth := 0; { case stat.Refill != 0: - refWidth = int(internal.PercentageRound(stat.Total, stat.Refill, int64(width))) + refWidth = int(internal.PercentageRound(stat.Total, stat.Refill, uint(width))) curWidth -= refWidth refWidth += curWidth fallthrough diff --git a/internal/percentage.go b/internal/percentage.go index 988227d..e25cf99 100644 --- a/internal/percentage.go +++ b/internal/percentage.go @@ -14,9 +14,9 @@ } // PercentageRound same as Percentage but with math.Round. -func PercentageRound(total, current, width int64) float64 { - if total < 0 || current < 0 || width < 0 { +func PercentageRound(total, current int64, width uint) float64 { + if total < 0 || current < 0 { return 0 } - return math.Round(Percentage(uint(total), uint(current), uint(width))) + return math.Round(Percentage(uint(total), uint(current), width)) } diff --git a/internal/percentage_test.go b/internal/percentage_test.go index b0e2838..515ad60 100644 --- a/internal/percentage_test.go +++ b/internal/percentage_test.go @@ -4,7 +4,7 @@ func TestPercentage(t *testing.T) { // key is barWidth - testSuite := map[int64][]struct { + testSuite := map[uint][]struct { name string total int64 current int64