github.com/hdt3213/godis@v1.2.9/lib/consistenthash/consistenthash_test.go (about) 1 package consistenthash 2 3 import "testing" 4 5 func TestHash(t *testing.T) { 6 m := New(3, nil) 7 m.AddNode("a", "b", "c", "d") 8 if m.PickNode("zxc") != "a" { 9 t.Error("wrong answer") 10 } 11 if m.PickNode("123{abc}") != "b" { 12 t.Error("wrong answer") 13 } 14 if m.PickNode("abc") != "b" { 15 t.Error("wrong answer") 16 } 17 }