Codebase list golang-github-vbauerster-mpb / 858658a
fix tests Vladimir Bauer 6 years ago
2 changed file(s) with 7 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
9090 func TestBarHas100PercentWithOnCompleteDecorator(t *testing.T) {
9191 var buf bytes.Buffer
9292
93 p := New(WithOutput(&buf))
93 p := New(WithOutput(&buf), WithWidth(80))
9494
9595 total := 50
9696
118118 func TestBarHas100PercentWithBarRemoveOnComplete(t *testing.T) {
119119 var buf bytes.Buffer
120120
121 p := New(WithOutput(&buf))
121 p := New(WithOutput(&buf), WithWidth(80))
122122
123123 total := 50
124124
2121 total: 60,
2222 current: 20,
2323 barWidth: 80,
24 want: " ",
24 want: "… ",
2525 },
2626 {
2727 name: "t,c,bw{60,20,80}trim",
3838 total: 60,
3939 current: 20,
4040 barWidth: 80,
41 want: " ",
41 want: "… ",
4242 },
4343 {
4444 name: "t,c,bw{60,20,80}trim",
318318 }
319319
320320 var tmpBuf bytes.Buffer
321 for termWidth, cases := range testSuite {
321 for tw, cases := range testSuite {
322322 for _, tc := range cases {
323323 s := newTestState(tc.reverse)
324324 s.reqWidth = tc.barWidth
331331 }
332332 }
333333 tmpBuf.Reset()
334 tmpBuf.ReadFrom(s.draw(newStatistics(termWidth, s)))
334 tmpBuf.ReadFrom(s.draw(newStatistics(tw, s)))
335335 by := tmpBuf.Bytes()
336336 by = by[:len(by)-1]
337337
338338 got := string(by)
339339 if got != tc.want {
340 t.Errorf("termWidth:%d %q want: %q %d, got: %q %d\n", termWidth, tc.name, tc.want, len(tc.want), got, len(got))
340 t.Errorf("termWidth:%d %q want: %q %d, got: %q %d\n", tw, tc.name, tc.want, len(tc.want), got, len(got))
341341 }
342342 }
343343 }