From ef543c835afd191056df77704d6243ebf6fe54c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E8=89=AF?= <841369634@qq.com> Date: Wed, 5 Jan 2022 15:36:02 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/cn/hutool/core/util/StrUtilTest.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/hutool-core/src/test/java/cn/hutool/core/util/StrUtilTest.java b/hutool-core/src/test/java/cn/hutool/core/util/StrUtilTest.java index 54d37836a..7c3bd2be8 100644 --- a/hutool-core/src/test/java/cn/hutool/core/util/StrUtilTest.java +++ b/hutool-core/src/test/java/cn/hutool/core/util/StrUtilTest.java @@ -562,8 +562,21 @@ public class StrUtilTest { @Test public void briefTest3() { String str = "123abc"; - int maxLength = 3; + + int maxLength = 6; String brief = StrUtil.brief(str, maxLength); + Assert.assertEquals(str, brief); + + maxLength = 5; + brief = StrUtil.brief(str, maxLength); + Assert.assertEquals("1...c", brief); + + maxLength = 4; + brief = StrUtil.brief(str, maxLength); + Assert.assertEquals("1..c", brief); + + maxLength = 3; + brief = StrUtil.brief(str, maxLength); Assert.assertEquals("1.c", brief); maxLength = 2;