Codebase list golang-github-vbauerster-mpb / 0e75bcc
Test fixes Vladimir Bauer 8 years ago
2 changed file(s) with 1 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
3737
3838 p.Stop()
3939
40 gotWidth := len(buf.Bytes())
40 gotWidth := utf8.RuneCount(buf.Bytes())
4141 if gotWidth != tc.expected {
4242 t.Errorf("%s: Expected width: %d, got: %d\n", k, tc.expected, gotWidth)
4343 }
4444 gotWidth := utf8.RuneCount(buf.Bytes())
4545 if gotWidth != wantWidth+1 { // +1 for new line
4646 t.Errorf("Expected default width: %d, got: %d\n", wantWidth, gotWidth)
47 }
48 }
49
50 func TestInvalidWidth(t *testing.T) {
51 var buf bytes.Buffer
52 p := mpb.New(mpb.WithWidth(1), mpb.Output(&buf))
53 bar := p.AddBar(100, mpb.BarTrim())
54
55 for i := 0; i < 100; i++ {
56 bar.Incr(1)
57 }
58 p.Stop()
59
60 wantWidth := 80
61 gotWidth := utf8.RuneCount(buf.Bytes())
62 if gotWidth != wantWidth+1 { // +1 for new line
63 t.Errorf("Expected width: %d, got: %d\n", wantWidth, gotWidth)
6447 }
6548 }
6649