1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package com.puppycrawl.tools.checkstyle.checks.coding;
21
22 import static com.google.common.truth.Truth.assertWithMessage;
23 import static com.puppycrawl.tools.checkstyle.checks.coding.TextBlockGoogleStyleFormattingCheck.MSG_CLOSE_QUOTES_ERROR;
24 import static com.puppycrawl.tools.checkstyle.checks.coding.TextBlockGoogleStyleFormattingCheck.MSG_OPEN_QUOTES_ERROR;
25 import static com.puppycrawl.tools.checkstyle.checks.coding.TextBlockGoogleStyleFormattingCheck.MSG_TEXT_BLOCK_CONTENT;
26 import static com.puppycrawl.tools.checkstyle.checks.coding.TextBlockGoogleStyleFormattingCheck.MSG_VERTICALLY_UNALIGNED;
27
28 import org.junit.jupiter.api.Test;
29
30 import com.puppycrawl.tools.checkstyle.AbstractModuleTestSupport;
31 import com.puppycrawl.tools.checkstyle.api.TokenTypes;
32
33 public class TextBlockGoogleStyleFormattingCheckTest extends AbstractModuleTestSupport {
34
35 @Override
36 public String getPackageLocation() {
37 return "com/puppycrawl/tools/checkstyle/checks/coding/textblockgooglestyleformatting";
38 }
39
40 @Test
41 public void testGetAcceptableTokens() {
42 final TextBlockGoogleStyleFormattingCheck check =
43 new TextBlockGoogleStyleFormattingCheck();
44
45 final int[] acceptableTokens = {TokenTypes.TEXT_BLOCK_LITERAL_BEGIN};
46 assertWithMessage("Expected empty array")
47 .that(check.getAcceptableTokens())
48 .isEqualTo(acceptableTokens);
49 }
50
51 @Test
52 public void testDefaultTextBlockFormat() throws Exception {
53 final String[] expected = {
54 "14:37: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
55 "14:40: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
56 "16:9: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
57 "26:33: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
58 "26:36: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
59 "28:17: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
60 "39:36: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
61 "39:39: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
62 "41:17: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
63 "45:17: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
64 "45:20: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
65 "48:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
66 "52:16: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
67 "52:19: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
68 "54:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
69 "60:32: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
70 "60:32: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
71 "68:42: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
72 "68:42: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
73 "75:16: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
74 "89:29: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
75 "89:32: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
76 "90:29: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
77 "102:17: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
78 "102:20: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
79 "104:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
80 "104:19: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
81 "106:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
82 };
83
84 verifyWithInlineConfigParser(
85 getPath("InputTextBlockGoogleStyleFormatting.java"), expected);
86 }
87
88 @Test
89 public void testDefaultTextBlockFormat1() throws Exception {
90 final String[] expected = {
91 "18:19: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
92 "18:22: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
93 "20:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
94 "20:18: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
95 "20:21: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
96 "22:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
97 "30:35: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
98 "30:35: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
99 "46:15: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
100 "51:15: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
101 "51:18: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
102 "53:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
103 };
104
105 verifyWithInlineConfigParser(
106 getPath("InputTextBlockGoogleStyleFormatting1.java"), expected);
107 }
108
109 @Test
110 public void testDefaultTextBlockFormat2() throws Exception {
111 final String[] expected = {
112 "13:37: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
113 "13:40: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
114 "14:14: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
115 "14:14: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
116 "22:32: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
117 "22:32: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
118 "29:33: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
119 "29:36: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
120 "30:38: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
121 "30:38: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
122 "39:34: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
123 "39:34: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
124 "46:36: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
125 "46:39: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
126 "47:31: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
127 "47:31: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
128 "55:17: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
129 "55:20: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
130 "57:42: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
131 "57:42: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
132 "63:16: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
133 "63:19: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
134 "64:32: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
135 "64:32: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
136 "74:32: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
137 "74:32: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
138 "82:42: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
139 "82:42: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
140 "89:16: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
141 "89:19: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
142 "90:41: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
143 "90:41: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
144 "98:41: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
145 "98:41: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
146 "105:24: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
147 "105:24: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
148 };
149
150 verifyWithInlineConfigParser(
151 getPath("InputTextBlockGoogleStyleFormatting2.java"), expected);
152 }
153
154 @Test
155 public void testDefaultTextBlockFormat3() throws Exception {
156 final String[] expected = {
157 "20:17: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
158 "20:20: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
159 "22:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
160 "22:19: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
161 "22:22: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
162 "23:24: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
163 "23:24: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
164 "25:26: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
165 "25:26: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
166 "37:19: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
167 "37:22: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
168 "38:24: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
169 "38:24: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
170 "38:29: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
171 "38:32: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
172 "39:26: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
173 "39:26: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
174 "47:35: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
175 "47:35: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
176 "56:24: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
177 "56:24: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
178 "63:27: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
179 "63:27: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
180 "70:15: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
181 "70:18: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
182 "71:22: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
183 "71:22: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
184 "80:22: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
185 "80:22: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
186 };
187
188 verifyWithInlineConfigParser(
189 getPath("InputTextBlockGoogleStyleFormatting3.java"), expected);
190 }
191
192 @Test
193 public void testDefaultTextBlockFormat4() throws Exception {
194 final String[] expected = {
195 "17:25: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
196 "27:29: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
197 "27:32: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
198 "28:36: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
199 "28:36: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
200 "28:51: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
201 "28:54: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
202 "30:17: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
203 "37:20: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
204 "37:23: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
205 "40:44: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
206 "40:44: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
207 "51:17: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
208 "51:20: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
209 "54:9: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
210 "64:16: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
211 "64:19: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
212 "67:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
213 "70:15: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
214 "70:18: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
215 "77:12: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
216 "83:16: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
217 "83:19: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
218 "86:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
219 "99:16: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
220 "99:19: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
221 "101:9: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
222 "103:12: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
223 "112:12: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
224 };
225 verifyWithInlineConfigParser(
226 getPath("InputTextBlockGoogleStyleFormatting4.java"), expected);
227 }
228
229 @Test
230 public void testDefaultTextBlockFormat5() throws Exception {
231 final String[] expected = {
232 "17:48: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
233 "17:45: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
234 "19:9: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
235 "26:44: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
236 "26:47: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
237 "28:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
238 "34:51: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
239 "34:54: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
240 "36:26: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
241 "42:24: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
242 "42:27: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
243 "46:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
244 "51:23: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
245 "51:26: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
246 "53:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
247 "58:20: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
248 "58:23: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
249 "60:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
250 "68:48: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
251 "68:51: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
252 "71:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
253 "81:28: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
254 "81:31: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
255 "83:9: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
256 "83:15: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
257 "83:18: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
258 "85:9: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
259 };
260
261 verifyWithInlineConfigParser(
262 getPath("InputTextBlockGoogleStyleFormatting5.java"),
263 expected);
264 }
265
266 @Test
267 public void testTextBlockGoogleStyleFormattingWithTabs() throws Exception {
268 final String[] expected = {
269 "15:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
270 "18:17: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
271 "25:24: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
272 "25:27: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
273 "28:33: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
274 "33:21: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
275 "41:66: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
276 "41:69: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
277 "44:65: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
278 };
279
280 verifyWithInlineConfigParser(
281 getPath("InputTextBlockGoogleStyleFormattingWithTabs.java"),
282 expected);
283 }
284
285 @Test
286 public void testTextBlockFormatNotVerticallyAligned() throws Exception {
287 final String[] expected = {
288 "28:17: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
289 "33:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
290 "39:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
291 "44:1: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
292 "51:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
293 "69:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
294 "99:13: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
295 "102:17: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
296 "111:12: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
297 };
298
299 verifyWithInlineConfigParser(
300 getPath("InputTextBlockGoogleStyleFormattingNotVerticallyAligned.java"),
301 expected);
302 }
303
304 @Test
305 public void testDefaultTextBlockFormatWithIf() throws Exception {
306 final String[] expected = {
307 "17:18: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
308 "17:21: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
309 "18:18: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
310 "25:13: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
311 "26:18: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
312 "26:18: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
313 "26:24: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
314 "26:27: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
315 "27:19: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
316 "27:19: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
317 "39:20: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
318 "39:23: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
319 "40:18: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
320 "40:18: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
321 "40:24: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
322 "40:27: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
323 "41:18: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
324 "41:18: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
325 "57:18: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
326 "57:21: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
327 "58:18: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
328 "58:24: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
329 "58:27: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
330 "59:18: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
331 "59:18: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
332 "59:24: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
333 "59:27: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
334 "60:18: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
335 "60:18: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
336 "72:19: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
337 "72:22: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
338 "81:38: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
339 "81:41: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
340 "82:20: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
341 "82:20: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
342 "73:20: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
343 "73:20: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
344 "90:33: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
345 "90:36: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
346 "91:18: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
347 "91:18: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
348 "99:22: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
349 "99:25: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
350 "100:18: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
351 "100:18: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
352 "108:21: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
353 "108:24: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
354 "109:19: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
355 "109:19: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
356 "110:22: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
357 "111:27: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
358 "111:27: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
359 };
360
361 verifyWithInlineConfigParser(
362 getPath("InputTextBlockGoogleStyleFormatting6.java"), expected);
363 }
364
365 @Test
366 public void testDefaultTextBlockFormatWithNewKeyword() throws Exception {
367 final String[] expected = {
368 "13:45: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
369 "13:42: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
370 "15:33: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
371 "23:31: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
372 "23:34: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
373 "25:25: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
374 "28:55: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
375 "28:58: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
376 "30:25: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
377 "39:70: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
378 "39:70: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
379 "49:21: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
380 "51:24: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
381 "64:36: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
382 "64:39: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
383 "66:17: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
384 "70:23: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
385 "70:26: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
386 "72:17: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
387 "79:25: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
388 "105:19: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
389 "107:21: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
390 };
391 verifyWithInlineConfigParser(
392 getPath("InputTextBlockGoogleStyleFormatting7.java"), expected);
393 }
394
395 @Test
396 public void testDefaultTextBlockFormatInCtor() throws Exception {
397 final String[] expected = {
398 "24:66: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
399 "24:66: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
400 "39:23: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
401 "39:26: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
402 "41:17: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
403 "46:20: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
404 "53:29: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
405 "55:14: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
406 };
407 verifyWithInlineConfigParser(
408 getPath("InputTextBlockGoogleStyleFormatting8.java"), expected);
409 }
410
411 @Test
412 public void testDefaultTextBlockFormatInAnnotations() throws Exception {
413 final String[] expected = {
414 "13:22: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
415 "13:25: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
416 "14:19: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
417 "14:19: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
418 "22:22: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
419 "22:25: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
420 "23:15: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
421 "23:15: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
422 "33:22: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
423 "33:25: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
424 "35:9: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
425 };
426 verifyWithInlineConfigParser(
427 getPath("InputTextBlockGoogleStyleFormatting9.java"), expected);
428 }
429
430 @Test
431 public void testDefaultTextBlockFormatIndentationOfContent() throws Exception {
432 final String[] expected = {
433 "13:16: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
434 "27:20: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
435 "49:20: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
436 "50:17: " + getCheckMessage(MSG_CLOSE_QUOTES_ERROR),
437 };
438 verifyWithInlineConfigParser(
439 getPath("InputTextBlockGoogleStyleFormatting10.java"), expected);
440 }
441
442 @Test
443 public void testDefaultTextBlockFormatAnnotations() throws Exception {
444 final String[] expected = {
445 "60:27: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
446 "60:30: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
447 "68:19: " + getCheckMessage(MSG_OPEN_QUOTES_ERROR),
448 "68:22: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
449 "70:1: " + getCheckMessage(MSG_VERTICALLY_UNALIGNED),
450 };
451 verifyWithInlineConfigParser(
452 getPath("InputTextBlockGoogleStyleFormattingAnnotations.java"), expected);
453 }
454
455 @Test
456 public void testDefaultTextBlockFormat6() throws Exception {
457 final String[] expected = {
458 "31:16: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
459 "48:20: " + getCheckMessage(MSG_TEXT_BLOCK_CONTENT),
460 };
461 verifyWithInlineConfigParser(
462 getPath("InputTextBlockGoogleStyleFormatting11.java"), expected);
463 }
464 }