初版功能完成
ci / Go checks (ubuntu-latest) (push) Has been cancelled
ci / Go checks (windows-latest) (push) Has been cancelled

This commit is contained in:
qsc
2026-08-29 13:12:17 +08:00
commit 142e5dc7d6
217 changed files with 21313 additions and 0 deletions
@@ -0,0 +1,35 @@
//go:build windows
package windowsplatform
import (
"net/netip"
"testing"
)
func TestValidateAdapterConfig(t *testing.T) {
t.Parallel()
tests := []struct {
name string
address string
mtu int
wantErr bool
}{
{name: "valid", address: "10.88.0.2/16", mtu: 1280},
{name: "IPv6", address: "fd00::2/64", mtu: 1280, wantErr: true},
{name: "network", address: "10.88.0.0/16", mtu: 1280, wantErr: true},
{name: "broadcast", address: "10.88.255.255/16", mtu: 1280, wantErr: true},
{name: "small MTU", address: "10.88.0.2/16", mtu: 575, wantErr: true},
}
for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) {
t.Parallel()
prefix := netip.MustParsePrefix(test.address)
err := validateAdapterConfig(AdapterConfig{Address: prefix, MTU: test.mtu})
if (err != nil) != test.wantErr {
t.Fatalf("validateAdapterConfig() error = %v, wantErr %v", err, test.wantErr)
}
})
}
}