Skip to content

Commit e260d04

Browse files
committed
add test case
1 parent d6215f2 commit e260d04

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed

Test/src/FormatStyle_unitest.cpp

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,72 @@ if a
189189
or c then
190190
191191
end
192+
)",
193+
style));
194+
style.continuation_indent.SetAll(4);
195+
style.continuation_indent.before_block = 8;
196+
EXPECT_TRUE(TestHelper::TestFormatted(
197+
R"(
198+
if a
199+
or c then
200+
201+
end
202+
local t = a
203+
+ c
204+
)",
205+
R"(
206+
if a
207+
or c then
208+
209+
end
210+
local t = a
211+
+ c
212+
)",
213+
style));
214+
style.continuation_indent.SetAll(4);
215+
style.continuation_indent.in_expr = 8;
216+
EXPECT_TRUE(TestHelper::TestFormatted(
217+
R"(
218+
if a
219+
or c then
220+
221+
end
222+
local t = a
223+
+ c
224+
)",
225+
R"(
226+
if a
227+
or c then
228+
229+
end
230+
local t = a
231+
+ c
232+
)",
233+
style));
234+
style.continuation_indent.SetAll(4);
235+
style.continuation_indent.in_table = 8;
236+
EXPECT_TRUE(TestHelper::TestFormatted(
237+
R"(
238+
if a
239+
or c then
240+
241+
end
242+
local t = {
243+
a = 1,
244+
dddddddd
245+
.ccccc
246+
}
247+
)",
248+
R"(
249+
if a
250+
or c then
251+
252+
end
253+
local t = {
254+
a = 1,
255+
dddddddd
256+
.ccccc
257+
}
192258
)",
193259
style));
194260
}
@@ -603,6 +669,30 @@ p "aaa"
603669
R"(
604670
local f = p{ a = 123 }
605671
p"aaa"
672+
)",
673+
style));
674+
style.space_before_function_call_single_arg.SetAll(FunctionSingleArgSpace::None);
675+
style.space_before_function_call_single_arg.string = FunctionSingleArgSpace::Keep;
676+
EXPECT_TRUE(TestHelper::TestFormatted(
677+
R"(
678+
p "aaa"
679+
p "aaa"
680+
)",
681+
R"(
682+
p "aaa"
683+
p "aaa"
684+
)",
685+
style));
686+
style.space_before_function_call_single_arg.SetAll(FunctionSingleArgSpace::None);
687+
style.space_before_function_call_single_arg.table = FunctionSingleArgSpace::Keep;
688+
EXPECT_TRUE(TestHelper::TestFormatted(
689+
R"(
690+
p { a = 123 }
691+
p { a = 123 }
692+
)",
693+
R"(
694+
p { a = 123 }
695+
p { a = 123 }
606696
)",
607697
style));
608698
}

0 commit comments

Comments
 (0)