Codebase list golang-github-vbauerster-mpb / 589d00a
test update Vladimir Bauer 9 years ago
1 changed file(s) with 8 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
00 package mpb
11
2 import "testing"
2 import (
3 "bytes"
4 "testing"
5 )
36
47 func TestAddBar(t *testing.T) {
5 p := New().SetWidth(60)
8 var buf bytes.Buffer
9 p := New().SetWidth(60).SetOut(&buf)
610 count := p.BarsCount()
711 if count != 0 {
812 t.Errorf("Count want: %q, got: %q\n", 0, count)
913 }
10 p.Wg.Add(1)
1114 bar := p.AddBar(10)
1215 count = p.BarsCount()
1316 if count != 1 {
1619 for i := 0; i < 10; i++ {
1720 bar.Incr(1)
1821 }
19 p.WaitAndStop()
22 p.Stop()
2023 }
2124
2225 func TestRemoveBar(t *testing.T) {
2326 p := New()
24 p.Wg.Add(1)
2527 b := p.AddBar(10)
2628
2729 if !p.RemoveBar(b) {
3234 if count != 0 {
3335 t.Errorf("Count want: %q, got: %q\n", 0, count)
3436 }
35 p.WaitAndStop()
37 p.Stop()
3638 }