You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2011/06/05 07:40:52 UTC
svn commit: r1131852 - in /incubator/mesos/trunk/src: configuration.cpp
tests/test_configuration.cpp
Author: benh
Date: Sun Jun 5 05:40:51 2011
New Revision: 1131852
URL: http://svn.apache.org/viewvc?rev=1131852&view=rev
Log:
Fixed bug and wrote test case for it (forgot to change key to lowercase). Added another testcase for a known bug that has to be fixed ('-negative -25' is parsed as -negative 1).
Modified:
incubator/mesos/trunk/src/configuration.cpp
incubator/mesos/trunk/src/tests/test_configuration.cpp
Modified: incubator/mesos/trunk/src/configuration.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/configuration.cpp?rev=1131852&r1=1131851&r2=1131852&view=diff
==============================================================================
--- incubator/mesos/trunk/src/configuration.cpp (original)
+++ incubator/mesos/trunk/src/configuration.cpp Sun Jun 5 05:40:51 2011
@@ -103,13 +103,14 @@ void Configuration::loadCommandLine(int
if (args[i].find("--", 0) == 0) {
// handle --blah=25 and --blah
size_t eq = args[i].find_first_of("=");
- if (eq == string::npos) {
+ if (eq == string::npos) { // handle no value case
key = args[i].substr(2);
std::transform(key.begin(), key.end(), key.begin(), ::tolower);
val = "1";
set = true;
- } else {
- key = args[i].substr(2, eq-2);
+ } else { // handle value case
+ key = args[i].substr(2, eq-2);
+ std::transform(key.begin(), key.end(), key.begin(), ::tolower);
val = args[i].substr(eq+1);
set = true;
}
Modified: incubator/mesos/trunk/src/tests/test_configuration.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/tests/test_configuration.cpp?rev=1131852&r1=1131851&r2=1131852&view=diff
==============================================================================
--- incubator/mesos/trunk/src/tests/test_configuration.cpp (original)
+++ incubator/mesos/trunk/src/tests/test_configuration.cpp Sun Jun 5 05:40:51 2011
@@ -31,7 +31,7 @@ TEST(ConfigurationTest, Environment)
TEST(ConfigurationTest, CommandLine)
{
- const int ARGC = 6;
+ const int ARGC = 9;
char* argv[ARGC];
argv[0] = (char*) "./filename";
argv[1] = (char*) "--test1=text1";
@@ -39,6 +39,9 @@ TEST(ConfigurationTest, CommandLine)
argv[3] = (char*) "-test3";
argv[4] = (char*) "text2";
argv[5] = (char*) "-test4";
+ argv[6] = (char*) "-negative";
+ argv[7] = (char*) "-25";
+ argv[8] = (char*) "--cAsE=4";
Configuration conf(ARGC, argv, false);
@@ -46,6 +49,8 @@ TEST(ConfigurationTest, CommandLine)
EXPECT_EQ("1", conf.getParams()["test2"]);
EXPECT_EQ("text2", conf.getParams()["test3"]);
EXPECT_EQ("1", conf.getParams()["test4"]);
+ EXPECT_EQ("-25", conf.getParams()["negative"]);
+ EXPECT_EQ("4", conf.getParams()["case"]);
}