File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -169,6 +169,47 @@ func TestConcurrency(t *testing.T) {
169169 wg .Wait ()
170170}
171171
172+ func TestConcurrency2 (t * testing.T ) {
173+ assert := assert .New (t )
174+ ctrie := New (nil )
175+ var wg sync.WaitGroup
176+ wg .Add (4 )
177+
178+ go func () {
179+ for i := 0 ; i < 10000 ; i ++ {
180+ ctrie .Insert ([]byte (strconv .Itoa (i )), i )
181+ }
182+ wg .Done ()
183+ }()
184+
185+ go func () {
186+ for i := 0 ; i < 10000 ; i ++ {
187+ val , ok := ctrie .Lookup ([]byte (strconv .Itoa (i )))
188+ if ok {
189+ assert .Equal (i , val )
190+ }
191+ }
192+ wg .Done ()
193+ }()
194+
195+ go func () {
196+ for i := 0 ; i < 10000 ; i ++ {
197+ ctrie .Snapshot ()
198+ }
199+ wg .Done ()
200+ }()
201+
202+ go func () {
203+ for i := 0 ; i < 10000 ; i ++ {
204+ ctrie .ReadOnlySnapshot ()
205+ }
206+ wg .Done ()
207+ }()
208+
209+ wg .Wait ()
210+ assert .Equal (uint (10000 ), ctrie .Size ())
211+ }
212+
172213func TestSnapshot (t * testing.T ) {
173214 assert := assert .New (t )
174215 ctrie := New (nil )
You can’t perform that action at this time.
0 commit comments