Browse Source

Test: make plugin configuration passing test a bit more flexible.

Have the input configuration settable as well, instead of always
starting from a hardcoded one.
pull/596/head
Vladimír Vondruš 4 years ago
parent
commit
539263f5a5
  1. 103
      src/Magnum/Test/ConverterUtilitiesTest.cpp

103
src/Magnum/Test/ConverterUtilitiesTest.cpp

@ -40,95 +40,116 @@ struct ConverterUtilitiesTest: TestSuite::Tester {
const struct { const struct {
const char* name; const char* name;
const char* config;
const char* options; const char* options;
const char* anyPluginName; const char* anyPluginName;
const char* expectedConfig; const char* expectedConfig;
const char* expectedWarning; const char* expectedWarning;
} SetOptionsData[]{ } SetOptionsData[]{
{"", "option=value", "AnyPlugin", R"([configuration] {"", R"([configuration]
option=
another=
)",
"option=value", "AnyPlugin", R"([configuration]
option=value option=value
another= another=
[configuration/group]
option=
[configuration/group/nested]
option=
)", nullptr}, )", nullptr},
{"two options", "option=value,another=yes", "AnyPlugin", R"([configuration] {"two options", R"([configuration]
option=
some=
another=
)",
"option=value,another=yes", "AnyPlugin", R"([configuration]
option=value option=value
some=
another=yes another=yes
[configuration/group]
option=
[configuration/group/nested]
option=
)", nullptr}, )", nullptr},
{"implicit true", "option=value,another", "AnyPlugin", R"([configuration] {"implicit true", R"([configuration]
option=
another=
)",
"option=value,another", "AnyPlugin", R"([configuration]
option=value option=value
another=true another=true
)", nullptr},
{"group", R"([configuration]
option=
[configuration/group] [configuration/group]
option= option=
[configuration/group/nested] another=
)",
"group/option=value", "AnyPlugin", R"([configuration]
option= option=
[configuration/group]
option=value
another=
)", nullptr}, )", nullptr},
{"group", "group/option=value", "AnyPlugin", R"([configuration] {"nested group + root option after", R"([configuration]
option= option=
another= another=
[configuration/group] [configuration/group]
option=value option=
[configuration/group/nested] [configuration/group/nested]
option= option=
)", nullptr}, another=
{"nested group + root option after", "group/nested/option=value,another=yes", "AnyPlugin", R"([configuration] )",
"group/nested/option=value,another=yes", "AnyPlugin", R"([configuration]
option= option=
another=yes another=yes
[configuration/group] [configuration/group]
option= option=
[configuration/group/nested] [configuration/group/nested]
option=value option=value
another=
)", nullptr}, )", nullptr},
{"unrecognized option", "notFound=value", "AnyPlugin", R"([configuration] {"unrecognized option", R"([configuration]
option= option=
another=
notFound=value
[configuration/group] [configuration/group]
)",
"notFound=value", "AnyPlugin", R"([configuration]
option= option=
[configuration/group/nested] notFound=value
option= [configuration/group]
)", )",
/* The trailing space is there because the plugin name is empty */ /* The trailing space is there because the plugin name is empty */
"Option notFound not recognized by \n"}, "Option notFound not recognized by \n"},
{"unrecognized option in Any plugin", "notFound=value", "", R"([configuration] {"unrecognized option in Any plugin", R"([configuration]
option= option=
another=
notFound=value
[configuration/group] [configuration/group]
)",
"notFound=value", "", R"([configuration]
option= option=
[configuration/group/nested] notFound=value
option= [configuration/group]
)", nullptr}, )", nullptr},
{"unrecognized group", "notFound/option=value", "AnyPlugin", R"([configuration] {"unrecognized group", R"([configuration]
option= option=
another=
[configuration/group] [configuration/group]
option= option=
[configuration/group/nested] )",
"notFound/option=value", "AnyPlugin", R"([configuration]
option=
[configuration/group]
option= option=
[configuration/notFound] [configuration/notFound]
option=value option=value
)", )",
/* The trailing space is there because the plugin name is empty */ /* The trailing space is there because the plugin name is empty */
"Option notFound/option not recognized by \n"}, "Option notFound/option not recognized by \n"},
{"unrecognized nested group", "group/notFound/nested/option=value", "AnyPlugin", R"([configuration] {"unrecognized nested group", R"([configuration]
option= option=
another=
[configuration/group] [configuration/group]
option= option=
[configuration/group/nested] )",
"group/notFound/nested/option=value", "AnyPlugin", R"([configuration]
option=
[configuration/group]
option= option=
[configuration/group/notFound/nested] [configuration/group/notFound/nested]
option=value option=value
)", )",
/* The trailing space is there because the plugin name is empty */ /* The trailing space is there because the plugin name is empty */
"Option group/notFound/nested/option not recognized by \n"} "Option group/notFound/nested/option not recognized by \n"},
}; };
ConverterUtilitiesTest::ConverterUtilitiesTest() { ConverterUtilitiesTest::ConverterUtilitiesTest() {
@ -140,16 +161,12 @@ void ConverterUtilitiesTest::setOptions() {
auto&& data = SetOptionsData[testCaseInstanceId()]; auto&& data = SetOptionsData[testCaseInstanceId()];
setTestCaseDescription(data.name); setTestCaseDescription(data.name);
struct Plugin: PluginManager::AbstractPlugin { struct: PluginManager::AbstractPlugin {} plugin;
explicit Plugin() {
/* Populate default config */ /** @todo UGH, fix the insane Configuration API already */
configuration().setValue("option", ""); std::stringstream in;
configuration().setValue("another", ""); in << data.config;
Utility::ConfigurationGroup& group = *configuration().addGroup("group"); plugin.configuration() = Utility::ConfigurationGroup{*Utility::Configuration{in}.group("configuration")};
group.setValue("option", "");
group.addGroup("nested")->setValue("option", "");
}
} plugin;
{ {
std::ostringstream out; std::ostringstream out;

Loading…
Cancel
Save