17 Star 36 Fork 10

ShirDon-廖显东 / goProgressor

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
progress_test.go 759 Bytes
一键复制 编辑 原始数据 按行查看 历史
githubvip 提交于 2019-11-29 16:18 . commit
package goprogressor
import (
"bytes"
"fmt"
"strings"
"sync"
"testing"
"time"
)
func TestStoppingPrintout(t *testing.T) {
progress := New()
progress.SetRefreshInterval(time.Millisecond * 10)
var buffer = &bytes.Buffer{}
progress.SetOut(buffer)
bar := progress.AddBar(100)
progress.Start()
var wg sync.WaitGroup
wg.Add(1)
go func() {
for i := 0; i <= 80; i = i + 10 {
bar.Set(i)
time.Sleep(time.Millisecond * 5)
}
wg.Done()
}()
wg.Wait()
progress.Stop()
fmt.Fprintf(buffer, "foo")
var wantSuffix = "[======================================================>-------------]\nfoo"
if !strings.HasSuffix(buffer.String(), wantSuffix) {
t.Errorf("Content that should be printed after stop not appearing on buffer.")
}
}
Go
1
https://gitee.com/shirdonl/goProgressor.git
git@gitee.com:shirdonl/goProgressor.git
shirdonl
goProgressor
goProgressor
master

搜索帮助