mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
add methods
This commit is contained in:
@@ -113,6 +113,12 @@ public class ConvertTest {
|
||||
Assert.assertEquals(Integer.valueOf(-1), aInt);
|
||||
}
|
||||
|
||||
@Test(expected = NumberFormatException.class)
|
||||
public void toIntOfExceptionTest(){
|
||||
final Integer d = Convert.convert(Integer.class, "d");
|
||||
Assert.assertNotNull(d);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toLongTest() {
|
||||
final String a = " 342324545435435";
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package cn.hutool.core.map;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.convert.ConvertException;
|
||||
import cn.hutool.core.lang.Opt;
|
||||
import cn.hutool.core.text.StrUtil;
|
||||
import lombok.Builder;
|
||||
@@ -217,9 +216,9 @@ public class MapUtilTest {
|
||||
Assert.assertEquals(Integer.valueOf(2), map.get("b"));
|
||||
}
|
||||
|
||||
@Test(expected = ConvertException.class)
|
||||
@Test(expected = NumberFormatException.class)
|
||||
public void getIntTest(){
|
||||
final Map<String, String> map = MapUtil.ofEntries(MapUtil.entry("a", "D"));
|
||||
final Map<String, String> map = MapUtil.ofEntries(MapUtil.entry("a", "d"));
|
||||
final Integer a = MapUtil.getInt(map, "a");
|
||||
Assert.assertNotNull(a);
|
||||
}
|
||||
|
@@ -434,4 +434,10 @@ public class NumberUtilTest {
|
||||
//noinspection ResultOfMethodCallIgnored
|
||||
NumberUtil.range(0, Integer.MIN_VALUE);
|
||||
}
|
||||
|
||||
@Test(expected = NumberFormatException.class)
|
||||
public void parseIntTest3() {
|
||||
int v1 = NumberUtil.parseInt("d");
|
||||
Assert.assertEquals(0, v1);
|
||||
}
|
||||
}
|
||||
|
@@ -14,7 +14,7 @@ import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ReUtilTest {
|
||||
final String content = "ZZZaaabbbccc中文1234";
|
||||
static final String content = "ZZZaaabbbccc中文1234";
|
||||
|
||||
@Test
|
||||
public void getTest() {
|
||||
@@ -144,6 +144,22 @@ public class ReUtilTest {
|
||||
Assert.assertEquals("我有个\\$符号\\{\\}", escape);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void escapeTest2(){
|
||||
final String str = "a[bbbc";
|
||||
final String re = "[";
|
||||
final String s = ReUtil.get(ReUtil.escape(re), str, 0);
|
||||
Assert.assertEquals("[", s);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void escapeTest3(){
|
||||
final String context = "{prefix}_";
|
||||
final String regex = "{prefix}_";
|
||||
final boolean b = ReUtil.isMatch(ReUtil.escape(regex), context);
|
||||
Assert.assertTrue(b);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getAllGroupsTest() {
|
||||
//转义给定字符串,为正则相关的特殊符号转义
|
||||
|
Reference in New Issue
Block a user