You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

40 lines
621 B

package nets
import (
"fmt"
"testing"
)
func TestIpConvert(t *testing.T) {
ip := "192.168.1.110"
// ip := "255.255.255.255"
i64, err := Ip2i64(ip)
if err != nil {
t.Error(err)
}
ip2 := I642Ip(int64(int32(i64)))
if ip2 != ip {
t.Error("ip parse error")
}
}
func TestAddressConvert(t *testing.T) {
addr := "192.168.1.110:8080"
i64, err := Address2i64(addr)
if err != nil {
t.Error(err)
}
addr2 := I642Address(i64)
if addr2 != addr {
t.Error("address parse error")
}
}
func TestGetHostIpv4(t *testing.T) {
ip, err := GetHostIpv4()
if err != nil {
t.Error(err)
return
}
fmt.Println(ip)
}