2014-08-21 07:09:40 +02:00
|
|
|
package hashcode
|
|
|
|
|
2015-02-11 20:40:49 +01:00
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
2014-08-21 07:09:40 +02:00
|
|
|
|
|
|
|
func TestString(t *testing.T) {
|
|
|
|
v := "hello, world"
|
|
|
|
expected := String(v)
|
|
|
|
for i := 0; i < 100; i++ {
|
|
|
|
actual := String(v)
|
|
|
|
if actual != expected {
|
2015-02-11 19:59:21 +01:00
|
|
|
t.Fatalf("bad: %#v\n\t%#v", actual, expected)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestString_positiveIndex(t *testing.T) {
|
|
|
|
ips := []string{"192.168.1.3", "192.168.1.5"}
|
|
|
|
for _, ip := range ips {
|
2015-02-11 20:40:49 +01:00
|
|
|
if index := String(ip); index < 0 {
|
2015-02-11 19:59:21 +01:00
|
|
|
t.Fatalf("Bad Index %#v for ip %s", index, ip)
|
2014-08-21 07:09:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|