26 lines
371 B
Go
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()
|
||
|
}
|