mirror of https://github.com/poanetwork/gecko.git
utils: Add test for IPDesc.PortString
This commit is contained in:
parent
599756feb8
commit
631615d907
|
@ -62,3 +62,22 @@ func TestIPDescEqual(t *testing.T) {
|
|||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestIPDescPortString(t *testing.T) {
|
||||
tests := []struct {
|
||||
ipDesc IPDesc
|
||||
result string
|
||||
}{
|
||||
{IPDesc{net.ParseIP("127.0.0.1"), 0}, ":0"},
|
||||
{IPDesc{net.ParseIP("::1"), 42}, ":42"},
|
||||
{IPDesc{net.ParseIP("::ffff:127.0.0.1"), 65535}, ":65535"},
|
||||
{IPDesc{net.IP{}, 1234}, ":1234"},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.result, func(t *testing.T) {
|
||||
if result := tt.ipDesc.PortString(); result != tt.result {
|
||||
t.Errorf("Expected %q, got %q", tt.result, result)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue