aboutsummaryrefslogtreecommitdiff
path: root/llvm/unittests/Support/CommandLineTest.cpp
diff options
context:
space:
mode:
authorChris Bieneman <beanz@apple.com>2015-01-26 22:50:47 +0000
committerChris Bieneman <beanz@apple.com>2015-01-26 22:50:47 +0000
commitc333e577fe476fb4f8f4ab3c0babdcc07f62a2be (patch)
treef5d0fc4d75ab04fc2668f308a59251f860e4deee /llvm/unittests/Support/CommandLineTest.cpp
parent1a63f5b624883e051fe7ab4b9dbaf89aeda9bf2e (diff)
downloadllvm-c333e577fe476fb4f8f4ab3c0babdcc07f62a2be.zip
llvm-c333e577fe476fb4f8f4ab3c0babdcc07f62a2be.tar.gz
llvm-c333e577fe476fb4f8f4ab3c0babdcc07f62a2be.tar.bz2
Pete Cooper suggested the new API should use ArrayRef instead of SmallVectorImpl. Also adding a test case.
llvm-svn: 227148
Diffstat (limited to 'llvm/unittests/Support/CommandLineTest.cpp')
-rw-r--r--llvm/unittests/Support/CommandLineTest.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp
index 4fa14e2..7505593 100644
--- a/llvm/unittests/Support/CommandLineTest.cpp
+++ b/llvm/unittests/Support/CommandLineTest.cpp
@@ -247,4 +247,28 @@ TEST(CommandLineTest, HideUnrelatedOptions) {
<< "Hid default option that should be visable.";
}
+cl::OptionCategory TestCategory2("Test Options set 2", "Description");
+
+TEST(CommandLineTest, HideUnrelatedOptionsMulti) {
+ cl::opt<int> TestOption1("test-option-1");
+ cl::opt<int> TestOption2("test-option-2", cl::cat(TestCategory));
+ cl::opt<int> TestOption3("test-option-3", cl::cat(TestCategory2));
+
+ cl::OptionCategory *VisibleCategories[] = {&TestCategory, &TestCategory2};
+
+ cl::HideUnrelatedOptions(makeArrayRef(VisibleCategories));
+
+ ASSERT_EQ(cl::ReallyHidden, TestOption1.getOptionHiddenFlag())
+ << "Failed to hide extra option.";
+ ASSERT_EQ(cl::NotHidden, TestOption2.getOptionHiddenFlag())
+ << "Hid extra option that should be visable.";
+ ASSERT_EQ(cl::NotHidden, TestOption3.getOptionHiddenFlag())
+ << "Hid extra option that should be visable.";
+
+ StringMap<cl::Option *> Map;
+ cl::getRegisteredOptions(Map);
+ ASSERT_EQ(cl::NotHidden, Map["help"]->getOptionHiddenFlag())
+ << "Hid default option that should be visable.";
+}
+
} // anonymous namespace