Adds operator != to AbilityType.
Makes Abiites tests use the vector compare helper. Makes Abilities tests report "no errors" instead of "" for success.
This commit is contained in:
@@ -20,6 +20,10 @@ namespace SBF {
|
|||||||
left.plural == right.plural;
|
left.plural == right.plural;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool operator!=(const AbilityType& left, const AbilityType& right) {
|
||||||
|
return !(left == right);
|
||||||
|
}
|
||||||
|
|
||||||
void FillAbilities(vector<AbilityType>& abilities) {
|
void FillAbilities(vector<AbilityType>& abilities) {
|
||||||
abilities.clear();
|
abilities.clear();
|
||||||
abilities.push_back(kAbilityGroupTalents);
|
abilities.push_back(kAbilityGroupTalents);
|
||||||
|
|||||||
@@ -152,6 +152,12 @@ namespace SBF {
|
|||||||
/// @return True if left is equal to right and false otherwise.
|
/// @return True if left is equal to right and false otherwise.
|
||||||
bool operator==(const AbilityType& left, const AbilityType& right);
|
bool operator==(const AbilityType& left, const AbilityType& right);
|
||||||
|
|
||||||
|
/// @brief This function compares two AbilityType values for equality.
|
||||||
|
/// @param left The first AbilityType.
|
||||||
|
/// @param right The second AbilityType.
|
||||||
|
/// @return True if left and right are not equal and false otherwise.
|
||||||
|
bool operator!=(const AbilityType& left, const AbilityType& right);
|
||||||
|
|
||||||
/// @brief Fills the provided vector with all of the available ability groups.
|
/// @brief Fills the provided vector with all of the available ability groups.
|
||||||
/// @param abilities The vector to fill. It will be cleared before filling.
|
/// @param abilities The vector to fill. It will be cleared before filling.
|
||||||
void FillAbilities(std::vector<AbilityType>& abilities);
|
void FillAbilities(std::vector<AbilityType>& abilities);
|
||||||
|
|||||||
@@ -100,32 +100,50 @@ namespace Test::Abilities {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TestResults test_AbilityType_operator_not_equal_to() {
|
||||||
|
return execute_suite<bool, AbilityType, AbilityType>(
|
||||||
|
make_test_suite(
|
||||||
|
"SBF::AbilityType::operator!=",
|
||||||
|
[](const AbilityType& left, const AbilityType& right) {
|
||||||
|
return left != right;
|
||||||
|
},
|
||||||
|
vector<TestTuple<bool, AbilityType, AbilityType>>({
|
||||||
|
make_test<bool, AbilityType, AbilityType>(
|
||||||
|
"should return false when comparing an ability group to itself",
|
||||||
|
false,
|
||||||
|
make_tuple(kAbilityGroupTalents, kAbilityGroupTalents)),
|
||||||
|
make_test<bool, AbilityType, AbilityType>(
|
||||||
|
"should return false when comparing two different instances created with the same values",
|
||||||
|
false,
|
||||||
|
make_tuple(kAbilityGroupSkills, AbilityType({kAbilitySkillsId, kAbilitySkillsSingular, kAbilitySkillsPlural}))),
|
||||||
|
make_test<bool, AbilityType, AbilityType>(
|
||||||
|
"should return true when comparing two different ability gropus",
|
||||||
|
true,
|
||||||
|
make_tuple(kAbilityGroupKnowledges, kAbilityGroupSkills)),
|
||||||
|
})
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
TestResults test_FillAbilities() {
|
TestResults test_FillAbilities() {
|
||||||
return execute_suite<string>(
|
return execute_suite<string>(
|
||||||
make_test_suite(
|
make_test_suite(
|
||||||
"SBF::FillAbilities",
|
"SBF::FillAbilities",
|
||||||
[]() {
|
[]()->string {
|
||||||
ostringstream error_message;
|
ostringstream error_message;
|
||||||
vector<AbilityType> actual;
|
vector<AbilityType> actual = {{-1, "This should be removed.", "This should be removed."}};
|
||||||
|
vector<AbilityType> expected = {kAbilityGroupTalents, kAbilityGroupSkills, kAbilityGroupKnowledges};
|
||||||
FillAbilities(actual);
|
FillAbilities(actual);
|
||||||
if (actual.size() != 3) {
|
compare(error_message, expected, actual);
|
||||||
error_message << "size != 3 actually, and was " << actual.size();
|
string error = error_message.str();
|
||||||
|
if (error.size() > 0) {
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
if (!error_message.str().size() && !(actual[0] == kAbilityGroupTalents)) {
|
return "no errors";
|
||||||
error_message << "group 0 != talents, and was " << actual[0];
|
|
||||||
}
|
|
||||||
if (!error_message.str().size() && !(actual[1] == kAbilityGroupSkills)) {
|
|
||||||
error_message << "group 1 != skills, and was " << actual[1];
|
|
||||||
}
|
|
||||||
if (!error_message.str().size() && !(actual[2] == kAbilityGroupKnowledges)) {
|
|
||||||
error_message << "group 2 != knowledges, and was " << actual[2];
|
|
||||||
}
|
|
||||||
return error_message.str();
|
|
||||||
},
|
},
|
||||||
vector<TestTuple<string>>({
|
vector<TestTuple<string>>({
|
||||||
make_test<string>(
|
make_test<string>(
|
||||||
"should fill abilities",
|
"should fill abilities",
|
||||||
"",
|
"no errors",
|
||||||
make_tuple()),
|
make_tuple()),
|
||||||
})
|
})
|
||||||
));
|
));
|
||||||
@@ -136,7 +154,7 @@ namespace Test::Abilities {
|
|||||||
make_test_suite(
|
make_test_suite(
|
||||||
"SBF::FillAbilitiesForAbilityGroup",
|
"SBF::FillAbilitiesForAbilityGroup",
|
||||||
[](int groupId) {
|
[](int groupId) {
|
||||||
vector<string> abilities = {"This should be removed"};
|
vector<string> abilities = {"This should be removed."};
|
||||||
FillAbilitiesForAbilityGroup(abilities, groupId);
|
FillAbilitiesForAbilityGroup(abilities, groupId);
|
||||||
return abilities;
|
return abilities;
|
||||||
},
|
},
|
||||||
@@ -170,7 +188,7 @@ namespace Test::Abilities {
|
|||||||
make_test_suite(
|
make_test_suite(
|
||||||
"SBF::FillAbilityLabels",
|
"SBF::FillAbilityLabels",
|
||||||
[](int groupId) {
|
[](int groupId) {
|
||||||
vector<string> abilities = {"This should be removed"};
|
vector<string> abilities = {"This should be removed."};
|
||||||
FillAbilityLabels(abilities, groupId);
|
FillAbilityLabels(abilities, groupId);
|
||||||
return abilities;
|
return abilities;
|
||||||
},
|
},
|
||||||
@@ -203,22 +221,22 @@ namespace Test::Abilities {
|
|||||||
return execute_suite<string>(
|
return execute_suite<string>(
|
||||||
make_test_suite(
|
make_test_suite(
|
||||||
"SBF::FillKnowlegeLabels",
|
"SBF::FillKnowlegeLabels",
|
||||||
[]() {
|
[]()->string {
|
||||||
ostringstream error_message;
|
ostringstream error_message;
|
||||||
vector<string> actual = {"This should be removed"};
|
vector<string> actual = {"This should be removed."};
|
||||||
|
vector<string> expected = {"", "Bureaucracy", "Computer", "Finance", "Investigation", "Law", "Linguistics", "Medicine", "Occult", "Politics", "Science"};
|
||||||
FillKnowledgeLabels(actual);
|
FillKnowledgeLabels(actual);
|
||||||
if (actual.size() != 11) {
|
compare(error_message, expected, actual);
|
||||||
error_message << "size != 11 actually, and was " << actual.size();
|
string error = error_message.str();
|
||||||
|
if (error.size() > 0) {
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
if (!error_message.str().size() && !(actual == vector<string>({"", "Bureaucracy", "Computer", "Finance", "Investigation", "Law", "Linguistics", "Medicine", "Occult", "Politics", "Science"}))) {
|
return "no errors";
|
||||||
error_message << "group 0 != talents, and was " << actual[0];
|
|
||||||
}
|
|
||||||
return error_message.str();
|
|
||||||
},
|
},
|
||||||
vector<TestTuple<string>>({
|
vector<TestTuple<string>>({
|
||||||
make_test<string>(
|
make_test<string>(
|
||||||
"should fill knowledge labels",
|
"should fill knowledge labels",
|
||||||
"",
|
"no errors",
|
||||||
make_tuple()),
|
make_tuple()),
|
||||||
})
|
})
|
||||||
));
|
));
|
||||||
@@ -228,22 +246,22 @@ namespace Test::Abilities {
|
|||||||
return execute_suite<string>(
|
return execute_suite<string>(
|
||||||
make_test_suite(
|
make_test_suite(
|
||||||
"SBF::FillSkillLabels",
|
"SBF::FillSkillLabels",
|
||||||
[]() {
|
[]()->string {
|
||||||
ostringstream error_message;
|
ostringstream error_message;
|
||||||
vector<string> actual = {"This should be removed"};
|
vector<string> actual = {"This should be removed."};
|
||||||
|
vector<string> expected = {"", "Animal Ken", "Drive", "Etiquette", "Firearms", "Melee", "Music", "Repair", "Security", "Stealth", "Survival"};
|
||||||
FillSkillLabels(actual);
|
FillSkillLabels(actual);
|
||||||
if (actual.size() != 11) {
|
compare(error_message, expected, actual);
|
||||||
error_message << "size != 11 actually, and was " << actual.size();
|
string error = error_message.str();
|
||||||
|
if (error.size() > 0) {
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
if (!error_message.str().size() && !(actual == vector<string>({"", "Animal Ken", "Drive", "Etiquette", "Firearms", "Melee", "Music", "Repair", "Security", "Stealth", "Survival"}))) {
|
return "no errors";
|
||||||
error_message << "group 0 != talents, and was " << actual[0];
|
|
||||||
}
|
|
||||||
return error_message.str();
|
|
||||||
},
|
},
|
||||||
vector<TestTuple<string>>({
|
vector<TestTuple<string>>({
|
||||||
make_test<string>(
|
make_test<string>(
|
||||||
"should fill skill labels",
|
"should fill skill labels",
|
||||||
"",
|
"no errors",
|
||||||
make_tuple()),
|
make_tuple()),
|
||||||
})
|
})
|
||||||
));
|
));
|
||||||
@@ -253,22 +271,22 @@ namespace Test::Abilities {
|
|||||||
return execute_suite<string>(
|
return execute_suite<string>(
|
||||||
make_test_suite(
|
make_test_suite(
|
||||||
"SBF::FillTalentLabels",
|
"SBF::FillTalentLabels",
|
||||||
[]() {
|
[]()->string {
|
||||||
ostringstream error_message;
|
ostringstream error_message;
|
||||||
vector<string> actual = {"This should be removed"};
|
vector<string> actual = {"This should be removed."};
|
||||||
|
vector<string> expected = {"", "Acting", "Alertness", "Athletics", "Brawl", "Dodge", "Empathy", "Intimidation", "Leadership", "Streetwise", "Subterfuge"};
|
||||||
FillTalentLabels(actual);
|
FillTalentLabels(actual);
|
||||||
if (actual.size() != 11) {
|
compare(error_message, expected, actual);
|
||||||
error_message << "size != 11 actually, and was " << actual.size();
|
string error = error_message.str();
|
||||||
|
if (error.size() > 0) {
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
if (!error_message.str().size() && !(actual == vector<string>({"", "Acting", "Alertness", "Athletics", "Brawl", "Dodge", "Empathy", "Intimidation", "Leadership", "Streetwise", "Subterfuge"}))) {
|
return "no errors";
|
||||||
error_message << "group 0 != talents, and was " << actual[0];
|
|
||||||
}
|
|
||||||
return error_message.str();
|
|
||||||
},
|
},
|
||||||
vector<TestTuple<string>>({
|
vector<TestTuple<string>>({
|
||||||
make_test<string>(
|
make_test<string>(
|
||||||
"should fill knowledge labels",
|
"should fill knowledge labels",
|
||||||
"",
|
"no errors",
|
||||||
make_tuple()),
|
make_tuple()),
|
||||||
})
|
})
|
||||||
));
|
));
|
||||||
|
|||||||
Reference in New Issue
Block a user