statview/stat_test.go

29 lines
393 B
Go
Raw Permalink Normal View History

2023-03-03 19:52:34 +01:00
package statview
import (
"fmt"
"testing"
"time"
)
func TestStat(t *testing.T) {
view := New[int]()
2023-03-10 23:12:02 +01:00
fmt.Println("asd")
2023-03-03 19:52:34 +01:00
for i := 0; i < 5; i++ {
view.Add(i)
2023-03-10 23:12:02 +01:00
2023-03-03 19:52:34 +01:00
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()
}