Fix loot_get_plugin_tags() remembering results

Consecutive calls would include the output tags from previous calls.
Closes #595.
This commit is contained in:
Oliver Hamlet
2016-07-06 19:45:45 +01:00
parent 7d008179df
commit 65afed18e5
3 changed files with 64 additions and 0 deletions
+2
View File
@@ -77,11 +77,13 @@ void loot_db::setRevisionDateString(const std::string& str) {
}
void loot_db::setAddedTags(const std::set<std::string>& names) {
addedTagIds.clear();
for (const auto& name : names)
addedTagIds.push_back(getBashTagUid(name));
}
void loot_db::setRemovedTags(const std::set<std::string>& names) {
removedTagIds.clear();
for (const auto& name : names)
removedTagIds.push_back(getBashTagUid(name));
}
+38
View File
@@ -180,6 +180,25 @@ namespace loot {
}), db->getAddedTagIds());
}
TEST_P(loot_db_test, settingAddedTagsShouldReplaceExistingTags) {
db->addBashTagsToMap({
"C.Climate",
"Relev",
});
db->setAddedTags({
"Relev",
});
db->setAddedTags({
"C.Climate",
});
EXPECT_EQ(std::vector<unsigned int>({
0,
}), db->getAddedTagIds());
}
TEST_P(loot_db_test, settingRemovedTagsWithNoTagMapShouldThrow) {
EXPECT_ANY_THROW(db->setRemovedTags({
"Relev",
@@ -201,6 +220,25 @@ namespace loot {
}), db->getRemovedTagIds());
}
TEST_P(loot_db_test, settingRemovedTagsShouldReplaceExistingTags) {
db->addBashTagsToMap({
"C.Climate",
"Relev",
});
db->setRemovedTags({
"Relev",
});
db->setRemovedTags({
"C.Climate",
});
EXPECT_EQ(std::vector<unsigned int>({
0,
}), db->getRemovedTagIds());
}
TEST_P(loot_db_test, settingPluginMessagesShouldCopyThem) {
db->setPluginMessages(std::list<Message>({
Message(Message::warn, "Test 1"),
+24
View File
@@ -134,6 +134,30 @@ namespace loot {
EXPECT_TRUE(modified);
}
TEST_P(loot_get_plugin_tags_test, shouldOutputTheCorrectBashTagsForPluginsWhenMakingConsecutiveCalls) {
ASSERT_NO_THROW(generateMasterlist());
ASSERT_EQ(loot_ok, loot_load_lists(db, masterlistPath.string().c_str(), NULL));
getTagMap();
EXPECT_EQ(loot_ok, loot_get_plugin_tags(db, blankEsm.c_str(), &added, &numAdded, &removed, &numRemoved, &modified));
ASSERT_EQ(2, numAdded);
EXPECT_EQ(0, added[0]);
EXPECT_EQ(1, added[1]);
ASSERT_EQ(1, numRemoved);
EXPECT_EQ(2, removed[0]);
EXPECT_FALSE(modified);
EXPECT_EQ(loot_ok, loot_get_plugin_tags(db, blankEsp.c_str(), &added, &numAdded, &removed, &numRemoved, &modified));
EXPECT_EQ(0, numAdded);
EXPECT_EQ(NULL, added);
EXPECT_EQ(0, numRemoved);
EXPECT_EQ(NULL, removed);
EXPECT_FALSE(modified);
}
}
}