| // Copyright 2009 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| var hosttests = []hostTest{ |
| func TestLookupStaticHost(t *testing.T) { |
| hostsPath = "testdata/hosts" |
| for i := 0; i < len(hosttests); i++ { |
| ips := lookupStaticHost(tt.host) |
| if len(ips) != len(tt.ips) { |
| t.Errorf("# of hosts = %v; want %v", |
| if tt.ips[k].String() != v { |
| t.Errorf("lookupStaticHost(%q) = %v; want %v", |
| func TestLookupHost(t *testing.T) { |
| // Can't depend on this to return anything in particular, |
| // but if it does return something, make sure it doesn't |
| // duplicate addresses (a common bug due to the way |
| addrs, _ := LookupHost("localhost") |
| for i := 0; i+1 < len(addrs); i++ { |
| if addrs[i] == addrs[i+1] { |
| t.Fatalf("LookupHost(\"localhost\") = %v, has duplicate addresses", addrs) |