Add PluginMetadata::UnsetGroup()

The postcondition is that GetGroup returns nullopt.
This commit is contained in:
Oliver Hamlet
2019-01-27 18:07:20 +00:00
parent 56d8f787e7
commit 1b67c79aed
3 changed files with 20 additions and 0 deletions
+5
View File
@@ -180,6 +180,11 @@ public:
*/
LOOT_API void SetGroup(const std::string& group);
/**
* Unsets the plugin's group.
*/
LOOT_API void UnsetGroup();
/**
* Set the files that the plugin must load after.
* @param after
+4
View File
@@ -220,6 +220,10 @@ void PluginMetadata::SetGroup(const std::string& group) {
group_ = group;
}
void PluginMetadata::UnsetGroup() {
group_ = std::nullopt;
}
void PluginMetadata::SetLoadAfterFiles(const std::set<File>& l) {
loadAfter_ = l;
}
@@ -476,6 +476,17 @@ TEST_P(PluginMetadataTest, simpleMessagesShouldReturnMessagesAsSimpleMessages) {
EXPECT_EQ("content3", simpleMessages.back().text);
}
TEST_P(PluginMetadataTest, unsetGroupShouldLeaveNoGroupValueSet) {
PluginMetadata plugin;
EXPECT_FALSE(plugin.GetGroup().has_value());
plugin.SetGroup("test");
EXPECT_EQ("test", plugin.GetGroup().value());
plugin.UnsetGroup();
EXPECT_FALSE(plugin.GetGroup().has_value());
}
TEST_P(PluginMetadataTest,
hasNameOnlyShouldBeTrueForADefaultConstructedPluginMetadataObject) {
PluginMetadata plugin;