mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-09-28 05:46:36 +08:00
177578ef4e
新增访问日志概览 API 与前端页面:汇总请求量/访问量/带宽趋势与 Top 排行, 明细列表保留检索;排行榜改为紧凑列表样式。
45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
package geoip
|
|
|
|
import "testing"
|
|
|
|
func TestCountryCentroidGermany(t *testing.T) {
|
|
lat, lon, ok := CountryCentroidByISO("DE")
|
|
if !ok {
|
|
t.Fatal("expected DE centroid")
|
|
}
|
|
if lat < 47 || lat > 55 || lon < 5 || lon > 15 {
|
|
t.Fatalf("unexpected Germany centroid: %f,%f", lat, lon)
|
|
}
|
|
}
|
|
|
|
func TestCountryCentroidHongKongSingaporeTaiwan(t *testing.T) {
|
|
cases := []struct {
|
|
iso string
|
|
name string
|
|
minLat float64
|
|
maxLat float64
|
|
minLon float64
|
|
maxLon float64
|
|
}{
|
|
{iso: "HK", name: "Hong Kong", minLat: 22, maxLat: 23, minLon: 113, maxLon: 115},
|
|
{iso: "SG", name: "Singapore", minLat: 1, maxLat: 2, minLon: 103, maxLon: 104},
|
|
{iso: "TW", name: "Taiwan", minLat: 22, maxLat: 26, minLon: 119, maxLon: 122},
|
|
}
|
|
for _, tc := range cases {
|
|
lat, lon, ok := CountryCentroidByISO(tc.iso)
|
|
if !ok {
|
|
t.Fatalf("expected %s centroid by ISO", tc.iso)
|
|
}
|
|
if lat < tc.minLat || lat > tc.maxLat || lon < tc.minLon || lon > tc.maxLon {
|
|
t.Fatalf("%s ISO centroid out of range: %f,%f", tc.iso, lat, lon)
|
|
}
|
|
lat, lon, ok = CountryCentroidByName(tc.name)
|
|
if !ok {
|
|
t.Fatalf("expected %s centroid by name", tc.name)
|
|
}
|
|
if lat < tc.minLat || lat > tc.maxLat || lon < tc.minLon || lon > tc.maxLon {
|
|
t.Fatalf("%s name centroid out of range: %f,%f", tc.name, lat, lon)
|
|
}
|
|
}
|
|
}
|