Skip to content

Commit

Permalink
Add a test for trailing unicode escaped whitespace in text blocks
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 629785894
  • Loading branch information
cushon authored and google-java-format Team committed May 1, 2024
1 parent fdf4b29 commit bec248b
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,35 @@ public void textBlockTrailingWhitespace() throws Exception {
assertThat(actual).isEqualTo(expected);
}

// It would be neat if the formatter could remove the trailing whitespace here, but in general
// it preserves unicode escapes from the original text.
@Test
public void textBlockTrailingWhitespaceUnicodeEscape() throws Exception {
assumeTrue(Runtime.version().feature() >= 15);
// We want a unicode escape in the Java source being formatted, so it needs to be escaped
// in the string literal in this test.
String input =
lines(
"public class T {",
" String s =",
" \"\"\"",
" lorem\\u0020",
" ipsum",
" \"\"\";",
"}");
String expected =
lines(
"public class T {",
" String s =",
" \"\"\"",
" lorem\\u0020",
" ipsum",
" \"\"\";",
"}");
String actual = StringWrapper.wrap(100, input, new Formatter());
assertThat(actual).isEqualTo(expected);
}

@Test
public void textBlockSpaceTabMix() throws Exception {
assumeTrue(Runtime.version().feature() >= 15);
Expand Down

0 comments on commit bec248b

Please sign in to comment.