summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/unittests/cpp11-migrate
diff options
context:
space:
mode:
Diffstat (limited to 'clang-tools-extra/unittests/cpp11-migrate')
-rw-r--r--clang-tools-extra/unittests/cpp11-migrate/CMakeLists.txt3
-rw-r--r--clang-tools-extra/unittests/cpp11-migrate/IncludeExcludeTest.cpp29
-rw-r--r--clang-tools-extra/unittests/cpp11-migrate/Makefile2
3 files changed, 32 insertions, 2 deletions
diff --git a/clang-tools-extra/unittests/cpp11-migrate/CMakeLists.txt b/clang-tools-extra/unittests/cpp11-migrate/CMakeLists.txt
index 7756b6f9738..77b81585d65 100644
--- a/clang-tools-extra/unittests/cpp11-migrate/CMakeLists.txt
+++ b/clang-tools-extra/unittests/cpp11-migrate/CMakeLists.txt
@@ -7,7 +7,8 @@ get_filename_component(CPP11_MIGRATE_SOURCE_DIR
include_directories(${CPP11_MIGRATE_SOURCE_DIR})
add_extra_unittest(Cpp11MigrateTests
- TransformTest.cpp)
+ TransformTest.cpp
+ IncludeExcludeTest.cpp)
target_link_libraries(Cpp11MigrateTests
migrateCore
diff --git a/clang-tools-extra/unittests/cpp11-migrate/IncludeExcludeTest.cpp b/clang-tools-extra/unittests/cpp11-migrate/IncludeExcludeTest.cpp
new file mode 100644
index 00000000000..a4b270b2ce2
--- /dev/null
+++ b/clang-tools-extra/unittests/cpp11-migrate/IncludeExcludeTest.cpp
@@ -0,0 +1,29 @@
+#include "Core/IncludeExcludeInfo.h"
+#include "gtest/gtest.h"
+
+IncludeExcludeInfo IEManager(/*include=*/ "a,b/b2,c/c2/c3",
+ /*exclude=*/ "a/af.cpp,a/a2,b/b2/b2f.cpp,c/c2/c3");
+
+TEST(IncludeExcludeTest, NoMatchOnIncludeList) {
+ // If the file does not appear on the include list then it is not safe to
+ // transform. Files are not safe to transform by default.
+ EXPECT_FALSE(IEManager.isFileIncluded("f.cpp"));
+ EXPECT_FALSE(IEManager.isFileIncluded("b/dir/f.cpp"));
+}
+
+TEST(IncludeExcludeTest, MatchOnIncludeList) {
+ // If the file appears on only the include list then it is safe to transform.
+ EXPECT_TRUE(IEManager.isFileIncluded("a/f.cpp"));
+ EXPECT_TRUE(IEManager.isFileIncluded("a/dir/f.cpp"));
+ EXPECT_TRUE(IEManager.isFileIncluded("b/b2/f.cpp"));
+}
+
+TEST(IncludeExcludeTest, MatchOnBothLists) {
+ // If the file appears on both the include or exclude list then it is not
+ // safe to transform.
+ EXPECT_FALSE(IEManager.isFileIncluded("a/af.cpp"));
+ EXPECT_FALSE(IEManager.isFileIncluded("a/a2/f.cpp"));
+ EXPECT_FALSE(IEManager.isFileIncluded("a/a2/dir/f.cpp"));
+ EXPECT_FALSE(IEManager.isFileIncluded("b/b2/b2f.cpp"));
+ EXPECT_FALSE(IEManager.isFileIncluded("c/c2/c3/f.cpp"));
+}
diff --git a/clang-tools-extra/unittests/cpp11-migrate/Makefile b/clang-tools-extra/unittests/cpp11-migrate/Makefile
index 84fed3b4a82..4779c49cf34 100644
--- a/clang-tools-extra/unittests/cpp11-migrate/Makefile
+++ b/clang-tools-extra/unittests/cpp11-migrate/Makefile
@@ -16,7 +16,7 @@ USEDLIBS = clangTooling.a clangFrontend.a clangSerialization.a clangDriver.a \
clangRewriteFrontend.a clangRewriteCore.a clangParse.a \
clangSema.a clangAnalysis.a \
clangAST.a clangASTMatchers.a clangEdit.a clangLex.a clangBasic.a \
- migrateCore.a
+ migrateCore.a
include $(CLANG_LEVEL)/Makefile
MAKEFILE_UNITTEST_NO_INCLUDE_COMMON := 1
OpenPOWER on IntegriCloud