diff --git a/src/test/java/org/apache/commons/lang3/StringUtilsAbbreviateTest.java b/src/test/java/org/apache/commons/lang3/StringUtilsAbbreviateTest.java index 49a188d06de..ca9033c5bc8 100644 --- a/src/test/java/org/apache/commons/lang3/StringUtilsAbbreviateTest.java +++ b/src/test/java/org/apache/commons/lang3/StringUtilsAbbreviateTest.java @@ -101,6 +101,9 @@ void testAbbreviate_StringIntInt() { assertAbbreviateWithOffset("...ijklmno", 15, 10); assertAbbreviateWithOffset("...ijklmno", 16, 10); assertAbbreviateWithOffset("...ijklmno", Integer.MAX_VALUE, 10); + + // abbreviating a shorter string allows maxWidth < 7 + assertEquals("...efg", StringUtils.abbreviate("abcdefg", 5, 6)); } @Test @@ -157,6 +160,10 @@ void testAbbreviate_StringStringIntInt() { assertAbbreviateWithAbbrevMarkerAndOffset("999ijklmno", "999", 15, 10); assertAbbreviateWithAbbrevMarkerAndOffset("_ghijklmno", "_", 16, 10); assertAbbreviateWithAbbrevMarkerAndOffset("+ghijklmno", "+", Integer.MAX_VALUE, 10); + + // abbreviating a shorter string allows maxWidth < abbrevMarker.length * 2 + 1 + assertEquals("..de", StringUtils.abbreviate("abcde", "..", 4, 4)); + assertEquals("....fg", StringUtils.abbreviate("abcdefg", "....", 5, 6)); } // Fixed LANG-1463