- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringJava15MultiLineTest.java
More file actions
Latest commit
112 lines (92 loc) · 3.06 KB
/
Copy pathStringJava15MultiLineTest.java
File metadata and controls
112 lines (92 loc) · 3.06 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
packagebasics;
importorg.junit.jupiter.api.Assertions;
importorg.junit.jupiter.api.Test;
publicclassStringJava15MultiLineTest {
@Test
voidgivenAnOldStyleMultilineString_whenComparing_thenEqualsTextBlock() {
Stringexpected = "<html>\n"
+ "\n"
+ " <body>\n"
+ " <span>example text</span>\n"
+ " </body>\n"
+ "</html>";
Assertions.assertEquals(getBlockOfHtml(), expected);
}
@Test
voidgivenAnOldStyleString_whenComparing_thenEqualsTextBlock() {
Stringexpected = "<html>\n\n <body>\n <span>example text</span>\n </body>\n</html>";
Assertions.assertEquals(getBlockOfHtml(), expected);
}
@Test
voidgivenAnIndentedString_thenMatchesIndentedOldStyle() {
Assertions.assertEquals(getNonStandardIndent(), " Indent\n");
}
@Test
voidtext_block_escape_test() {
Assertions.assertEquals(getTextWithEscapes(), "\"fun\" with\n" +
"whitespace\n" +
"and other escapes \"\"\"\n");
}
@Test
voidgivenATextWithCarriageReturns_thenItContainsBoth() {
Assertions.assertEquals(getTextWithCarriageReturns(), "separated with\r\n" +
"carriage returns");
}
@Test
voidgivenAStringWithEscapedNewLines_thenTheResultHasNoNewLines() {
Stringexpected = "This is a long test which looks to have a newline but actually does not";
Assertions.assertEquals(getIgnoredNewLines(), expected);
}
@Test
voidgivenAStringWithEscapesSpaces_thenTheResultHasLinesEndingWithSpaces() {
Stringexpected = "line 1\nline 2 \n";
Assertions.assertEquals(getEscapedSpaces(), expected);
}
@Test
voidformatting_multiLine_test() {
Stringexpected = "Some parameter: end\nText\n";
Assertions.assertEquals(getFormattedText("end"), expected);
}
publicStringgetBlockOfHtml() {
return"""
<html>
<body>
<span>example text</span>
</body>
</html>""";
}
publicStringgetNonStandardIndent() {
return"""
Indent
""";
}
publicStringgetTextWithEscapes() {
return"""
"fun" with
whitespace
and other escapes \"""
""";
}
publicStringgetTextWithCarriageReturns() {
return"""
separated with\r
carriage returns""";
}
publicStringgetIgnoredNewLines() {
return"""
This is a long test which looks to \
have a newline but actually does not""";
}
publicStringgetEscapedSpaces() {
return"""
line 1
line 2 \s
""";
}
publicStringgetFormattedText(Stringparameter) {
return"""
Some parameter: %s
Text
""".formatted(parameter);
}
}