Skip to content

Commit

Permalink
Explicitly test that reformatting after formatting and string wrappin…
Browse files Browse the repository at this point in the history
…g is idempotent

There's some indirect coverage of this from line ending tests, but they don't exercise string wrapping.

PiperOrigin-RevId: 695382884
  • Loading branch information
cushon authored and google-java-format Team committed Nov 11, 2024
1 parent 02b6ad1 commit beacc08
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,19 @@ public void format() {
}
}

@Test
public void idempotent() {
try {
Formatter formatter = new Formatter();
String formatted = formatter.formatSource(input);
formatted = StringWrapper.wrap(formatted, formatter);
String reformatted = formatter.formatSource(formatted);
assertEquals("bad output for " + name, formatted, reformatted);
} catch (FormatterException e) {
fail(String.format("Formatter crashed on %s: %s", name, e.getMessage()));
}
}

@Test
public void idempotentLF() {
try {
Expand Down

0 comments on commit beacc08

Please sign in to comment.