Skip to content

Commit beacc08

Browse files
cushongoogle-java-format Team
authored and
google-java-format Team
committed
Explicitly test that reformatting after formatting and string wrapping is idempotent
There's some indirect coverage of this from line ending tests, but they don't exercise string wrapping. PiperOrigin-RevId: 695382884
1 parent 02b6ad1 commit beacc08

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

core/src/test/java/com/google/googlejavaformat/java/FormatterIntegrationTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,19 @@ public void format() {
144144
}
145145
}
146146

147+
@Test
148+
public void idempotent() {
149+
try {
150+
Formatter formatter = new Formatter();
151+
String formatted = formatter.formatSource(input);
152+
formatted = StringWrapper.wrap(formatted, formatter);
153+
String reformatted = formatter.formatSource(formatted);
154+
assertEquals("bad output for " + name, formatted, reformatted);
155+
} catch (FormatterException e) {
156+
fail(String.format("Formatter crashed on %s: %s", name, e.getMessage()));
157+
}
158+
}
159+
147160
@Test
148161
public void idempotentLF() {
149162
try {

0 commit comments

Comments
 (0)