Skip to content

Commit 1722c41

Browse files
committed
完善单元选项得单元测试 进度60%
1 parent 9119bbd commit 1722c41

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

Test/src/FormatStyle_unitest.cpp

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,3 +424,110 @@ print(1, 2, 3)
424424
print(1, 2, 3)
425425
)", style));
426426
}
427+
428+
TEST(FormatByStyleOption, space_before_closure_open_parenthesis) {
429+
LuaStyle style;
430+
431+
style.space_before_closure_open_parenthesis = true;
432+
EXPECT_TRUE(TestHelper::TestFormatted(
433+
R"(
434+
local f = function ()
435+
end
436+
)",
437+
R"(
438+
local f = function ()
439+
end
440+
)", style));
441+
style.space_before_closure_open_parenthesis = false;
442+
EXPECT_TRUE(TestHelper::TestFormatted(
443+
R"(
444+
local f = function ()
445+
end
446+
)",
447+
R"(
448+
local f = function()
449+
end
450+
)", style));
451+
}
452+
453+
TEST(FormatByStyleOption, space_before_function_call_single_arg) {
454+
LuaStyle style;
455+
456+
style.space_before_function_call_single_arg = true;
457+
EXPECT_TRUE(TestHelper::TestFormatted(
458+
R"(
459+
local f = p { a = 123 }
460+
)",
461+
R"(
462+
local f = p { a = 123 }
463+
)", style));
464+
style.space_before_function_call_single_arg = false;
465+
EXPECT_TRUE(TestHelper::TestFormatted(
466+
R"(
467+
local f = p { a = 123 }
468+
)",
469+
R"(
470+
local f = p{ a = 123 }
471+
)", style));
472+
}
473+
474+
TEST(FormatByStyleOption, space_inside_function_call_parentheses) {
475+
LuaStyle style;
476+
477+
style.space_inside_function_call_parentheses = true;
478+
EXPECT_TRUE(TestHelper::TestFormatted(
479+
R"(
480+
p(1,2,3)
481+
p()
482+
)",
483+
R"(
484+
p( 1, 2, 3 )
485+
p()
486+
)", style));
487+
style.space_inside_function_call_parentheses = false;
488+
EXPECT_TRUE(TestHelper::TestFormatted(
489+
R"(
490+
p(1,2,3)
491+
p()
492+
)",
493+
R"(
494+
p(1, 2, 3)
495+
p()
496+
)", style));
497+
}
498+
499+
TEST(FormatByStyleOption, space_inside_function_param_list_parentheses) {
500+
LuaStyle style;
501+
502+
style.space_inside_function_param_list_parentheses = true;
503+
EXPECT_TRUE(TestHelper::TestFormatted(
504+
R"(
505+
function f()
506+
end
507+
function f2(a,b,c)
508+
end
509+
)",
510+
R"(
511+
function f()
512+
end
513+
514+
function f2( a, b, c )
515+
end
516+
)", style));
517+
style.space_inside_function_param_list_parentheses = false;
518+
EXPECT_TRUE(TestHelper::TestFormatted(
519+
R"(
520+
function f()
521+
end
522+
523+
function f2(a,b,c)
524+
end
525+
)",
526+
R"(
527+
function f()
528+
end
529+
530+
function f2(a, b, c)
531+
end
532+
)", style));
533+
}

0 commit comments

Comments
 (0)