Allow clean and dirty metadata in regex plugin entries

This commit is contained in:
Oliver Hamlet
2018-10-20 12:47:53 +01:00
parent a819c20673
commit 2f776cfac6
3 changed files with 16 additions and 20 deletions
+2 -2
View File
@@ -93,13 +93,13 @@ This is the structure that brings all the others together, and forms the main co
``cleaning data set``
Cleaning data for this plugin, identifying dirty plugins. Plugin entries with regular expression filenames **must not** contain cleaning data.
An unordered set of cleaning data structures for this plugin, identifying dirty plugins.
.. describe:: clean
``cleaning data set``
An unordered set of cleaning data structures for this plugin, identifying clean plugins. Plugin entries with regular expression filenames **must not** contain cleaning data. The ``itm``, ``udr`` and ``nav`` fields are unused in this context, as they're assumed to be zero.
An unordered set of cleaning data structures for this plugin, identifying clean plugins. The ``itm``, ``udr`` and ``nav`` fields are unused in this context, as they're assumed to be zero.
Equality
--------
+4 -16
View File
@@ -119,24 +119,12 @@ struct convert<loot::PluginMetadata> {
if (node["tag"])
rhs.SetTags(node["tag"].as<std::set<loot::Tag>>());
if (node["dirty"]) {
if (rhs.IsRegexPlugin())
throw RepresentationException(node.Mark(),
"bad conversion: 'dirty' key must not be "
"present in a regex 'plugin metadata' "
"object");
else
rhs.SetDirtyInfo(
node["dirty"].as<std::set<loot::PluginCleaningData>>());
rhs.SetDirtyInfo(
node["dirty"].as<std::set<loot::PluginCleaningData>>());
}
if (node["clean"]) {
if (rhs.IsRegexPlugin())
throw RepresentationException(node.Mark(),
"bad conversion: 'clean' key must not be "
"present in a regex 'plugin metadata' "
"object");
else
rhs.SetCleanInfo(
node["clean"].as<std::set<loot::PluginCleaningData>>());
rhs.SetCleanInfo(
node["clean"].as<std::set<loot::PluginCleaningData>>());
}
if (node["url"])
rhs.SetLocations(node["url"].as<std::set<loot::Location>>());
@@ -959,8 +959,12 @@ TEST_P(PluginMetadataTest,
" util: 'utility'\n"
" udr: 1\n"
" nav: 2");
PluginMetadata plugin = node.as<PluginMetadata>();
EXPECT_THROW(node.as<PluginMetadata>(), YAML::RepresentationException);
EXPECT_EQ("Blank\\.esp", plugin.GetName());
EXPECT_EQ(std::set<PluginCleaningData>(
{PluginCleaningData(5, "utility", info_, 0, 1, 2)}),
plugin.GetDirtyInfo());
}
TEST_P(PluginMetadataTest,
@@ -970,8 +974,12 @@ TEST_P(PluginMetadataTest,
"clean:\n"
" - crc: 0x5\n"
" util: 'utility'");
PluginMetadata plugin = node.as<PluginMetadata>();
EXPECT_THROW(node.as<PluginMetadata>(), YAML::RepresentationException);
EXPECT_EQ("Blank\\.esp", plugin.GetName());
EXPECT_EQ(std::set<PluginCleaningData>(
{PluginCleaningData(5, "utility")}),
plugin.GetCleanInfo());
}
TEST_P(PluginMetadataTest, decodingFromYamlWithAnInvalidRegexNameShouldThrow) {