mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix brief bug
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
## 5.3.9 (2020-06-17)
|
## 5.3.9 (2020-06-23)
|
||||||
|
|
||||||
### 新特性
|
### 新特性
|
||||||
* 【core 】 DateUtil增加formatChineseDate(pr#932@Github)
|
* 【core 】 DateUtil增加formatChineseDate(pr#932@Github)
|
||||||
@@ -11,6 +11,7 @@
|
|||||||
### Bug修复
|
### Bug修复
|
||||||
* 【core 】 修复NumberUtil.partValue有余数问题(issue#I1KX66@Gitee)
|
* 【core 】 修复NumberUtil.partValue有余数问题(issue#I1KX66@Gitee)
|
||||||
* 【core 】 修复BeanUtil.isEmpty不能忽略static字段问题(issue#I1KZI6@Gitee)
|
* 【core 】 修复BeanUtil.isEmpty不能忽略static字段问题(issue#I1KZI6@Gitee)
|
||||||
|
* 【core 】 修复StrUtil.brief长度问题(pr#930@Github)
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
## 5.3.8 (2020-06-16)
|
## 5.3.8 (2020-06-16)
|
||||||
|
@@ -3312,11 +3312,11 @@ public class StrUtil {
|
|||||||
if (null == str) {
|
if (null == str) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ((str.length() + 3) <= maxLength) {
|
if (str.length() <= maxLength) {
|
||||||
return str.toString();
|
return str.toString();
|
||||||
}
|
}
|
||||||
int w = maxLength / 2;
|
int w = maxLength / 2;
|
||||||
int l = str.length();
|
int l = str.length() + 3;
|
||||||
|
|
||||||
final String str2 = str.toString();
|
final String str2 = str.toString();
|
||||||
return format("{}...{}", str2.substring(0, maxLength - w), str2.substring(l - w));
|
return format("{}...{}", str2.substring(0, maxLength - w), str2.substring(l - w));
|
||||||
|
@@ -448,5 +448,12 @@ public class StrUtilTest {
|
|||||||
String[] results2 = StrUtil.subBetweenAll(src2,"/*","*/");
|
String[] results2 = StrUtil.subBetweenAll(src2,"/*","*/");
|
||||||
Assert.assertEquals(0, results2.length);
|
Assert.assertEquals(0, results2.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void briefTest(){
|
||||||
|
String str = RandomUtil.randomString(1000);
|
||||||
|
int maxLength = RandomUtil.randomInt(1000);
|
||||||
|
String brief = StrUtil.brief(str, maxLength);
|
||||||
|
Assert.assertEquals(brief.length(), maxLength);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user