avoid potential race in test
Vladimir Bauer
7 years ago
| 4 | 4 | "fmt" |
| 5 | 5 | "io/ioutil" |
| 6 | 6 | "strings" |
| 7 | "sync/atomic" | |
| 7 | 8 | "testing" |
| 8 | 9 | "time" |
| 9 | 10 | "unicode/utf8" |
| 147 | 148 | |
| 148 | 149 | total := 100 |
| 149 | 150 | panicMsg := "Upps!!!" |
| 150 | var pCount int | |
| 151 | var pCount uint32 | |
| 151 | 152 | bar := p.AddBar(int64(total), |
| 152 | 153 | PrependDecorators(panicDecorator(panicMsg, |
| 153 | 154 | func(st *decor.Statistics) bool { |
| 154 | 155 | if st.Current >= 42 { |
| 155 | pCount++ | |
| 156 | atomic.AddUint32(&pCount, 1) | |
| 156 | 157 | return true |
| 157 | 158 | } |
| 158 | 159 | return false |
| 183 | 184 | |
| 184 | 185 | total := 100 |
| 185 | 186 | panicMsg := "Upps!!!" |
| 186 | var pCount int | |
| 187 | var pCount uint32 | |
| 187 | 188 | bar := p.AddBar(int64(total), |
| 188 | 189 | PrependDecorators(panicDecorator(panicMsg, |
| 189 | 190 | func(st *decor.Statistics) bool { |
| 190 | 191 | if st.Completed { |
| 191 | pCount++ | |
| 192 | atomic.AddUint32(&pCount, 1) | |
| 192 | 193 | return true |
| 193 | 194 | } |
| 194 | 195 | return false |