AdGuardDNS/internal/bindtodevice/connindex_linux_internal_test.go
Andrey Meshkov 150f2d733f Sync v2.5.1
2024-01-04 19:22:32 +03:00

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)
}