net/netip: cover more AddrPort.String cases in tests

TestInvalidAddrPortString currently only tests for invalid AddrPorts.
Add some valid cases as well to improve test coverage.

Change-Id: Iaa9192e48a61daed6f7ce7d680d602a021570bdc
Reviewed-on: https://go-review.googlesource.com/c/go/+/613795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
Tobias Klauser 2024-09-17 10:42:08 +02:00 committed by Gopher Robot
parent db40d1a4c4
commit e190638f20

View File

@ -2179,11 +2179,14 @@ func TestPrefixString(t *testing.T) {
}
}
func TestInvalidAddrPortString(t *testing.T) {
func TestAddrPortString(t *testing.T) {
tests := []struct {
ipp AddrPort
want string
}{
{MustParseAddrPort("127.0.0.1:80"), "127.0.0.1:80"},
{MustParseAddrPort("[0000::0]:8080"), "[::]:8080"},
{MustParseAddrPort("[FFFF::1]:8080"), "[ffff::1]:8080"},
{AddrPort{}, "invalid AddrPort"},
{AddrPortFrom(Addr{}, 80), "invalid AddrPort"},
}