1 // RUN: %check_clang_tidy %s bugprone-suspicious-missing-comma %t
2 
3 const char* Cartoons[] = {
4   "Bugs Bunny",
5   "Homer Simpson",
6   "Mickey Mouse",
7   "Bart Simpson",
8   "Charlie Brown"  // There is a missing comma here.
9   "Fred Flintstone",
10   "Popeye",
11 };
12 // CHECK-MESSAGES: :[[@LINE-4]]:3: warning: suspicious string literal, probably missing a comma [bugprone-suspicious-missing-comma]
13 
14 const wchar_t* Colors[] = {
15   L"Red", L"Yellow", L"Blue", L"Green", L"Purple", L"Rose", L"White", L"Black"
16 };
17 
18 // The following array should not trigger any warnings. There is more than 5
19 // elements, but they are all concatenated string literals.
20 const char* HttpCommands[] = {
21   "GET / HTTP/1.0\r\n"
22   "\r\n",
23 
24   "GET /index.html HTTP/1.0\r\n"
25   "\r\n",
26 
27   "GET /favicon.ico HTTP/1.0\r\n"
28   "header: dummy"
29   "\r\n",
30 
31   "GET /index.html-en HTTP/1.0\r\n"
32   "\r\n",
33 
34   "GET /index.html-fr HTTP/1.0\r\n"
35   "\r\n",
36 
37   "GET /index.html-es HTTP/1.0\r\n"
38   "\r\n",
39 };
40 
41 // This array is too small to trigger a warning.
42 const char* SmallArray[] = {
43   "a" "b", "c"
44 };
45 
46 // Parentheses should be enough to avoid warnings.
47 const char* ParentheseArray[] = {
48   ("a" "b"), "c",
49   ("d"
50    "e"
51    "f"),
52   "g", "h", "i", "j", "k", "l"
53 };
54 
55 // Indentation should be enough to avoid warnings.
56 const char* CorrectlyIndentedArray[] = {
57   "This is a long message "
58       "which is spanning over multiple lines."
59       "And this should be fine.",
60   "a", "b", "c", "d", "e", "f",
61   "g", "h", "i", "j", "k", "l"
62 };
63 
64 const char* IncorrectlyIndentedArray[] = {
65   "This is a long message "
66   "which is spanning over multiple lines."
67       "And this should be fine.",
68   "a", "b", "c", "d", "e", "f",
69   "g", "h", "i", "j", "k", "l"
70 };
71 // CHECK-MESSAGES: :[[@LINE-6]]:3: warning: suspicious string literal, probably missing a comma [bugprone-suspicious-missing-comma]
72 
73 const char* TooManyConcatenatedTokensArray[] = {
74   "Dummy line",
75   "Dummy line",
76   "a" "b" "c" "d" "e" "f",
77   "g" "h" "i" "j" "k" "l",
78   "Dummy line",
79   "Dummy line",
80   "Dummy line",
81   "Dummy line",
82 };
83