diff options
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r-- | clang/unittests/Format/FormatTest.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp index b1fcd39a49a..dc20faf70c5 100644 --- a/clang/unittests/Format/FormatTest.cpp +++ b/clang/unittests/Format/FormatTest.cpp @@ -9877,6 +9877,79 @@ TEST_F(FormatTest, ConfigurableUseOfTab) { Tab); } +TEST_F(FormatTest, ZeroTabWidth) { + FormatStyle Tab = getLLVMStyleWithColumns(42); + Tab.IndentWidth = 8; + Tab.UseTab = FormatStyle::UT_Never; + Tab.TabWidth = 0; + EXPECT_EQ("void a(){\n" + " // line starts with '\t'\n" + "};", + format("void a(){\n" + "\t// line starts with '\t'\n" + "};", + Tab)); + + EXPECT_EQ("void a(){\n" + " // line starts with '\t'\n" + "};", + format("void a(){\n" + "\t\t// line starts with '\t'\n" + "};", + Tab)); + + Tab.UseTab = FormatStyle::UT_ForIndentation; + EXPECT_EQ("void a(){\n" + " // line starts with '\t'\n" + "};", + format("void a(){\n" + "\t// line starts with '\t'\n" + "};", + Tab)); + + EXPECT_EQ("void a(){\n" + " // line starts with '\t'\n" + "};", + format("void a(){\n" + "\t\t// line starts with '\t'\n" + "};", + Tab)); + + Tab.UseTab = FormatStyle::UT_ForContinuationAndIndentation; + EXPECT_EQ("void a(){\n" + " // line starts with '\t'\n" + "};", + format("void a(){\n" + "\t// line starts with '\t'\n" + "};", + Tab)); + + EXPECT_EQ("void a(){\n" + " // line starts with '\t'\n" + "};", + format("void a(){\n" + "\t\t// line starts with '\t'\n" + "};", + Tab)); + + Tab.UseTab = FormatStyle::UT_Always; + EXPECT_EQ("void a(){\n" + "// line starts with '\t'\n" + "};", + format("void a(){\n" + "\t// line starts with '\t'\n" + "};", + Tab)); + + EXPECT_EQ("void a(){\n" + "// line starts with '\t'\n" + "};", + format("void a(){\n" + "\t\t// line starts with '\t'\n" + "};", + Tab)); +} + TEST_F(FormatTest, CalculatesOriginalColumn) { EXPECT_EQ("\"qqqqqqqqqqqqqqqqqqqqqqqqqq\\\n" "q\"; /* some\n" |