Skip to content

Commit 7c56edb

Browse files
committed
test each operator seperated
1 parent d4e5d05 commit 7c56edb

File tree

1 file changed

+61
-17
lines changed

1 file changed

+61
-17
lines changed

test/split_unittest.cpp

+61-17
Original file line numberDiff line numberDiff line change
@@ -113,35 +113,68 @@ TEST(SplitTest, Viriable) {
113113
" ", "{", "'", "\\", "0", "'", "}", ";");
114114
}
115115

116-
TEST(SplitTest, Special) {
116+
TEST(SplitTest, Special_Slash) {
117117
// check /=
118118
runTest("max/=10;", 4, "max", "/=", "10", ";");
119+
// check /*
120+
runTest("/*multiline comments start", 6,
121+
"/*", "multiline", " ", "comments", " ", "start");
122+
// check //
123+
runTest("//comment", 2, "//", "comment");
124+
// check ///
125+
runTest("///comment", 2, "///", "comment");
126+
// check /(
127+
runTest("a/(b)", 5, "a", "/", "(", "b", ")");
128+
}
119129

130+
TEST(SplitTest, Special_Colon) {
120131
// check ::
121-
runTest("QTextEdit::ExtraSelection selection;", 6,
122-
"QTextEdit", "::", "ExtraSelection", " ", "selection", ";");
132+
runTest("a::b", 3, "a", "::", "b");
133+
}
134+
135+
TEST(SplitTest, Special_OpenParen) {
136+
// check ()
137+
runTest("func();", 4, "func", "(", ")", ";");
138+
}
123139

124-
// check (), )), ), );
125-
runTest("func(aa(), bb());", 12,
126-
"func", "(", "aa", "(", ")", ",", " ", "bb", "(", ")", ")", ";");
140+
TEST(SplitTest, Special_CloseParen) {
141+
// check ))
142+
runTest("func(aa())", 6, "func", "(", "aa", "(", ")", ")");
143+
// check ),
144+
runTest("func(aa(),bb)", 8, "func", "(", "aa", "(", ")", ",", "bb", ")");
145+
// check );
146+
runTest("func(aa);", 5, "func", "(", "aa", ")", ";");
147+
// check )<
148+
runTest("(a+b)<c", 7, "(", "a", "+", "b", ")", "<", "c");
149+
// check ):
150+
runTest("child():Parent()", 7, "child", "(", ")", ":", "Parent", "(", ")");
151+
// check ){
152+
runTest("func(){", 4, "func", "(", ")", "{");
153+
// check )*
154+
runTest("(a+b)+c", 7, "(", "a", "+", "b", ")", "+", "c");
155+
// check )/
156+
runTest("(a+b)-c", 7, "(", "a", "+", "b", ")", "-", "c");
157+
// check )*
158+
runTest("(a+b)*c", 7, "(", "a", "+", "b", ")", "*", "c");
159+
// check )/
160+
runTest("(a+b)/c", 7, "(", "a", "+", "b", ")", "/", "c");
161+
// check ).
162+
runTest("data().value", 5, "data", "(", ")", ".", "value");
163+
}
127164

165+
TEST(SplitTest, Special) {
128166
// check ++ and ++)
129167
runTest("func(i++)", 5, "func", "(", "i", "++", ")");
130168

131-
// check <<, )<, <" and ";
169+
// check <<, <" and ";
132170
runTest("qWarning()<<\"hello world\";", 10, "qWarning", "(", ")", "<<",
133171
"\"", "hello", " ", "world", "\"", ";");
134172

135-
// check ):, ){;
136-
runTest("LineNumberArea(CodeEditor*editor):QWidget(editor){", 12,
137-
"LineNumberArea", "(", "CodeEditor", "*", "editor", ")", ":",
138-
"QWidget", "(", "editor", ")", "{");
139-
140173
// check ]= and =-
141174
runTest("mBookMarkList[i]=-1;", 8, "mBookMarkList", "[", "i", "]", "=",
142175
"-", "1", ";");
143176

144-
// check ') and )*
177+
// check ')
145178
runTest("intspace=width(QLatin1Char('9'))*digits;", 14,
146179
"intspace", "=", "width", "(", "QLatin1Char",
147180
"(", "'", "9", "'", ")", ")", "*", "digits", ";");
@@ -153,15 +186,26 @@ TEST(SplitTest, Special) {
153186
// check ==
154187
runTest("if(a==b)", 6, "if", "(", "a", "==", "b", ")");
155188

156-
// check /* and */
157-
runTest("int a;/*multiline comments*/", 9,
158-
"int", " ", "a", ";", "/*", "multiline", " ", "comments", "*/");
189+
// check */
190+
runTest("multiline comments end*/", 6,
191+
"multiline", " ", "comments", " ", "end", "*/");
159192

160-
// check -> and ).
193+
// check ->
161194
runTest("event->rect().bottom()", 9,
162195
"event", "->", "rect", "(", ")", ".", "bottom", "(", ")");
163196

164197
// check &&
165198
runTest("if(x&&y)", 6, "if", "(", "x", "&&", "y", ")");
166199

200+
// check ;/
201+
runTest("int a;//comment", 6, "int", " ", "a", ";", "//", "comment");
202+
203+
// check &,
204+
runTest("void updateLineNumberArea(const QRect &, int);", 14,
205+
"void", " ", "updateLineNumberArea", "(", "const", " ", "QRect", " ",
206+
"&", ",", " ", "int", ")", ";");
207+
208+
// check ];
209+
runTest("int mBookMarkList[BOOKMARKMAXCOUNT];", 7,
210+
"int", " ", "mBookMarkList", "[", "BOOKMARKMAXCOUNT", "]", ";");
167211
}

0 commit comments

Comments
 (0)