Skip to content

Commit 5a3666f

Browse files
committed
Add additional test
1 parent 20e5c66 commit 5a3666f

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

src/net/lookup_windows_test.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
)
1919

2020
var nslookupTestServers = []string{"mail.golang.com", "gmail.com"}
21+
var lookupTestIPs = []string{"8.8.8.8", "1.1.1.1"}
2122

2223
func toJson(v interface{}) string {
2324
data, _ := json.Marshal(v)
@@ -124,7 +125,7 @@ func TestNSLookupTXT(t *testing.T) {
124125
}
125126
}
126127

127-
func TestLookupPTR(t *testing.T) {
128+
func TestLookupLocalPTR(t *testing.T) {
128129
testenv.MustHaveExternalNetwork(t)
129130

130131
addr, err := localIP()
@@ -149,6 +150,29 @@ func TestLookupPTR(t *testing.T) {
149150
}
150151
}
151152

153+
func TestLookupPTR(t *testing.T) {
154+
testenv.MustHaveExternalNetwork(t)
155+
156+
for _, addr := range lookupTestIPs {
157+
names, err := LookupAddr(addr)
158+
if err != nil {
159+
t.Errorf("failed %s: %s", addr, err)
160+
}
161+
if len(names) == 0 {
162+
t.Errorf("no results")
163+
}
164+
expected, err := lookupPTR(addr)
165+
if err != nil {
166+
t.Logf("skipping failed lookup %s test: %s", addr, err)
167+
}
168+
sort.Strings(expected)
169+
sort.Strings(names)
170+
if !reflect.DeepEqual(expected, names) {
171+
t.Errorf("different results %s:\texp:%v\tgot:%v", addr, toJson(expected), toJson(names))
172+
}
173+
}
174+
}
175+
152176
type byPrefAndHost []*MX
153177

154178
func (s byPrefAndHost) Len() int { return len(s) }

0 commit comments

Comments
 (0)