2013-12-12 19:07:14 +00:00
|
|
|
package consul
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestStrContains(t *testing.T) {
|
|
|
|
l := []string{"a", "b", "c"}
|
|
|
|
if !strContains(l, "b") {
|
|
|
|
t.Fatalf("should contain")
|
|
|
|
}
|
|
|
|
if strContains(l, "d") {
|
|
|
|
t.Fatalf("should not contain")
|
|
|
|
}
|
|
|
|
}
|
2013-12-31 23:44:17 +00:00
|
|
|
|
|
|
|
func TestIsPrivateIP(t *testing.T) {
|
|
|
|
if !isPrivateIP("192.168.1.1") {
|
|
|
|
t.Fatalf("bad")
|
|
|
|
}
|
|
|
|
if !isPrivateIP("172.16.45.100") {
|
|
|
|
t.Fatalf("bad")
|
|
|
|
}
|
|
|
|
if !isPrivateIP("10.1.2.3") {
|
|
|
|
t.Fatalf("bad")
|
|
|
|
}
|
|
|
|
if isPrivateIP("8.8.8.8") {
|
|
|
|
t.Fatalf("bad")
|
|
|
|
}
|
|
|
|
if isPrivateIP("127.0.0.1") {
|
|
|
|
t.Fatalf("bad")
|
|
|
|
}
|
|
|
|
}
|