mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix brief bug
This commit is contained in:
parent
e0e07c726f
commit
8bb47018e6
@ -3,7 +3,7 @@
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
## 5.3.9 (2020-06-17)
|
||||
## 5.3.9 (2020-06-23)
|
||||
|
||||
### 新特性
|
||||
* 【core 】 DateUtil增加formatChineseDate(pr#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)
|
||||
|
@ -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));
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user