-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTextBlocksTest.java
40 lines (30 loc) · 1.09 KB
/
TextBlocksTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.github.hubertwo.playground.java15.string;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
class TextBlocksTest {
/**
* {@see <a href="https://openjdk.java.net/jeps/378>More</a>}
*/
@Test
@DisplayName("Multiline text block")
void multilineTextBlock() {
String concatenatedString = "No more quote escaping \", \\n and concatenation needed!\n" +
"Hurray!";
var actualString = """
No more quote escaping ", \\n and concatenation needed!
Hurray!""";
assertThat(actualString).isEqualTo(concatenatedString);
}
@Test
@DisplayName("Do not add line breaks to result string")
void doNotAddLineBreaks() {
String expectedString = "This is one line of text.";
// Try to remove slashes at the end of lines.
String actualString = """
This is one line\
of\
text.""";
assertThat(actualString).isEqualTo(expectedString);
}
}