github.com/jrperritt/terraform@v0.1.1-0.20170525065507-96f391dafc38/helper/hashcode/hashcode_test.go (about) 1 package hashcode 2 3 import ( 4 "testing" 5 ) 6 7 func TestString(t *testing.T) { 8 v := "hello, world" 9 expected := String(v) 10 for i := 0; i < 100; i++ { 11 actual := String(v) 12 if actual != expected { 13 t.Fatalf("bad: %#v\n\t%#v", actual, expected) 14 } 15 } 16 } 17 18 func TestString_positiveIndex(t *testing.T) { 19 // "2338615298" hashes to uint32(2147483648) which is math.MinInt32 20 ips := []string{"192.168.1.3", "192.168.1.5", "2338615298"} 21 for _, ip := range ips { 22 if index := String(ip); index < 0 { 23 t.Fatalf("Bad Index %#v for ip %s", index, ip) 24 } 25 } 26 }