diff options
author | Edwin Vane <edwin.vane@intel.com> | 2013-04-15 14:50:35 +0000 |
---|---|---|
committer | Edwin Vane <edwin.vane@intel.com> | 2013-04-15 14:50:35 +0000 |
commit | 83a38b5c15a6b58a039674cc01c0c15852cde595 (patch) | |
tree | aeb102375c3944fe50af8956f137766e53c90f46 /clang-tools-extra/unittests/cpp11-migrate/IncludeExcludeTest.cpp | |
parent | 41cb64f4fa9e9976508faf56a788178bc826e64a (diff) | |
download | bcm5719-llvm-83a38b5c15a6b58a039674cc01c0c15852cde595.tar.gz bcm5719-llvm-83a38b5c15a6b58a039674cc01c0c15852cde595.zip |
Adding support for -include/-exclude to cpp11-migrate
This commit adds initial support for the -include/-exclude options which are
both currently marked as hidden. This support is the first step toward
supporting transformations in headers included from source files.
Added unittests to test include/exclude support.
Author: Jack Yang <jack.yang@intel.com>
llvm-svn: 179528
Diffstat (limited to 'clang-tools-extra/unittests/cpp11-migrate/IncludeExcludeTest.cpp')
-rw-r--r-- | clang-tools-extra/unittests/cpp11-migrate/IncludeExcludeTest.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
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")); +} |