mirror of
https://github.com/AdguardTeam/AdGuardDNS.git
synced 2025-02-20 11:23:36 +08:00
30 lines
629 B
Go
30 lines
629 B
Go
//go:build linux
|
|
|
|
package bindtodevice
|
|
|
|
import (
|
|
"net/netip"
|
|
"slices"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestSubnetCompare(t *testing.T) {
|
|
want := []netip.Prefix{
|
|
netip.MustParsePrefix("1.0.0.0/24"),
|
|
netip.MustParsePrefix("1.2.3.0/24"),
|
|
netip.MustParsePrefix("1.0.0.0/16"),
|
|
netip.MustParsePrefix("1.2.0.0/16"),
|
|
}
|
|
got := []netip.Prefix{
|
|
netip.MustParsePrefix("1.0.0.0/16"),
|
|
netip.MustParsePrefix("1.0.0.0/24"),
|
|
netip.MustParsePrefix("1.2.0.0/16"),
|
|
netip.MustParsePrefix("1.2.3.0/24"),
|
|
}
|
|
|
|
slices.SortFunc(got, subnetCompare)
|
|
assert.Equalf(t, want, got, "got (as strings): %q", got)
|
|
}
|