summaryrefslogtreecommitdiff
path: root/unittests/Option
diff options
context:
space:
mode:
authorRui Ueyama <ruiu@google.com>2013-08-28 20:04:31 +0000
committerRui Ueyama <ruiu@google.com>2013-08-28 20:04:31 +0000
commit2957273b888dabe8be8e2fa5ac691e39879685c4 (patch)
tree275ac46fd8d334c7ae15c3391cb95c76e22f3e74 /unittests/Option
parent435798e96a64738b55a01055dde1bc9a88a15191 (diff)
downloadllvm-2957273b888dabe8be8e2fa5ac691e39879685c4.tar.gz
llvm-2957273b888dabe8be8e2fa5ac691e39879685c4.tar.bz2
llvm-2957273b888dabe8be8e2fa5ac691e39879685c4.tar.xz
Option parsing: support case-insensitive option matching.
Re-submitting r189416 with fix for Windows build on where strcasecmp is not defined. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189501 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Option')
-rw-r--r--unittests/Option/OptionParsingTest.cpp26
1 files changed, 23 insertions, 3 deletions
diff --git a/unittests/Option/OptionParsingTest.cpp b/unittests/Option/OptionParsingTest.cpp
index 86286d11bd..11d6d1e87e 100644
--- a/unittests/Option/OptionParsingTest.cpp
+++ b/unittests/Option/OptionParsingTest.cpp
@@ -20,7 +20,7 @@ using namespace llvm::opt;
enum ID {
OPT_INVALID = 0, // This is not an option ID.
#define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \
- HELPTEXT, METAVAR) OPT_##ID,
+ HELPTEXT, METAVAR) OPT_##ID,
#include "Opts.inc"
LastOption
#undef OPTION
@@ -48,8 +48,8 @@ static const OptTable::Info InfoTable[] = {
namespace {
class TestOptTable : public OptTable {
public:
- TestOptTable()
- : OptTable(InfoTable, array_lengthof(InfoTable)) {}
+ TestOptTable(bool IgnoreCase = false)
+ : OptTable(InfoTable, array_lengthof(InfoTable), IgnoreCase) {}
};
}
@@ -157,6 +157,26 @@ TEST(Option, AliasArgs) {
EXPECT_EQ(AL->getAllArgValues(OPT_B)[1], "bar");
}
+TEST(Option, IgnoreCase) {
+ TestOptTable T(true);
+ unsigned MAI, MAC;
+
+ const char *MyArgs[] = { "-a", "-joo" };
+ OwningPtr<InputArgList> AL(T.ParseArgs(MyArgs, array_endof(MyArgs), MAI, MAC));
+ EXPECT_TRUE(AL->hasArg(OPT_A));
+ EXPECT_TRUE(AL->hasArg(OPT_B));
+}
+
+TEST(Option, DoNotIgnoreCase) {
+ TestOptTable T;
+ unsigned MAI, MAC;
+
+ const char *MyArgs[] = { "-a", "-joo" };
+ OwningPtr<InputArgList> AL(T.ParseArgs(MyArgs, array_endof(MyArgs), MAI, MAC));
+ EXPECT_FALSE(AL->hasArg(OPT_A));
+ EXPECT_FALSE(AL->hasArg(OPT_B));
+}
+
TEST(Option, SlurpEmpty) {
TestOptTable T;
unsigned MAI, MAC;