refactoring: draw_test
initialize *bState with (*pState).makeBarState
Vladimir Bauer
2 years ago
| 766 | 766 | var tmpBuf bytes.Buffer |
| 767 | 767 | for tw, cases := range testSuite { |
| 768 | 768 | for _, tc := range cases { |
| 769 | s := newTestState(tc.style.Build()) | |
| 770 | s.reqWidth = tc.barWidth | |
| 771 | s.total = tc.total | |
| 769 | ps := pState{reqWidth: tc.barWidth} | |
| 770 | s := ps.makeBarState(tc.total, tc.style.Build()) | |
| 772 | 771 | s.current = tc.current |
| 773 | 772 | s.trimSpace = tc.trim |
| 774 | 773 | s.refill = tc.refill |
| 1220 | 1219 | var tmpBuf bytes.Buffer |
| 1221 | 1220 | for tw, cases := range testSuite { |
| 1222 | 1221 | for _, tc := range cases { |
| 1223 | s := newTestState(tc.style.Build()) | |
| 1224 | s.reqWidth = tc.barWidth | |
| 1225 | s.total = tc.total | |
| 1222 | ps := pState{reqWidth: tc.barWidth} | |
| 1223 | s := ps.makeBarState(tc.total, tc.style.Build()) | |
| 1226 | 1224 | s.current = tc.current |
| 1227 | 1225 | s.trimSpace = tc.trim |
| 1228 | 1226 | s.refill = tc.refill |
| 1397 | 1395 | var tmpBuf bytes.Buffer |
| 1398 | 1396 | for tw, cases := range testSuite { |
| 1399 | 1397 | for _, tc := range cases { |
| 1400 | s := newTestState(tc.style.Build()) | |
| 1401 | s.reqWidth = tc.barWidth | |
| 1402 | s.total = tc.total | |
| 1398 | ps := pState{reqWidth: tc.barWidth} | |
| 1399 | s := ps.makeBarState(tc.total, tc.style.Build()) | |
| 1403 | 1400 | s.current = tc.current |
| 1404 | 1401 | s.trimSpace = tc.trim |
| 1405 | 1402 | s.refill = tc.refill |
| 1425 | 1422 | } |
| 1426 | 1423 | } |
| 1427 | 1424 | } |
| 1428 | ||
| 1429 | func newTestState(filler BarFiller) *bState { | |
| 1430 | bs := &bState{ | |
| 1431 | filler: filler, | |
| 1432 | } | |
| 1433 | for i := 0; i < len(bs.buffers); i++ { | |
| 1434 | bs.buffers[i] = bytes.NewBuffer(make([]byte, 0, defaultStructBufCap)) | |
| 1435 | } | |
| 1436 | return bs | |
| 1437 | } | |