test: 增加单元测试提高代码覆盖率

This commit is contained in:
Argo Zhang 2025-11-21 11:18:37 +08:00
parent db50f7b0da
commit ca7fc93953
1 changed files with 5 additions and 2 deletions

View File

@ -97,12 +97,15 @@ public class SearcherTest
[Theory] [Theory]
[InlineData("58.251.255.255", "中国|广东省|深圳市|联通")] [InlineData("58.251.255.255", "中国|广东省|深圳市|联通")]
public void Search_UintIp_Ok(string ipStr, string expected) public void Search_Ip_Ok(string ipStr, string expected)
{ {
var fileSearcher = new Searcher(CachePolicy.File, _xdbPathV4); var fileSearcher = new Searcher(CachePolicy.File, _xdbPathV4);
var ipAddress = IPAddress.Parse(ipStr); var ipAddress = IPAddress.Parse(ipStr);
var region = fileSearcher.Search(ipAddress);
Assert.Equal(expected, region);
var ip = XDB.Util.IpAddressToUInt32(ipAddress); var ip = XDB.Util.IpAddressToUInt32(ipAddress);
var region = fileSearcher.Search(ip); region = fileSearcher.Search(ip);
Assert.Equal(expected, region); Assert.Equal(expected, region);
} }