Skip to content

Commit bdb2b60

Browse files
committed
fix tests
1 parent 8562e08 commit bdb2b60

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

map_test.go

+11-18
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,23 @@
11
package lrc
22

33
import (
4-
"math/rand"
5-
"sync"
64
"testing"
75
)
86

97
func TestLRMap(t *testing.T) {
108
lrmap := newIntMap()
119

12-
wg := sync.WaitGroup{}
13-
14-
for i := 0; i < 100000; i++ {
15-
wg.Add(1)
16-
go func() {
17-
lrmap.Get(rand.Intn(10000))
18-
wg.Done()
19-
}()
10+
_, exist := lrmap.Get(1)
11+
if exist {
12+
t.Error("should not exist")
2013
}
2114

22-
wg.Add(1)
23-
go func() {
24-
k := rand.Intn(10000)
25-
lrmap.Put(k, k)
26-
wg.Done()
27-
}()
28-
29-
wg.Wait()
15+
lrmap.Put(1, 1)
16+
v, exist := lrmap.Get(1)
17+
if v != 1 {
18+
t.Error("not equal")
19+
}
20+
if !exist {
21+
t.Error("should exist")
22+
}
3023
}

0 commit comments

Comments
 (0)