diff --git a/bar_test.go b/bar_test.go index 3f662ac..9cf8466 100644 --- a/bar_test.go +++ b/bar_test.go @@ -5,6 +5,7 @@ "fmt" "io/ioutil" "strings" + "sync/atomic" "testing" "time" "unicode/utf8" @@ -148,12 +149,12 @@ total := 100 panicMsg := "Upps!!!" - var pCount int + var pCount uint32 bar := p.AddBar(int64(total), PrependDecorators(panicDecorator(panicMsg, func(st *decor.Statistics) bool { if st.Current >= 42 { - pCount++ + atomic.AddUint32(&pCount, 1) return true } return false @@ -184,12 +185,12 @@ total := 100 panicMsg := "Upps!!!" - var pCount int + var pCount uint32 bar := p.AddBar(int64(total), PrependDecorators(panicDecorator(panicMsg, func(st *decor.Statistics) bool { if st.Completed { - pCount++ + atomic.AddUint32(&pCount, 1) return true } return false