fix brief bug

This commit is contained in:
Looly 2020-06-23 18:02:38 +08:00
parent e0e07c726f
commit 8bb47018e6
3 changed files with 12 additions and 4 deletions

View File

@ -3,7 +3,7 @@
-------------------------------------------------------------------------------------------------------------
## 5.3.9 (2020-06-17)
## 5.3.9 (2020-06-23)
### 新特性
* 【core 】 DateUtil增加formatChineseDatepr#932@Github
@ -11,6 +11,7 @@
### Bug修复
* 【core 】 修复NumberUtil.partValue有余数问题issue#I1KX66@Gitee
* 【core 】 修复BeanUtil.isEmpty不能忽略static字段问题issue#I1KZI6@Gitee
* 【core 】 修复StrUtil.brief长度问题pr#930@Github
-------------------------------------------------------------------------------------------------------------
## 5.3.8 (2020-06-16)

View File

@ -3312,11 +3312,11 @@ public class StrUtil {
if (null == str) {
return null;
}
if ((str.length() + 3) <= maxLength) {
if (str.length() <= maxLength) {
return str.toString();
}
int w = maxLength / 2;
int l = str.length();
int l = str.length() + 3;
final String str2 = str.toString();
return format("{}...{}", str2.substring(0, maxLength - w), str2.substring(l - w));

View File

@ -449,4 +449,11 @@ public class StrUtilTest {
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);
}
}