MCPcopy Index your code
hub / github.com/schollz/progressbar / TestOptionSetElapsedTime

Function TestOptionSetElapsedTime

progressbar_test.go:590–619  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

588}
589
590func TestOptionSetElapsedTime(t *testing.T) {
591 buf := strings.Builder{}
592 bar := NewOptions(
593 10,
594 OptionSetElapsedTime(false),
595 OptionSetPredictTime(false),
596 OptionSetWidth(10),
597 OptionSetWriter(&buf),
598 )
599
600 _ = bar.Add(2)
601 result := strings.TrimSpace(buf.String())
602 expect := "20% |██ |"
603
604 if result != expect {
605 t.Errorf("Render miss-match\nResult: '%s'\nExpect: '%s'\n%+v", result, expect, bar)
606 }
607
608 bar.Reset()
609 bar.config.elapsedTime = true
610 buf.Reset()
611
612 _ = bar.Add(7)
613 result = strings.TrimSpace(buf.String())
614 expect = "70% |███████ | [0s]"
615
616 if result != expect {
617 t.Errorf("Render miss-match\nResult: '%s'\nExpect: '%s'\n%+v", result, expect, bar)
618 }
619}
620
621func TestShowElapsedTimeOnFinish(t *testing.T) {
622 buf := strings.Builder{}

Callers

nothing calls this directly

Calls 8

NewOptionsFunction · 0.85
OptionSetElapsedTimeFunction · 0.85
OptionSetPredictTimeFunction · 0.85
OptionSetWidthFunction · 0.85
OptionSetWriterFunction · 0.85
AddMethod · 0.80
StringMethod · 0.80
ResetMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…