Codebase list golang-github-vbauerster-mpb / ff76489
replace for loops with bar.IncrBy(total) Vladimir Bauer 4 years ago
1 changed file(s) with 17 addition(s) and 34 deletion(s). Raw diff Collapse all Expand all
1919 bar := p.AddBar(int64(total))
2020
2121 if bar.Completed() {
22 t.Error("bar is completed before increment")
23 }
24
25 for i := 0; i < total; i++ {
26 bar.Increment()
27 }
22 t.Fail()
23 }
24
25 bar.IncrBy(total)
2826
2927 if !bar.Completed() {
3028 t.Error("bar isn't completed after increment")
6260 t.Errorf("Expected bar id: %d, got %d\n", wantID, gotID)
6361 }
6462
65 bar.Abort(true)
63 bar.IncrBy(total)
64
6665 p.Wait()
6766 }
6867
7978
8079 bar.SetRefill(int64(till))
8180 bar.IncrBy(till)
82
83 for i := 0; i < total-till; i++ {
84 bar.Increment()
85 time.Sleep(10 * time.Millisecond)
86 }
81 bar.IncrBy(total - till)
8782
8883 p.Wait()
8984
111106 mpb.AppendDecorators(decor.Percentage()),
112107 )
113108
114 for i := 0; i < total; i++ {
115 bar.Increment()
116 time.Sleep(10 * time.Millisecond)
117 }
109 bar.IncrBy(total)
118110
119111 p.Wait()
120112
138130 bs.Rbound(string(runes[4]))
139131 bar := p.New(int64(total), bs, mpb.BarFillerTrim())
140132
141 for i := 0; i < total; i++ {
142 bar.Increment()
143 time.Sleep(10 * time.Millisecond)
144 }
133 bar.IncrBy(total)
145134
146135 p.Wait()
147136
181170 )),
182171 )
183172
184 for i := 0; i < total; i++ {
185 time.Sleep(10 * time.Millisecond)
186 bar.Increment()
187 }
173 bar.IncrBy(total)
188174
189175 p.Wait()
190176
191177 if pCount != 1 {
192 t.Errorf("Decor called after panic %d times\n", pCount-1)
178 t.Errorf("Decorator called after panic %d times, expected 1\n", pCount)
193179 }
194180
195181 barStr := buf.String()
221207 )),
222208 )
223209
224 for i := 0; i < total; i++ {
225 time.Sleep(10 * time.Millisecond)
226 bar.Increment()
227 }
228
229 p.Wait()
230
231 if pCount > 2 {
232 t.Error("Decor called after panic more than 2 times\n")
210 bar.IncrBy(total)
211
212 p.Wait()
213
214 if pCount != 1 {
215 t.Errorf("Decorator called after panic %d times, expected 1\n", pCount)
233216 }
234217
235218 barStr := buf.String()