Files
Havline/internal/frp/location_test.go
T

23 lines
483 B
Go
Raw Normal View History

2026-09-23 09:40:59 +08:00
package frp
import (
"net"
"testing"
)
func TestFormatLocation(t *testing.T) {
value := formatLocation(ipLocationResponse{City: "Hong Kong", Region: "Hong Kong", Country: "China"})
if value != "Hong Kong · China" {
t.Fatalf("位置格式错误:%s", value)
}
}
func TestIsPublicIP(t *testing.T) {
if !isPublicIP(net.ParseIP("38.95.74.87")) {
t.Fatal("公网 IP 应被识别")
}
if isPublicIP(net.ParseIP("192.168.1.1")) {
t.Fatal("私网 IP 不应被定位")
}
}