Skip to content

Commit

Permalink
Merge branch 'main' into c/remove-downloads-badge
Browse files Browse the repository at this point in the history
  • Loading branch information
bschaatsbergen authored Dec 2, 2023
2 parents c116c71 + 0469318 commit 5e85de3
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions pkg/core/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,46 @@ func TestContainsAddress(t *testing.T) {
})
}
}

func TestParseCIDR(t *testing.T) {
tests := []struct {
name string
cidrStr string
wantErr bool
}{
{
name: "Parse a valid IPv4 CIDR",
cidrStr: "10.0.0.0/16",
wantErr: false,
},
{
name: "Parse a valid IPv6 CIDR",
cidrStr: "2001:db8:1234:1a00::/106",
wantErr: false,
},
{
name: "Parse an invalid IPv4 CIDR",
cidrStr: "356.356.356.356/16",
wantErr: true,
},
{
name: "Parse an invalid IPv6 CIDR",
cidrStr: "2001:db8:1234:1a00::/129",
wantErr: true,
},
{
name: "Parse an empty CIDR",
cidrStr: "",
wantErr: true,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
_, err := ParseCIDR(tt.cidrStr)
if (err != nil) != tt.wantErr {
t.Errorf("ParseCIDR() error = %v, wantErr %v", err, tt.wantErr)
return
}
})
}
}

0 comments on commit 5e85de3

Please sign in to comment.