diff options
Diffstat (limited to 'clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp')
| -rw-r--r-- | clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp index 5a7da5acce1..36105a24cba 100644 --- a/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp +++ b/clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp @@ -1,5 +1,6 @@ #include "ClangTidyOptions.h" #include "gtest/gtest.h" +#include "llvm/ADT/StringExtras.h" namespace clang { namespace tidy { @@ -66,6 +67,38 @@ TEST(ParseConfiguration, ValidConfiguration) { EXPECT_EQ("some.user", *Options->User); } +TEST(ParseConfiguration, MergeConfigurations) { + llvm::ErrorOr<ClangTidyOptions> Options1 = parseConfiguration(R"( + Checks: "check1,check2" + HeaderFilterRegex: "filter1" + AnalyzeTemporaryDtors: true + User: user1 + ExtraArgs: ['arg1', 'arg2'] + ExtraArgsBefore: ['arg-before1', 'arg-before2'] + )"); + ASSERT_TRUE(!!Options1); + llvm::ErrorOr<ClangTidyOptions> Options2 = parseConfiguration(R"( + Checks: "check3,check4" + HeaderFilterRegex: "filter2" + AnalyzeTemporaryDtors: false + User: user2 + ExtraArgs: ['arg3', 'arg4'] + ExtraArgsBefore: ['arg-before3', 'arg-before4'] + )"); + ASSERT_TRUE(!!Options2); + ClangTidyOptions Options = Options1->mergeWith(*Options2); + EXPECT_EQ("check1,check2,check3,check4", *Options.Checks); + EXPECT_EQ("filter2", *Options.HeaderFilterRegex); + EXPECT_FALSE(*Options.AnalyzeTemporaryDtors); + EXPECT_EQ("user2", *Options.User); + ASSERT_TRUE(Options.ExtraArgs.hasValue()); + EXPECT_EQ("arg1,arg2,arg3,arg4", llvm::join(Options.ExtraArgs->begin(), + Options.ExtraArgs->end(), ",")); + ASSERT_TRUE(Options.ExtraArgsBefore.hasValue()); + EXPECT_EQ("arg-before1,arg-before2,arg-before3,arg-before4", + llvm::join(Options.ExtraArgsBefore->begin(), + Options.ExtraArgsBefore->end(), ",")); +} } // namespace test } // namespace tidy } // namespace clang |

