update the test assert and optimize the bench tests

This commit is contained in:
lionsoul2014 2026-06-11 16:37:31 +08:00
parent e360f3d031
commit 7b320846c9
2 changed files with 3 additions and 9 deletions

View File

@ -339,13 +339,7 @@ func testBench() {
return return
} }
mip, err := xdb.IPMiddle(sip, eip) for _, ip := range [][]byte{sip, eip} {
if err != nil {
fmt.Printf("IPMiddle(%s,%s): %s", xdb.IP2String(sip), xdb.IP2String(eip), err)
return
}
for _, ip := range [][]byte{sip, mip, eip} {
sTime := time.Now() sTime := time.Now()
region, err := searcher.Search(ip) region, err := searcher.Search(ip)
if err != nil { if err != nil {

View File

@ -245,12 +245,12 @@ func TestConcurrentCall(t *testing.T) {
} }
if l := len(ipBytes); l == 4 { if l := len(ipBytes); l == 4 {
if region != "中国|广东省|深圳市|电信" { if region != "中国|广东省|深圳市|电信|CN" {
fmt.Print("Error: region not equals") fmt.Print("Error: region not equals")
break break
} }
} else { } else {
if region != "中国|广东省|深圳市|家庭宽带" { if region != "中国|广东省|深圳市|电信|CN" {
fmt.Print("Error: region not equals") fmt.Print("Error: region not equals")
break break
} }