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