Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Add test cases for method IsZeroCIDR() in pkg/proxy/util/utils_test.go #110203

Merged
merged 1 commit into from
May 27, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 41 additions & 0 deletions pkg/proxy/util/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1469,3 +1469,44 @@ func TestContainsIPv4Loopback(t *testing.T) {
})
}
}

func TestIsZeroCIDR(t *testing.T) {
testCases := []struct {
name string
input string
expected bool
}{
{
name: "invalide cidr",
input: "",
expected: false,
},
{
name: "ipv4 cidr",
input: "172.10.0.0/16",
expected: false,
},
{
name: "ipv4 zero cidr",
input: IPv4ZeroCIDR,
expected: true,
},
{
name: "ipv6 cidr",
input: "::/128",
expected: false,
},
{
name: "ipv6 zero cidr",
input: IPv6ZeroCIDR,
expected: true,
},
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
if got := IsZeroCIDR(tc.input); tc.expected != got {
t.Errorf("IsZeroCIDR() = %t, want %t", got, tc.expected)
}
})
}
}