mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-06 17:26:52 +08:00
add some unittests and bug fix
This commit is contained in:
17
lib/consistenthash/consistenthash_test.go
Normal file
17
lib/consistenthash/consistenthash_test.go
Normal file
@@ -0,0 +1,17 @@
|
||||
package consistenthash
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestHash(t *testing.T) {
|
||||
m := New(3, nil)
|
||||
m.AddNode("a", "b", "c", "d")
|
||||
if m.PickNode("zxc") != "a" {
|
||||
t.Error("wrong answer")
|
||||
}
|
||||
if m.PickNode("123{abc}") != "b" {
|
||||
t.Error("wrong answer")
|
||||
}
|
||||
if m.PickNode("abc") != "b" {
|
||||
t.Error("wrong answer")
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user