fix convert

This commit is contained in:
Looly
2020-11-12 00:35:49 +08:00
parent 17e91a6388
commit c646ba04ef
7 changed files with 111 additions and 145 deletions

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.annotation.Alias;
import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.bean.copier.ValueProvider;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.lang.Console;
import cn.hutool.core.map.MapUtil;
import lombok.Data;
import lombok.Getter;

View File

@@ -2,6 +2,7 @@ package cn.hutool.core.convert;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;
import org.junit.Assert;
import org.junit.Test;
@@ -253,4 +254,28 @@ public class ConvertTest {
private String cName;
private String version;
}
@Test
public void enumToIntTest(){
final Integer integer = Convert.toInt(BuildingType.CUO);
Assert.assertEquals(1, integer.intValue());
}
@Getter
public enum BuildingType {
PING(1, "平层"),
CUO(2, "错层"),
YUE(3, "跃层"),
FUSHI(4, "复式"),
KAIJIAN(5, "开间"),
OTHER(6, "其他");
private final int id;
private final String name;
BuildingType(int id, String name){
this.id = id;
this.name = name;
}
}
}

View File

@@ -164,6 +164,7 @@ public class StrUtilTest {
Assert.assertEquals(-1, StrUtil.lastIndexOfIgnoreCase("aabaabaa", "B", -1));
Assert.assertEquals(2, StrUtil.lastIndexOfIgnoreCase("aabaabaa", "", 2));
Assert.assertEquals(3, StrUtil.lastIndexOfIgnoreCase("abc", "", 9));
Assert.assertEquals(0, StrUtil.lastIndexOfIgnoreCase("AAAcsd", "aaa"));
}
@Test