diff options
author | Eric Liu <ioeric@google.com> | 2018-05-14 19:51:33 +0000 |
---|---|---|
committer | Eric Liu <ioeric@google.com> | 2018-05-14 19:51:33 +0000 |
commit | 9d92c027e89e877409ec0e65f700d3bbb14d139b (patch) | |
tree | c8ee5107479e4ff85afb8cd5738c63553ad178d4 /clang/unittests/Format/SortIncludesTest.cpp | |
parent | d9f28735117d8ff86b48f093f7b37cce4aac2fdb (diff) | |
download | bcm5719-llvm-9d92c027e89e877409ec0e65f700d3bbb14d139b.tar.gz bcm5719-llvm-9d92c027e89e877409ec0e65f700d3bbb14d139b.zip |
[clang-format] Move #include related style to libToolingCore
Summary: This will be shared by include insertion/deletion library.
Reviewers: ilya-biryukov
Reviewed By: ilya-biryukov
Subscribers: mgorny, klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D46758
llvm-svn: 332284
Diffstat (limited to 'clang/unittests/Format/SortIncludesTest.cpp')
-rw-r--r-- | clang/unittests/Format/SortIncludesTest.cpp | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/clang/unittests/Format/SortIncludesTest.cpp b/clang/unittests/Format/SortIncludesTest.cpp index 09fc0703d42..dde88003784 100644 --- a/clang/unittests/Format/SortIncludesTest.cpp +++ b/clang/unittests/Format/SortIncludesTest.cpp @@ -26,12 +26,12 @@ protected: std::string sort(StringRef Code, std::vector<tooling::Range> Ranges, StringRef FileName = "input.cc") { - auto Replaces = sortIncludes(Style, Code, Ranges, FileName); + auto Replaces = sortIncludes(FmtStyle, Code, Ranges, FileName); Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges); auto Sorted = applyAllReplacements(Code, Replaces); EXPECT_TRUE(static_cast<bool>(Sorted)); auto Result = applyAllReplacements( - *Sorted, reformat(Style, *Sorted, Ranges, FileName)); + *Sorted, reformat(FmtStyle, *Sorted, Ranges, FileName)); EXPECT_TRUE(static_cast<bool>(Result)); return *Result; } @@ -41,12 +41,12 @@ protected: } unsigned newCursor(llvm::StringRef Code, unsigned Cursor) { - sortIncludes(Style, Code, GetCodeRange(Code), "input.cpp", &Cursor); + sortIncludes(FmtStyle, Code, GetCodeRange(Code), "input.cpp", &Cursor); return Cursor; } - FormatStyle Style = getLLVMStyle(); - + FormatStyle FmtStyle = getLLVMStyle(); + tooling::IncludeStyle &Style = FmtStyle.IncludeStyle; }; TEST_F(SortIncludesTest, BasicSorting) { @@ -74,11 +74,11 @@ TEST_F(SortIncludesTest, NoReplacementsForValidIncludes) { "#include <d>\n" "#include <e>\n" "#include <f>\n"; - EXPECT_TRUE(sortIncludes(Style, Code, GetCodeRange(Code), "a.cc").empty()); + EXPECT_TRUE(sortIncludes(FmtStyle, Code, GetCodeRange(Code), "a.cc").empty()); } TEST_F(SortIncludesTest, SortedIncludesInMultipleBlocksAreMerged) { - Style.IncludeBlocks = FormatStyle::IBS_Merge; + Style.IncludeBlocks = tooling::IncludeStyle::IBS_Merge; EXPECT_EQ("#include \"a.h\"\n" "#include \"b.h\"\n" "#include \"c.h\"\n", @@ -88,7 +88,7 @@ TEST_F(SortIncludesTest, SortedIncludesInMultipleBlocksAreMerged) { "\n" "#include \"b.h\"\n")); - Style.IncludeBlocks = FormatStyle::IBS_Regroup; + Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup; EXPECT_EQ("#include \"a.h\"\n" "#include \"b.h\"\n" "#include \"c.h\"\n", @@ -119,7 +119,7 @@ TEST_F(SortIncludesTest, SupportClangFormatOff) { } TEST_F(SortIncludesTest, IncludeSortingCanBeDisabled) { - Style.SortIncludes = false; + FmtStyle.SortIncludes = false; EXPECT_EQ("#include \"a.h\"\n" "#include \"c.h\"\n" "#include \"b.h\"\n", @@ -182,7 +182,7 @@ TEST_F(SortIncludesTest, SortsLocallyInEachBlock) { } TEST_F(SortIncludesTest, SortsAllBlocksWhenMerging) { - Style.IncludeBlocks = FormatStyle::IBS_Merge; + Style.IncludeBlocks = tooling::IncludeStyle::IBS_Merge; EXPECT_EQ("#include \"a.h\"\n" "#include \"b.h\"\n" "#include \"c.h\"\n", @@ -202,7 +202,7 @@ TEST_F(SortIncludesTest, CommentsAlwaysSeparateGroups) { "// comment\n" "#include \"b.h\"\n")); - Style.IncludeBlocks = FormatStyle::IBS_Merge; + Style.IncludeBlocks = tooling::IncludeStyle::IBS_Merge; EXPECT_EQ("#include \"a.h\"\n" "#include \"c.h\"\n" "// comment\n" @@ -212,7 +212,7 @@ TEST_F(SortIncludesTest, CommentsAlwaysSeparateGroups) { "// comment\n" "#include \"b.h\"\n")); - Style.IncludeBlocks = FormatStyle::IBS_Regroup; + Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup; EXPECT_EQ("#include \"a.h\"\n" "#include \"c.h\"\n" "// comment\n" @@ -233,7 +233,7 @@ TEST_F(SortIncludesTest, HandlesAngledIncludesAsSeparateBlocks) { "#include \"c.h\"\n" "#include \"a.h\"\n")); - Style = getGoogleStyle(FormatStyle::LK_Cpp); + FmtStyle = getGoogleStyle(FormatStyle::LK_Cpp); EXPECT_EQ("#include <b.h>\n" "#include <d.h>\n" "#include \"a.h\"\n" @@ -245,7 +245,7 @@ TEST_F(SortIncludesTest, HandlesAngledIncludesAsSeparateBlocks) { } TEST_F(SortIncludesTest, RegroupsAngledIncludesInSeparateBlocks) { - Style.IncludeBlocks = FormatStyle::IBS_Regroup; + Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup; EXPECT_EQ("#include \"a.h\"\n" "#include \"c.h\"\n" "\n" @@ -345,7 +345,7 @@ TEST_F(SortIncludesTest, LeavesMainHeaderFirst) { TEST_F(SortIncludesTest, RecognizeMainHeaderInAllGroups) { Style.IncludeIsMainRegex = "([-_](test|unittest))?$"; - Style.IncludeBlocks = FormatStyle::IBS_Merge; + Style.IncludeBlocks = tooling::IncludeStyle::IBS_Merge; EXPECT_EQ("#include \"c.h\"\n" "#include \"a.h\"\n" @@ -359,7 +359,7 @@ TEST_F(SortIncludesTest, RecognizeMainHeaderInAllGroups) { TEST_F(SortIncludesTest, MainHeaderIsSeparatedWhenRegroupping) { Style.IncludeIsMainRegex = "([-_](test|unittest))?$"; - Style.IncludeBlocks = FormatStyle::IBS_Regroup; + Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup; EXPECT_EQ("#include \"a.h\"\n" "\n" @@ -417,7 +417,7 @@ TEST_F(SortIncludesTest, NegativePriorities) { TEST_F(SortIncludesTest, PriorityGroupsAreSeparatedWhenRegroupping) { Style.IncludeCategories = {{".*important_os_header.*", -1}, {".*", 1}}; - Style.IncludeBlocks = FormatStyle::IBS_Regroup; + Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup; EXPECT_EQ("#include \"important_os_header.h\"\n" "\n" @@ -467,7 +467,7 @@ TEST_F(SortIncludesTest, DeduplicateIncludes) { "#include <b>\n" "#include <c>\n")); - Style.IncludeBlocks = FormatStyle::IBS_Merge; + Style.IncludeBlocks = tooling::IncludeStyle::IBS_Merge; EXPECT_EQ("#include <a>\n" "#include <b>\n" "#include <c>\n", @@ -479,7 +479,7 @@ TEST_F(SortIncludesTest, DeduplicateIncludes) { "#include <b>\n" "#include <c>\n")); - Style.IncludeBlocks = FormatStyle::IBS_Regroup; + Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup; EXPECT_EQ("#include <a>\n" "#include <b>\n" "#include <c>\n", @@ -503,7 +503,7 @@ TEST_F(SortIncludesTest, SortAndDeduplicateIncludes) { "#include <c>\n" "#include <b>\n")); - Style.IncludeBlocks = FormatStyle::IBS_Merge; + Style.IncludeBlocks = tooling::IncludeStyle::IBS_Merge; EXPECT_EQ("#include <a>\n" "#include <b>\n" "#include <c>\n", @@ -515,7 +515,7 @@ TEST_F(SortIncludesTest, SortAndDeduplicateIncludes) { "#include <c>\n" "#include <b>\n")); - Style.IncludeBlocks = FormatStyle::IBS_Regroup; + Style.IncludeBlocks = tooling::IncludeStyle::IBS_Regroup; EXPECT_EQ("#include <a>\n" "#include <b>\n" "#include <c>\n", @@ -573,7 +573,7 @@ TEST_F(SortIncludesTest, ValidAffactedRangesAfterDeduplicatingIncludes) { "\n" " int x ;"; std::vector<tooling::Range> Ranges = {tooling::Range(0, 52)}; - auto Replaces = sortIncludes(Style, Code, Ranges, "input.cpp"); + auto Replaces = sortIncludes(FmtStyle, Code, Ranges, "input.cpp"); Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges); EXPECT_EQ(1u, Ranges.size()); EXPECT_EQ(0u, Ranges[0].getOffset()); |