diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2015-01-11 23:49:12 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2015-01-11 23:49:12 +0900 |
commit | 9dbf6b02d24b52ae43e36905bbb1e83087e1dfe9 (patch) | |
tree | 37e627f5bb4a3037ea769aad1033593baec4eb00 /src/item_test.go | |
parent | 1db68a3976cfb10ed7d6ab88d7b468bb1b93ee34 (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/item_test.go')
-rw-r--r-- | src/item_test.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/item_test.go b/src/item_test.go index 87d8be46..0e83631a 100644 --- a/src/item_test.go +++ b/src/item_test.go @@ -31,13 +31,13 @@ func TestRankComparison(t *testing.T) { // Match length, string length, index func TestItemRank(t *testing.T) { strs := []string{"foo", "foobar", "bar", "baz"} - item1 := Item{text: &strs[0], rank: Rank{0, 0, 1}, offsets: []Offset{}} - rank1 := item1.Rank() + item1 := Item{text: &strs[0], index: 1, offsets: []Offset{}} + rank1 := item1.Rank(true) if rank1.matchlen != 0 || rank1.strlen != 3 || rank1.index != 1 { - t.Error(item1.Rank()) + t.Error(item1.Rank(true)) } // Only differ in index - item2 := Item{text: &strs[0], rank: Rank{0, 0, 0}, offsets: []Offset{}} + item2 := Item{text: &strs[0], index: 0, offsets: []Offset{}} items := []*Item{&item1, &item2} sort.Sort(ByRelevance(items)) |