Merge in DNS/adguard-home from imp-test-file-names to master Squashed commit of the following: commit a0827efdf633fba012c5eb0e0f69eaabf7629724 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 10 21:41:46 2025 +0300 all: imp tests commit 21fc274d9276ce0442572261ea39a1c018490870 Author: Stanislav Chzhen <s.chzhen@adguard.com> Date: Mon Mar 10 19:40:40 2025 +0300 all: imp test file names
46 lines
809 B
Go
46 lines
809 B
Go
package aghnet_test
|
|
|
|
import (
|
|
"net"
|
|
"testing"
|
|
|
|
"github.com/AdguardTeam/AdGuardHome/internal/aghnet"
|
|
"github.com/AdguardTeam/golibs/netutil"
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestIPMut(t *testing.T) {
|
|
testIPs := []net.IP{{
|
|
127, 0, 0, 1,
|
|
}, {
|
|
192, 168, 0, 1,
|
|
}, {
|
|
8, 8, 8, 8,
|
|
}}
|
|
|
|
t.Run("nil_no_mut", func(t *testing.T) {
|
|
ipmut := aghnet.NewIPMut(nil)
|
|
|
|
ips := netutil.CloneIPs(testIPs)
|
|
for i := range ips {
|
|
ipmut.Load()(ips[i])
|
|
assert.True(t, ips[i].Equal(testIPs[i]))
|
|
}
|
|
})
|
|
|
|
t.Run("not_nil_mut", func(t *testing.T) {
|
|
ipmut := aghnet.NewIPMut(func(ip net.IP) {
|
|
for i := range ip {
|
|
ip[i] = 0
|
|
}
|
|
})
|
|
want := netutil.IPv4Zero()
|
|
|
|
ips := netutil.CloneIPs(testIPs)
|
|
for i := range ips {
|
|
ipmut.Load()(ips[i])
|
|
assert.True(t, ips[i].Equal(want))
|
|
}
|
|
})
|
|
}
|