Codebase list golang-github-vbauerster-mpb / 1dc4c4c
Refactoring draw test Vladimir Bauer 8 years ago
1 changed file(s) with 7 addition(s) and 6 deletion(s). Raw diff Collapse all Expand all
179179
180180 prependWs := newWidthSyncer(nil, 1, 0)
181181 appendWs := newWidthSyncer(nil, 1, 0)
182 var temp bytes.Buffer
182 var tmpBuf bytes.Buffer
183183 for termWidth, cases := range testSuite {
184184 for name, tc := range cases {
185185 s := newTestState()
189189 if tc.barRefill != nil {
190190 s.refill = tc.barRefill
191191 }
192 temp.Reset()
193 temp.ReadFrom(s.draw(termWidth, prependWs, appendWs))
194 got := temp.String()
195 if got != tc.want+"\n" {
196 t.Errorf("termWidth %d; %s: want: %s %d, got: %s %d\n", termWidth, name, tc.want+"\n", len(tc.want), got, len(got))
192 tmpBuf.Reset()
193 tmpBuf.ReadFrom(s.draw(termWidth, prependWs, appendWs))
194 got := tmpBuf.String()
195 want := tc.want + "\n"
196 if got != want {
197 t.Errorf("termWidth %d; %s: want: %s %d, got: %s %d\n", termWidth, name, want, len(want), got, len(got))
197198 }
198199 }
199200 }