summaryrefslogtreecommitdiffstats
path: root/src/merger_test.go
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2015-01-11 23:49:12 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2015-01-11 23:49:12 +0900
commit9dbf6b02d24b52ae43e36905bbb1e83087e1dfe9 (patch)
tree37e627f5bb4a3037ea769aad1033593baec4eb00 /src/merger_test.go
parent1db68a3976cfb10ed7d6ab88d7b468bb1b93ee34 (diff)
Fix race conditions
- Wait for completions of goroutines when cancelling a search - Remove shared access to rank field of Item
Diffstat (limited to 'src/merger_test.go')
-rw-r--r--src/merger_test.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/merger_test.go b/src/merger_test.go
index 32a1228a..f79da09a 100644
--- a/src/merger_test.go
+++ b/src/merger_test.go
@@ -1,6 +1,7 @@
package fzf
import (
+ "fmt"
"math/rand"
"sort"
"testing"
@@ -13,8 +14,17 @@ func assert(t *testing.T, cond bool, msg ...string) {
}
func randItem() *Item {
+ str := fmt.Sprintf("%d", rand.Uint32())
+ offsets := make([]Offset, rand.Int()%3)
+ for idx := range offsets {
+ sidx := int32(rand.Uint32() % 20)
+ eidx := sidx + int32(rand.Uint32()%20)
+ offsets[idx] = Offset{sidx, eidx}
+ }
return &Item{
- rank: Rank{uint16(rand.Uint32()), uint16(rand.Uint32()), rand.Uint32()}}
+ text: &str,
+ index: rand.Uint32(),
+ offsets: offsets}
}
func TestEmptyMerger(t *testing.T) {