add some unittest

This commit is contained in:
hdt3213
2021-05-07 00:04:38 +08:00
parent 18d2cbb29b
commit fc39150740
5 changed files with 131 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
package dict
import (
"github.com/hdt3213/godis/lib/utils"
"strconv"
"sync"
"testing"
@@ -267,3 +268,14 @@ func TestConcurrentRandomKey(t *testing.T) {
t.Errorf("get duplicated keys in result")
}
}
func TestConcurrentDict_Keys(t *testing.T) {
d := MakeConcurrent(0)
size := 10
for i := 0; i < size; i++ {
d.Put(utils.RandString(5), utils.RandString(5))
}
if len(d.Keys()) != size {
t.Errorf("expect %d keys, actual: %d", size, len(d.Keys()))
}
}