Skip to content

Instantly share code, notes, and snippets.

@bufferings
Created March 23, 2021 14:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bufferings/0812634ec5c6b61a69aba7fdc7bb1433 to your computer and use it in GitHub Desktop.
Save bufferings/0812634ec5c6b61a69aba7fdc7bb1433 to your computer and use it in GitHub Desktop.
@Test
void testTextBlocks1() {
String html1 = "<html>\n" +
" <body>\n" +
" <p>Hello, world</p>\n" +
" </body>\n" +
"</html>\n";
String html2 = """
<html>
<body>
<p>Hello, world</p>
</body>
</html>
""";
assertEquals(html1, html2);
}
@Test
void testTextBlocks2() {
String query1 = "SELECT \"EMP_ID\", \"LAST_NAME\" FROM \"EMPLOYEE_TB\"\n" +
"WHERE \"CITY\" = 'INDIANAPOLIS'\n" +
"ORDER BY \"EMP_ID\", \"LAST_NAME\";\n";
String query2 = """
SELECT "EMP_ID", "LAST_NAME" FROM "EMPLOYEE_TB"
WHERE "CITY" = 'INDIANAPOLIS'
ORDER BY "EMP_ID", "LAST_NAME";
""";
assertEquals(query1, query2);
}
@Test
void testTextBlocks3() {
String source1 = """
public void print(MyClass object) {
System.out.println(Objects.toString(object));
}
""";
String source2 = """
public void print(%s object) {
System.out.println(Objects.toString(object));
}
""".formatted("MyClass");
assertEquals(source1, source2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment