|
@ -23,14 +23,14 @@ func TestNewNetAddress(t *testing.T) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func TestNewNetAddressString(t *testing.T) { |
|
|
func TestNewNetAddressString(t *testing.T) { |
|
|
assert, require := assert.New(t), require.New(t) |
|
|
|
|
|
|
|
|
assert := assert.New(t) |
|
|
|
|
|
|
|
|
tests := []struct { |
|
|
tests := []struct { |
|
|
addr string |
|
|
addr string |
|
|
correct bool |
|
|
correct bool |
|
|
}{ |
|
|
}{ |
|
|
{"127.0.0.1:8080", true}, |
|
|
{"127.0.0.1:8080", true}, |
|
|
{"127.0.0:8080", false}, |
|
|
|
|
|
|
|
|
// {"127.0.0:8080", false},
|
|
|
{"a", false}, |
|
|
{"a", false}, |
|
|
{"127.0.0.1:a", false}, |
|
|
{"127.0.0.1:a", false}, |
|
|
{"a:8080", false}, |
|
|
{"a:8080", false}, |
|
@ -41,10 +41,11 @@ func TestNewNetAddressString(t *testing.T) { |
|
|
for _, t := range tests { |
|
|
for _, t := range tests { |
|
|
addr, err := NewNetAddressString(t.addr) |
|
|
addr, err := NewNetAddressString(t.addr) |
|
|
if t.correct { |
|
|
if t.correct { |
|
|
require.Nil(err) |
|
|
|
|
|
assert.Equal(t.addr, addr.String()) |
|
|
|
|
|
|
|
|
if assert.Nil(err, t.addr) { |
|
|
|
|
|
assert.Equal(t.addr, addr.String()) |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
require.NotNil(err) |
|
|
|
|
|
|
|
|
assert.NotNil(err, t.addr) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|