Skip to content

Commit

Permalink
Merge pull request kubernetes#110203 from wppzxc/add-testcases
Browse files Browse the repository at this point in the history
Fix: Add test cases for method IsZeroCIDR() in  pkg/proxy/util/utils_test.go
  • Loading branch information
k8s-ci-robot authored May 27, 2022
2 parents 32c3fb3 + 872be44 commit cb92b2c
Showing 1 changed file with 41 additions and 0 deletions.
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)
}
})
}
}

0 comments on commit cb92b2c

Please sign in to comment.