dnsxl/reverse_test.go

23 lines
481 B
Go

package dnsxl
import (
"net"
"testing"
)
func TestReverseName(t *testing.T) {
for _, x := range [][2]string{
{"1.2.3.4", "4.3.2.1"},
{"127.0.0.1", "1.0.0.127"},
{"192.168.11.12", "12.11.168.192"},
{"2001:8b0:8b0::1", "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.b.8.0.0.b.8.0.1.0.0.2"},
} {
ip := net.ParseIP(x[0])
r := reverseName(ip)
if r != x[1] {
t.Errorf("for IP %s [parsed from %s]: got reversed name %q but expected %q",
ip, x[0], r, x[1])
}
}
}