diff --git a/bar_test.go b/bar_test.go index 1f0067c..4e62287 100644 --- a/bar_test.go +++ b/bar_test.go @@ -61,9 +61,9 @@ total := 100 till := 30 - refillRune, _ := utf8.DecodeLastRuneInString(mpb.BarDefaultStyle) - - bar := p.AddBar(int64(total), mpb.BarFillerTrim()) + refiller := "+" + + bar := p.Add(int64(total), mpb.NewBarFiller(mpb.BarStyle().Refiller(refiller)), mpb.BarFillerTrim()) bar.SetRefill(int64(till)) bar.IncrBy(till) @@ -76,7 +76,7 @@ p.Wait() wantBar := fmt.Sprintf("[%s%s]", - strings.Repeat(string(refillRune), till-1), + strings.Repeat(refiller, till-1), strings.Repeat("=", total-till-1), ) @@ -143,22 +143,29 @@ func TestBarStyle(t *testing.T) { var buf bytes.Buffer customFormat := "╢▌▌░╟" + runes := []rune(customFormat) total := 80 p := mpb.New(mpb.WithWidth(total), mpb.WithOutput(&buf)) - bar := p.Add(int64(total), mpb.NewBarFiller(customFormat), mpb.BarFillerTrim()) - - for i := 0; i < total; i++ { - bar.Increment() - time.Sleep(10 * time.Millisecond) - } - - p.Wait() - - runes := []rune(customFormat) - wantBar := fmt.Sprintf("%s%s%s", + bs := mpb.BarStyle() + bs.Lbound(string(runes[0])) + bs.Filler(string(runes[1])) + bs.Tip(string(runes[2])) + bs.Padding(string(runes[3])) + bs.Rbound(string(runes[4])) + bar := p.Add(int64(total), mpb.NewBarFiller(bs), mpb.BarFillerTrim()) + + for i := 0; i < total; i++ { + bar.Increment() + time.Sleep(10 * time.Millisecond) + } + + p.Wait() + + wantBar := fmt.Sprintf("%s%s%s%s", string(runes[0]), - strings.Repeat(string(runes[1]), total-2), - string(runes[len(runes)-1]), + strings.Repeat(string(runes[1]), total-3), + string(runes[2]), + string(runes[4]), ) got := string(getLastLine(buf.Bytes()))