fix brief bug

This commit is contained in:
Looly
2021-07-19 00:36:32 +08:00
parent d8f393f7d9
commit 56e107ebda
3 changed files with 59 additions and 6 deletions

View File

@@ -482,6 +482,38 @@ public class StrUtilTest {
Assert.assertEquals(brief.length(), maxLength);
}
@Test
public void briefTest2() {
String str = "123";
int maxLength = 3;
String brief = StrUtil.brief(str, maxLength);
Assert.assertEquals("123", brief);
maxLength = 2;
brief = StrUtil.brief(str, maxLength);
Assert.assertEquals("1.", brief);
maxLength = 1;
brief = StrUtil.brief(str, maxLength);
Assert.assertEquals("1", brief);
}
@Test
public void briefTest3() {
String str = "123abc";
int maxLength = 3;
String brief = StrUtil.brief(str, maxLength);
Assert.assertEquals("1.c", brief);
maxLength = 2;
brief = StrUtil.brief(str, maxLength);
Assert.assertEquals("1.", brief);
maxLength = 1;
brief = StrUtil.brief(str, maxLength);
Assert.assertEquals("1", brief);
}
@Test
public void filterTest() {
final String filterNumber = StrUtil.filter("hutool678", CharUtil::isNumber);