File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change @@ -1469,3 +1469,44 @@ func TestContainsIPv4Loopback(t *testing.T) {
1469
1469
})
1470
1470
}
1471
1471
}
1472
+
1473
+ func TestIsZeroCIDR (t * testing.T ) {
1474
+ testCases := []struct {
1475
+ name string
1476
+ input string
1477
+ expected bool
1478
+ }{
1479
+ {
1480
+ name : "invalide cidr" ,
1481
+ input : "" ,
1482
+ expected : false ,
1483
+ },
1484
+ {
1485
+ name : "ipv4 cidr" ,
1486
+ input : "172.10.0.0/16" ,
1487
+ expected : false ,
1488
+ },
1489
+ {
1490
+ name : "ipv4 zero cidr" ,
1491
+ input : IPv4ZeroCIDR ,
1492
+ expected : true ,
1493
+ },
1494
+ {
1495
+ name : "ipv6 cidr" ,
1496
+ input : "::/128" ,
1497
+ expected : false ,
1498
+ },
1499
+ {
1500
+ name : "ipv6 zero cidr" ,
1501
+ input : IPv6ZeroCIDR ,
1502
+ expected : true ,
1503
+ },
1504
+ }
1505
+ for _ , tc := range testCases {
1506
+ t .Run (tc .name , func (t * testing.T ) {
1507
+ if got := IsZeroCIDR (tc .input ); tc .expected != got {
1508
+ t .Errorf ("IsZeroCIDR() = %t, want %t" , got , tc .expected )
1509
+ }
1510
+ })
1511
+ }
1512
+ }
You can’t perform that action at this time.
0 commit comments