use the unit test instead

This commit is contained in:
lion 2025-09-10 22:54:34 +08:00
parent 23b3c3bc9b
commit 629f509c6f
2 changed files with 21 additions and 30 deletions

View File

@ -18,28 +18,6 @@ public class UtilTest {
public static final Log log = Log.getLogger(UtilTest.class);
public static void testIndexPolicy() {
final String[] inputs = {"vector", "btree", "VecTor", "BTree", "abc"};
for (String str : inputs) {
try {
int policy = IndexPolicy.parse(str);
log.infof("parse(%s)=%d", str, policy);
} catch (Exception e) {
log.errorf("parse index policy `%s`: %s", str, e.getMessage());
}
}
}
public static void testIPUtil() {
final String ipStr = "1.2.3.4";
try {
long ip = Util.checkIP(ipStr);
log.infof("checkIP(%s)=%d, validate: %s, long2ip(%d)=%s", ipStr, ip, ip == 16909060 ? "true" : "false", ip, Util.long2ip(ip));
} catch (Exception e) {
log.errorf("failed to check ip `%s`: %s", ipStr, e.getMessage());
}
}
public static void testSegment() {
final String[] t_segs = {
"1.1.0.0|1.3.3.24|中国|广东|深圳|电信",
@ -85,14 +63,6 @@ public class UtilTest {
}
public static void main(String[] args) {
System.out.println("+-- testing index policy");
testIndexPolicy();
System.out.println();
System.out.println("+-- testing ip util");
testIPUtil();
System.out.println();
System.out.println("+-- testing segments");
testSegment();
System.out.println();

View File

@ -0,0 +1,21 @@
package org.lionsoul.ip2region.xdb;
import org.junit.Test;
public class IndexPolicyTest {
private static final Log log = Log.getLogger(IndexPolicyTest.class).setLevel(Log.DEBUG);
@Test
public void testParse() {
final String[] inputs = {"vector", "btree", "VecTor", "BTree", "abc"};
for (String str : inputs) {
try {
int policy = IndexPolicy.parse(str);
log.infof("parse(%s)=%d", str, policy);
} catch (Exception e) {
log.errorf("parse index policy `%s`: %s", str, e.getMessage());
}
}
}
}