Codebase list golang-github-vbauerster-mpb / 862e772
TestPrependPercentageDindentRight Vladimir Bauer 9 years ago
1 changed file(s) with 23 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
6565
6666 p.Stop()
6767
68 want := "100 %"
68 want := "]100 %"
6969 if !strings.Contains(buf.String(), want) {
7070 t.Errorf("%q not found in bar\n", want)
7171 }
7676 p := mpb.New().SetOut(&buf)
7777
7878 bar := p.AddBar(100).TrimLeftSpace().TrimRightSpace().
79 PrependPercentage(0, 0)
79 PrependPercentage(6, 0)
8080
8181 for i := 0; i < 100; i++ {
8282 time.Sleep(10 * time.Millisecond)
8585
8686 p.Stop()
8787
88 want := "100 %"
88 want := " 100 %["
8989 if !strings.Contains(buf.String(), want) {
9090 t.Errorf("%q not found in bar\n", want)
9191 }
9292 }
93
94 func TestPrependPercentageDindentRight(t *testing.T) {
95 var buf bytes.Buffer
96 p := mpb.New().SetOut(&buf)
97
98 bar := p.AddBar(100).TrimLeftSpace().TrimRightSpace().
99 PrependPercentage(6, mpb.DidentRight)
100
101 for i := 0; i < 100; i++ {
102 time.Sleep(10 * time.Millisecond)
103 bar.Incr(1)
104 }
105
106 p.Stop()
107
108 want := "100 % ["
109 if !strings.Contains(buf.String(), want) {
110 t.Errorf("%q not found in bar\n", want)
111 }
112 }