diff --git a/decorators_test.go b/decorators_test.go index 19764c1..36f8efe 100644 --- a/decorators_test.go +++ b/decorators_test.go @@ -66,7 +66,7 @@ p.Stop() - want := "100 %" + want := "]100 %" if !strings.Contains(buf.String(), want) { t.Errorf("%q not found in bar\n", want) } @@ -77,7 +77,7 @@ p := mpb.New().SetOut(&buf) bar := p.AddBar(100).TrimLeftSpace().TrimRightSpace(). - PrependPercentage(0, 0) + PrependPercentage(6, 0) for i := 0; i < 100; i++ { time.Sleep(10 * time.Millisecond) @@ -86,8 +86,28 @@ p.Stop() - want := "100 %" + want := " 100 %[" if !strings.Contains(buf.String(), want) { t.Errorf("%q not found in bar\n", want) } } + +func TestPrependPercentageDindentRight(t *testing.T) { + var buf bytes.Buffer + p := mpb.New().SetOut(&buf) + + bar := p.AddBar(100).TrimLeftSpace().TrimRightSpace(). + PrependPercentage(6, mpb.DidentRight) + + for i := 0; i < 100; i++ { + time.Sleep(10 * time.Millisecond) + bar.Incr(1) + } + + p.Stop() + + want := "100 % [" + if !strings.Contains(buf.String(), want) { + t.Errorf("%q not found in bar\n", want) + } +}