Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/main/java/org/apache/commons/text/FormattableUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ public static Formatter append(final CharSequence seq, final Formatter formatter
for (int i = buf.length(); i < width; i++) {
buf.insert(leftJustify ? i : 0, padChar);
}
formatter.format(buf.toString());
return formatter;
return formatter.format(SIMPLEST_FORMAT, buf.toString());
}

/**
Expand Down
10 changes: 10 additions & 0 deletions src/test/java/org/apache/commons/text/FormattableUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,16 @@ void testIllegalEllipsisWith7Args() {
() -> FormattableUtils.append("foo", createFormatter(), 0, 0, precisionLessThanEllipsisLength, '}', ellipsis));
}

@Test
void testPercentLiteral() {
assertEquals("100% done", FormattableUtils.append("100% done", new Formatter(), 0, -1, -1).toString());
}

@Test
void testPercentLiteralX2() {
assertEquals("50% off 100% items", FormattableUtils.append("50% off 100% items", new Formatter(), 0, -1, -1).toString());
}

@Test
void testPublicConstructorExists() {
new FormattableUtils();
Expand Down
Loading