test: avoid expanding massive CIDRs

This commit is contained in:
ZacharyZcR
2026-06-01 02:33:10 +08:00
parent ea17b5b1bc
commit ac755a9b4a
+1 -7
View File
@@ -890,12 +890,6 @@ func TestParseIP_InternalNetworkShortcuts(t *testing.T) {
100, // 172.16.0.0/12 应该很多 100, // 172.16.0.0/12 应该很多
"172.", "172.",
}, },
{
"10简写",
"10",
100, // 10.0.0.0/8 应该很多
"10.",
},
} }
for _, tt := range tests { for _, tt := range tests {
@@ -1007,7 +1001,7 @@ func TestParseIP_InvalidCIDR(t *testing.T) {
expectErr bool expectErr bool
}{ }{
{"无效掩码/33", "192.168.1.0/33", true}, {"无效掩码/33", "192.168.1.0/33", true},
{"效掩码/0", "192.168.1.0/0", false}, // /0 技术上是有效的 {"效掩码/32", "192.168.1.1/32", false},
{"格式错误", "192.168.1.0/abc", true}, {"格式错误", "192.168.1.0/abc", true},
{"缺少掩码", "192.168.1.0/", true}, {"缺少掩码", "192.168.1.0/", true},
} }