replace for loops with bar.IncrBy(total)
Vladimir Bauer
4 years ago
| 19 | 19 | bar := p.AddBar(int64(total)) |
| 20 | 20 | |
| 21 | 21 | 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) | |
| 28 | 26 | |
| 29 | 27 | if !bar.Completed() { |
| 30 | 28 | t.Error("bar isn't completed after increment") |
| 62 | 60 | t.Errorf("Expected bar id: %d, got %d\n", wantID, gotID) |
| 63 | 61 | } |
| 64 | 62 | |
| 65 | bar.Abort(true) | |
| 63 | bar.IncrBy(total) | |
| 64 | ||
| 66 | 65 | p.Wait() |
| 67 | 66 | } |
| 68 | 67 | |
| 79 | 78 | |
| 80 | 79 | bar.SetRefill(int64(till)) |
| 81 | 80 | 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) | |
| 87 | 82 | |
| 88 | 83 | p.Wait() |
| 89 | 84 | |
| 111 | 106 | mpb.AppendDecorators(decor.Percentage()), |
| 112 | 107 | ) |
| 113 | 108 | |
| 114 | for i := 0; i < total; i++ { | |
| 115 | bar.Increment() | |
| 116 | time.Sleep(10 * time.Millisecond) | |
| 117 | } | |
| 109 | bar.IncrBy(total) | |
| 118 | 110 | |
| 119 | 111 | p.Wait() |
| 120 | 112 | |
| 138 | 130 | bs.Rbound(string(runes[4])) |
| 139 | 131 | bar := p.New(int64(total), bs, mpb.BarFillerTrim()) |
| 140 | 132 | |
| 141 | for i := 0; i < total; i++ { | |
| 142 | bar.Increment() | |
| 143 | time.Sleep(10 * time.Millisecond) | |
| 144 | } | |
| 133 | bar.IncrBy(total) | |
| 145 | 134 | |
| 146 | 135 | p.Wait() |
| 147 | 136 | |
| 181 | 170 | )), |
| 182 | 171 | ) |
| 183 | 172 | |
| 184 | for i := 0; i < total; i++ { | |
| 185 | time.Sleep(10 * time.Millisecond) | |
| 186 | bar.Increment() | |
| 187 | } | |
| 173 | bar.IncrBy(total) | |
| 188 | 174 | |
| 189 | 175 | p.Wait() |
| 190 | 176 | |
| 191 | 177 | 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) | |
| 193 | 179 | } |
| 194 | 180 | |
| 195 | 181 | barStr := buf.String() |
| 221 | 207 | )), |
| 222 | 208 | ) |
| 223 | 209 | |
| 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) | |
| 233 | 216 | } |
| 234 | 217 | |
| 235 | 218 | barStr := buf.String() |