mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-06 09:17:10 +08:00
18 lines
308 B
Go
18 lines
308 B
Go
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")
|
|
}
|
|
}
|