测试完善 Kv.toAs

This commit is contained in:
2019-07-05 17:55:56 +08:00
parent 972fb387c7
commit ae32b3393d
2 changed files with 66 additions and 6 deletions

View File

@@ -176,7 +176,7 @@ public class RunTest<T> {
//@Test
public void kvTest() {
Map map = new HashMap<>();
/*Map map = new HashMap<>();
map.put("name", "xxxx");
map.put("age", 12);
@@ -186,7 +186,47 @@ public class RunTest<T> {
Kv kv = Kv.toKv(user, "name", "abxx=age");
System.out.println(user);
System.out.println(kv);
System.out.println(kv);*/
Class[] clazzs = {
int.class, long.class, short.class, byte.class,
Integer.class, Long.class, Short.class, Byte.class, float.class, Float.class,
String.class,
};
Object[] ks = new Object[]{"1", (int)1, (Integer)1, 1l, 1.0, 1f, 1.0d};
for (Object k : ks) {
System.out.println("--------------------------------------------");
for (Class v : clazzs) {
System.out.printf("%s -> %s = ", k.getClass().getSimpleName(), v.getSimpleName());
Object o = Kv.toAs(k, v);
switch (v.getSimpleName()) {
case "int":
System.out.println((int)o);break;
case "Integer":
System.out.println((Integer)o);break;
case "long":
System.out.println((long)o);break;
case "Long":
System.out.println((Long)o);break;
case "short":
System.out.println((short)o);break;
case "Short":
System.out.println((Short)o);break;
case "byte":
System.out.println((byte)o);break;
case "float":
System.out.println((float)o);break;
case "Float":
System.out.println((Float)o);break;
case "Byte":
System.out.println((Byte)o);break;
case "String":
System.out.println((String)o);break;
}
}
}
}
//@Test