mirror of
https://github.com/ditatompel/xmr-remote-nodes.git
synced 2025-01-08 05:52:10 +07:00
47 lines
762 B
Go
47 lines
762 B
Go
|
package ip
|
||
|
|
||
|
import (
|
||
|
"net"
|
||
|
"testing"
|
||
|
)
|
||
|
|
||
|
// Single test: go test ./internal/ip -bench TestIsIPv6Only -benchmem -run=^$ -v
|
||
|
func TestIsIPv6Only(t *testing.T) {
|
||
|
tests := []struct {
|
||
|
name string
|
||
|
ips []net.IP
|
||
|
want bool
|
||
|
}{
|
||
|
{
|
||
|
name: "IPv4",
|
||
|
ips: []net.IP{
|
||
|
net.ParseIP("1.1.1.1"),
|
||
|
},
|
||
|
want: false,
|
||
|
},
|
||
|
{
|
||
|
name: "IPv6",
|
||
|
ips: []net.IP{
|
||
|
net.ParseIP("2606:4700::6810:85e5"),
|
||
|
},
|
||
|
want: true,
|
||
|
},
|
||
|
{
|
||
|
name: "IPv6 and IPv4",
|
||
|
ips: []net.IP{
|
||
|
net.ParseIP("1.1.1.1"),
|
||
|
net.ParseIP("2606:4700::6810:84e5"),
|
||
|
},
|
||
|
want: false,
|
||
|
},
|
||
|
}
|
||
|
|
||
|
for _, tt := range tests {
|
||
|
t.Run(tt.name, func(t *testing.T) {
|
||
|
if got := IsIPv6Only(tt.ips); got != tt.want {
|
||
|
t.Errorf("IsIPv6Only() = %v, want %v", got, tt.want)
|
||
|
}
|
||
|
})
|
||
|
}
|
||
|
}
|