mirror of
https://github.com/TeaOSLab/EdgeAPI.git
synced 2025-12-15 23:26:35 +08:00
ip2region增加IP格式检查
This commit is contained in:
@@ -24,6 +24,29 @@ func TestIP2RegionLibrary_Lookup(t *testing.T) {
|
||||
logs.PrintAsJSON(result, t)
|
||||
}
|
||||
|
||||
func TestIP2RegionLibrary_Lookup_Valid_IP(t *testing.T) {
|
||||
library := &IP2RegionLibrary{}
|
||||
err := library.Load(Tea.Root + "/resources/ipdata/ip2region/ip2region.db")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
{
|
||||
result, err := library.Lookup("114.240.223")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
logs.PrintAsJSON(result, t)
|
||||
}
|
||||
{
|
||||
result, err := library.Lookup("abc")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
logs.PrintAsJSON(result, t)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func TestIP2RegionLibrary_Memory(t *testing.T) {
|
||||
library := &IP2RegionLibrary{}
|
||||
err := library.Load(Tea.Root + "/resources/ipdata/ip2region/ip2region.db")
|
||||
|
||||
Reference in New Issue
Block a user