Skip to content

Commit 8f46259

Browse files
eamonnmcmanusgoogle-java-format Team
authored andcommitted
Rewrite tests to use text blocks for improved readability.
PiperOrigin-RevId: 886963195
1 parent e573100 commit 8f46259

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,16 @@ public void testFormatAosp() throws Exception {
4949
"class A{void b(){while(true){weCanBeCertainThatThisWillEndUpGettingWrapped("
5050
+ "because, it, is, just, so, very, very, very, very, looong);}}}";
5151
String expectedOutput =
52-
Joiner.on("\n")
53-
.join(
54-
"class A {",
55-
" void b() {",
56-
" while (true) {",
57-
" weCanBeCertainThatThisWillEndUpGettingWrapped(",
58-
" because, it, is, just, so, very, very, very, very, looong);",
59-
" }",
60-
" }",
61-
"}",
62-
"");
52+
"""
53+
class A {
54+
void b() {
55+
while (true) {
56+
weCanBeCertainThatThisWillEndUpGettingWrapped(
57+
because, it, is, just, so, very, very, very, very, looong);
58+
}
59+
}
60+
}
61+
""";
6362

6463
Path tmpdir = testFolder.newFolder().toPath();
6564
Path path = tmpdir.resolve("A.java");
@@ -82,7 +81,7 @@ public void testFormatNonJavaFiles() throws Exception {
8281

8382
// should succeed because non-Java files are skipped
8483
assertThat(main.format("foo.go")).isEqualTo(0);
85-
assertThat(err.toString()).contains("Skipping non-Java file: " + "foo.go");
84+
assertThat(err.toString()).contains("Skipping non-Java file: foo.go");
8685

8786
// format still fails on missing files
8887
assertThat(main.format("Foo.java")).isEqualTo(1);
@@ -91,8 +90,8 @@ public void testFormatNonJavaFiles() throws Exception {
9190

9291
@Test
9392
public void testFormatStdinStdoutWithDashFlag() throws Exception {
94-
String input = "class Foo{\n" + "void f\n" + "() {\n" + "}\n" + "}\n";
95-
String expectedOutput = "class Foo {\n" + " void f() {}\n" + "}\n";
93+
String input = "class Foo{\nvoid f\n() {\n}\n}\n";
94+
String expectedOutput = "class Foo {\n void f() {}\n}\n";
9695

9796
InputStream in = new ByteArrayInputStream(input.getBytes(UTF_8));
9897
StringWriter out = new StringWriter();
@@ -110,8 +109,8 @@ public void testFormatStdinStdoutWithDashFlag() throws Exception {
110109

111110
@Test
112111
public void testFormatLengthUpToEOF() throws Exception {
113-
String input = "class Foo{\n" + "void f\n" + "() {\n" + "}\n" + "}\n\n\n\n\n\n";
114-
String expectedOutput = "class Foo {\n" + " void f() {}\n" + "}\n";
112+
String input = "class Foo{\nvoid f\n() {\n}\n}\n\n\n\n\n\n";
113+
String expectedOutput = "class Foo {\n void f() {}\n}\n";
115114

116115
Path tmpdir = testFolder.newFolder().toPath();
117116
Path path = tmpdir.resolve("Foo.java");

0 commit comments

Comments
 (0)