diff options
author | Chris Bieneman <beanz@apple.com> | 2015-01-27 22:21:06 +0000 |
---|---|---|
committer | Chris Bieneman <beanz@apple.com> | 2015-01-27 22:21:06 +0000 |
commit | 681693628770b4d69ca0ee69859ea97fd85f97e3 (patch) | |
tree | 546831cd0bcdff159e90e216b61d1186ee222765 /llvm/unittests/Support/CommandLineTest.cpp | |
parent | bfa3f9d82ff549fda10aaaf4cb7633dcbf9dcec6 (diff) | |
download | llvm-681693628770b4d69ca0ee69859ea97fd85f97e3.zip llvm-681693628770b4d69ca0ee69859ea97fd85f97e3.tar.gz llvm-681693628770b4d69ca0ee69859ea97fd85f97e3.tar.bz2 |
Re-landing changes to use ArrayRef instead of SmallVectorImpl, and new API test.
This contains the changes from r227148 & r227154, and also fixes to the test case to properly clean up the stack options.
llvm-svn: 227255
Diffstat (limited to 'llvm/unittests/Support/CommandLineTest.cpp')
-rw-r--r-- | llvm/unittests/Support/CommandLineTest.cpp | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/llvm/unittests/Support/CommandLineTest.cpp b/llvm/unittests/Support/CommandLineTest.cpp index 4fa14e2..f0ef020 100644 --- a/llvm/unittests/Support/CommandLineTest.cpp +++ b/llvm/unittests/Support/CommandLineTest.cpp @@ -231,8 +231,8 @@ TEST(CommandLineTest, AliasRequired) { } TEST(CommandLineTest, HideUnrelatedOptions) { - cl::opt<int> TestOption1("test-option-1"); - cl::opt<int> TestOption2("test-option-2", cl::cat(TestCategory)); + StackOption<int> TestOption1("hide-option-1"); + StackOption<int> TestOption2("hide-option-2", cl::cat(TestCategory)); cl::HideUnrelatedOptions(TestCategory); @@ -241,7 +241,32 @@ TEST(CommandLineTest, HideUnrelatedOptions) { ASSERT_EQ(cl::NotHidden, TestOption2.getOptionHiddenFlag()) << "Hid extra option that should be visable."; - StringMap<cl::Option*> Map; + StringMap<cl::Option *> Map; + cl::getRegisteredOptions(Map); + ASSERT_EQ(cl::NotHidden, Map["help"]->getOptionHiddenFlag()) + << "Hid default option that should be visable."; +} + +cl::OptionCategory TestCategory2("Test Options set 2", "Description"); + +TEST(CommandLineTest, HideUnrelatedOptionsMulti) { + StackOption<int> TestOption1("multi-hide-option-1"); + StackOption<int> TestOption2("multi-hide-option-2", cl::cat(TestCategory)); + StackOption<int> TestOption3("multi-hide-option-3", cl::cat(TestCategory2)); + + const 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."; |