statview/stat_test.go
2023-03-03 19:52:34 +01:00

26 lines
371 B
Go

package statview
import (
"fmt"
"testing"
"time"
)
func TestStat(t *testing.T) {
view := New[int]()
for i := 0; i < 5; i++ {
view.Add(i)
go func(id int) {
defer view.Done(id)
for p := 0; p <= 100; p++ {
view.Report(id, fmt.Sprintf("task %d: %3d%%", id, p))
time.Sleep(time.Duration(id+1) * 10 * time.Millisecond)
}
}(i)
}
view.Show()
}