summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--icetray/icetray/options.cpp9
-rw-r--r--icetray/unittests/testIceTrayOptions.cpp14
2 files changed, 22 insertions, 1 deletions
diff --git a/icetray/icetray/options.cpp b/icetray/icetray/options.cpp
index a12a7d0..dcc6bb0 100644
--- a/icetray/icetray/options.cpp
+++ b/icetray/icetray/options.cpp
@@ -46,7 +46,14 @@ namespace IceTray {
for (const auto & optDesc : all.options()) {
po::option opt;
opt.value = p->getPropertyAsList(optDesc->long_name());
- if (opt.value.empty()) continue;
+ if (opt.value.empty()) {
+ // If it was processed as an empty list and was empty, it wasn't there.
+ if (p->getProperty(optDesc->long_name()).empty()) {
+ continue;
+ }
+ // If it was process as an empty list but wasn't empty, treat as the empty string.
+ opt.value = { "" };
+ }
opt.string_key = optDesc->long_name();
opt.unregistered = false;
result.options.push_back(opt);
diff --git a/icetray/unittests/testIceTrayOptions.cpp b/icetray/unittests/testIceTrayOptions.cpp
index 3eb08fc..62f921a 100644
--- a/icetray/unittests/testIceTrayOptions.cpp
+++ b/icetray/unittests/testIceTrayOptions.cpp
@@ -30,3 +30,17 @@ BOOST_AUTO_TEST_CASE( testOptions )
BOOST_REQUIRE_EQUAL(8, myOpts->testVec[3]);
}
+BOOST_AUTO_TEST_CASE( overrideDefaultWithQuotesString )
+{
+ DI di({ R"C(--testString="some \"Quotes\" string")C" });
+ IceTray::OptionsResolver<TestOptions> myOpts;
+ BOOST_REQUIRE_EQUAL("some \"Quotes\" string", myOpts->testString);
+}
+
+BOOST_AUTO_TEST_CASE( overrideDefaultWithEmptyString )
+{
+ DI di({ R"C(--testString="")C" });
+ IceTray::OptionsResolver<TestOptions> myOpts;
+ BOOST_REQUIRE(myOpts->testString.empty());
+}
+