test update
Vladimir Bauer
9 years ago
| 0 | 0 | package mpb |
| 1 | 1 | |
| 2 | import "testing" | |
| 2 | import ( | |
| 3 | "bytes" | |
| 4 | "testing" | |
| 5 | ) | |
| 3 | 6 | |
| 4 | 7 | func TestAddBar(t *testing.T) { |
| 5 | p := New().SetWidth(60) | |
| 8 | var buf bytes.Buffer | |
| 9 | p := New().SetWidth(60).SetOut(&buf) | |
| 6 | 10 | count := p.BarsCount() |
| 7 | 11 | if count != 0 { |
| 8 | 12 | t.Errorf("Count want: %q, got: %q\n", 0, count) |
| 9 | 13 | } |
| 10 | p.Wg.Add(1) | |
| 11 | 14 | bar := p.AddBar(10) |
| 12 | 15 | count = p.BarsCount() |
| 13 | 16 | if count != 1 { |
| 16 | 19 | for i := 0; i < 10; i++ { |
| 17 | 20 | bar.Incr(1) |
| 18 | 21 | } |
| 19 | p.WaitAndStop() | |
| 22 | p.Stop() | |
| 20 | 23 | } |
| 21 | 24 | |
| 22 | 25 | func TestRemoveBar(t *testing.T) { |
| 23 | 26 | p := New() |
| 24 | p.Wg.Add(1) | |
| 25 | 27 | b := p.AddBar(10) |
| 26 | 28 | |
| 27 | 29 | if !p.RemoveBar(b) { |
| 32 | 34 | if count != 0 { |
| 33 | 35 | t.Errorf("Count want: %q, got: %q\n", 0, count) |
| 34 | 36 | } |
| 35 | p.WaitAndStop() | |
| 37 | p.Stop() | |
| 36 | 38 | } |