Documents Abilities.

Adds full test coverage for Abilities.
This commit is contained in:
2023-04-15 16:27:23 -07:00
parent 31a5b60f7f
commit e68973c1b1
3 changed files with 901 additions and 156 deletions

View File

@@ -3,32 +3,158 @@
#include <iostream> #include <iostream>
namespace SBF { namespace SBF {
using std::wstring; using std::string;
using std::ostream;
using std::vector;
ostream& operator<<(ostream& os, const AbilityType& abilityGroup) {
// template<typename T> os << "AbilityGroup: {id: " << abilityGroup.id
// T r(int a, int b) { << ", singular: \"" << abilityGroup.singular
// auto s = [](int a, int b){return (T)nullptr;} << "\", plural: \"" << abilityGroup.plural << "\"}";
// auto t = wstring(L"asdf"); return os;
// return s(a,b);
// }
void testMe() {
auto l = [](int a, int b){return;};
l(1,2);
// std::cout << "l: " << l(1,2) << std::endl;
// auto q = r<void>(1, 2);
// std::cout << "q: " << q(1,2) << std::endl;
} }
const wstring GetAbilityLabel(int abilityGroupId, int abilityId) {
bool operator==(const AbilityType& left, const AbilityType& right) {
return left.id == right.id &&
left.singular == right.singular &&
left.plural == right.plural;
}
void FillAbilities(vector<AbilityType>& abilities) {
abilities.clear();
abilities.push_back(kAbilityGroupTalents);
abilities.push_back(kAbilityGroupSkills);
abilities.push_back(kAbilityGroupKnowledges);
}
void FillAbilitiesForAbilityGroup(vector<string>& abilities, int abilityGroupId) {
abilities.clear();
int numAbilities = GetNumItemsForAbilityGroup(abilityGroupId);
switch (abilityGroupId) { switch (abilityGroupId) {
case kAbilityTalentsId: case kAbilityTalentsId:
return kTalents[abilityId]; for (int talentId = 0; talentId <= numAbilities; talentId++) {
if (talentId >= 0 && talentId <= kTalentsCount) {
abilities.push_back(kTalents[talentId]);
}
}
break;
case kAbilitySkillsId: case kAbilitySkillsId:
return kSkills[abilityId]; for (int skillId = 0; skillId <= numAbilities; skillId++) {
if (skillId >= 0 && skillId <= kSkillsCount) {
abilities.push_back(kSkills[skillId]);
}
}
break;
case kAbilityKnowledgesId: case kAbilityKnowledgesId:
return kKnowledges[abilityId]; for (int knowledgeId = 0; knowledgeId <= numAbilities; knowledgeId++) {
}; if (knowledgeId >= 0 && knowledgeId <= kKnowledgesCount) {
return wstring() + L""; abilities.push_back(kKnowledges[knowledgeId]);
}
}
break;
}
} }
void FillAbilityLabels(vector<string>& labels, int abilityGroupId) {
labels.clear();
switch (abilityGroupId) {
case kAbilityTalentsId:
FillTalentLabels(labels);
break;
case kAbilitySkillsId:
FillSkillLabels(labels);
break;
case kAbilityKnowledgesId:
FillKnowledgeLabels(labels);
break;
}
}
void FillKnowledgeLabels(vector<string>& labels) {
labels.clear();
int numAbilities = GetNumItemsForAbilityGroup(kAbilityKnowledgesId);
for (int knowledgeId = 0; knowledgeId <= numAbilities; knowledgeId++) {
if (knowledgeId >= 0 && knowledgeId <= kKnowledgesCount) {
labels.push_back(kKnowledges[knowledgeId]);
}
}
}
void FillSkillLabels(vector<string>& labels) {
labels.clear();
int numAbilities = GetNumItemsForAbilityGroup(kAbilitySkillsId);
for (int skillId = 0; skillId <= numAbilities; skillId++) {
if (skillId >= 0 && skillId <= kSkillsCount) {
labels.push_back(kSkills[skillId]);
}
}
}
void FillTalentLabels(vector<string>& labels) {
labels.clear();
int numAbilities = GetNumItemsForAbilityGroup(kAbilityTalentsId);
for (int talentId = 0; talentId <= numAbilities; talentId++) {
if (talentId >= 0 && talentId <= kTalentsCount) {
labels.push_back(kTalents[talentId]);
}
}
}
const AbilityType& GetAbility(int abilityGroupId) {
switch(abilityGroupId) {
case kAbilityTalentsId:
return kAbilityGroupTalents;
case kAbilitySkillsId:
return kAbilityGroupSkills;
case kAbilityKnowledgesId:
return kAbilityGroupKnowledges;
};
return kAbilityGroupUnknown;
}
const string GetAbilityLabel(int abilityGroupId, int abilityId) {
switch (abilityGroupId) {
case kAbilityTalentsId:
return GetTalentLabel(abilityId);
case kAbilitySkillsId:
return GetSkillLabel(abilityId);
case kAbilityKnowledgesId:
return GetKnowledgeLabel(abilityId);
};
return "";
}
const std::string GetKnowledgeLabel(int talentId){
if (talentId > 0 && talentId <= kKnowledgesCount) {
return kKnowledges[talentId];
}
return "";
}
int GetNumItemsForAbilityGroup(int abilityGroupId) {
switch (abilityGroupId) {
case kAbilityTalentsId:
return kTalentsCount;
case kAbilitySkillsId:
return kSkillsCount;
case kAbilityKnowledgesId:
return kKnowledgesCount;
}
return 0;
}
const std::string GetSkillLabel(int skillId) {
if (skillId > 0 && skillId <= kSkillsCount) {
return kSkills[skillId];
}
return "";
}
const std::string GetTalentLabel(int talentId) {
if (talentId > 0 && talentId <= kTalentsCount) {
return kTalents[talentId];
}
return "";
}
} // End namespace SBF } // End namespace SBF

View File

@@ -5,50 +5,59 @@
namespace SBF { namespace SBF {
const int kAbilityTalentsId = 1; const int kAbilityTalentsId = 1;
const std::wstring kAbilityTalentsSingular = L"Talent"; const std::string kAbilityTalentsSingular = "Talent";
const std::wstring kAbilityTalentsPlural = L"Talents"; const std::string kAbilityTalentsPlural = "Talents";
const int kAbilitySkillsId = 2; const int kAbilitySkillsId = 2;
const std::wstring kAbilitySkillsSingular = L"Skill"; const std::string kAbilitySkillsSingular = "Skill";
const std::wstring kAbilitySkillsPlural = L"Skills"; const std::string kAbilitySkillsPlural = "Skills";
const int kAbilityKnowledgesId = 3; const int kAbilityKnowledgesId = 3;
const std::wstring kAbilityKnowledgesSingular = L"Skill"; const std::string kAbilityKnowledgesSingular = "Knowledge";
const std::wstring kAbilityKnowledgesPlural = L"Skills"; const std::string kAbilityKnowledgesPlural = "Knowledges";
const int kAbilitiesCount = 3; const int kAbilitiesCount = 3;
/// @brief This type represents an ability group such as Talents, Skills or Knowledges.
struct AbilityType { struct AbilityType {
/// @brief The id of this ability group
int id; int id;
std::wstring singular; /// @brief The singular form of this group i.e. Talent.
std::wstring plural; std::string singular;
/// @brief The plural form of this group i.e. Talents.
std::string plural;
}; };
const AbilityType kAbilityGroupUnknown = {0, "", ""};
const AbilityType kAbilityGroupTalents = {kAbilityTalentsId, kAbilityTalentsSingular, kAbilityTalentsPlural};
const AbilityType kAbilityGroupSkills = {kAbilitySkillsId, kAbilitySkillsSingular, kAbilitySkillsPlural};
const AbilityType kAbilityGroupKnowledges = {kAbilityKnowledgesId, kAbilityKnowledgesSingular, kAbilityKnowledgesPlural};
const AbilityType kAbilities[] { const AbilityType kAbilities[] {
{0, L"", L""}, kAbilityGroupUnknown,
{kAbilityTalentsId, kAbilityTalentsSingular, kAbilityTalentsPlural}, kAbilityGroupTalents,
{kAbilitySkillsId, kAbilitySkillsSingular, kAbilitySkillsPlural}, kAbilityGroupSkills,
{kAbilityKnowledgesId, kAbilityKnowledgesSingular, kAbilityKnowledgesPlural}, kAbilityGroupKnowledges,
}; };
const int kTalentActingId = 1; const int kTalentActingId = 1;
const std::wstring kTalentActingLabel = L"Acting"; const std::string kTalentActingLabel = "Acting";
const int kTalentAlertnessId = 2; const int kTalentAlertnessId = 2;
const std::wstring kTalentAlertnessLabel = L"Alertness"; const std::string kTalentAlertnessLabel = "Alertness";
const int kTalentAthleticsId = 3; const int kTalentAthleticsId = 3;
const std::wstring kTalentAthleticsLabel = L"Athletics"; const std::string kTalentAthleticsLabel = "Athletics";
const int kTalentBrawlId = 4; const int kTalentBrawlId = 4;
const std::wstring kTalentBrawlLabel = L"Brawl"; const std::string kTalentBrawlLabel = "Brawl";
const int kTalentDodgeId = 5; const int kTalentDodgeId = 5;
const std::wstring kTalentDodgeLabel = L"Dodge"; const std::string kTalentDodgeLabel = "Dodge";
const int kTalentEmpathyId = 6; const int kTalentEmpathyId = 6;
const std::wstring kTalentEmpathyLabel = L"Empathty"; const std::string kTalentEmpathyLabel = "Empathy";
const int kTalentIntimidationId = 7; const int kTalentIntimidationId = 7;
const std::wstring kTalentIntimidationLabel = L"Intimidation"; const std::string kTalentIntimidationLabel = "Intimidation";
const int kTalentLeadershipId = 8; const int kTalentLeadershipId = 8;
const std::wstring kTalentLeadershipLabel = L"Leadership"; const std::string kTalentLeadershipLabel = "Leadership";
const int kTalentStreetwiseId = 9; const int kTalentStreetwiseId = 9;
const std::wstring kTalentStreetwiseLabel = L"Streetwise"; const std::string kTalentStreetwiseLabel = "Streetwise";
const int kTalentSubterfugeId = 10; const int kTalentSubterfugeId = 10;
const std::wstring kTalentSubterfugeLabel = L"Subterfuge"; const std::string kTalentSubterfugeLabel = "Subterfuge";
const int kTalentsCount = 10; const int kTalentsCount = 10;
const std::wstring kTalents[] = { const std::string kTalents[] = {
L"", "",
kTalentActingLabel, kTalentActingLabel,
kTalentAlertnessLabel, kTalentAlertnessLabel,
kTalentAthleticsLabel, kTalentAthleticsLabel,
@@ -62,28 +71,28 @@ namespace SBF {
}; };
const int kSkillAnimalKenId = 1; const int kSkillAnimalKenId = 1;
const std::wstring kSkillAnimalKenLabel = L"AnimalKen"; const std::string kSkillAnimalKenLabel = "Animal Ken";
const int kSkillDriveId = 2; const int kSkillDriveId = 2;
const std::wstring kSkillDriveLabel = L"Drive"; const std::string kSkillDriveLabel = "Drive";
const int kSkillEtiquetteId = 3; const int kSkillEtiquetteId = 3;
const std::wstring kSkillEtiquetteLabel = L"Etiquette"; const std::string kSkillEtiquetteLabel = "Etiquette";
const int kSkillFirearmsId = 4; const int kSkillFirearmsId = 4;
const std::wstring kSkillFirearmsLabel = L"Firearms"; const std::string kSkillFirearmsLabel = "Firearms";
const int kSkillMeleeId = 5; const int kSkillMeleeId = 5;
const std::wstring kSkillMeleeLabel = L"Melee"; const std::string kSkillMeleeLabel = "Melee";
const int kSkillMusicId = 6; const int kSkillMusicId = 6;
const std::wstring kSkillMusicLabel = L"Music"; const std::string kSkillMusicLabel = "Music";
const int kSkillRepairId = 7; const int kSkillRepairId = 7;
const std::wstring kSkillRepairLabel = L"Repair"; const std::string kSkillRepairLabel = "Repair";
const int kSkillSecurityId = 8; const int kSkillSecurityId = 8;
const std::wstring kSkillSecurityLabel = L"Security"; const std::string kSkillSecurityLabel = "Security";
const int kSkillStealthId = 9; const int kSkillStealthId = 9;
const std::wstring kSkillStealthLabel = L"Stealth"; const std::string kSkillStealthLabel = "Stealth";
const int kSkillSurvivalId = 10; const int kSkillSurvivalId = 10;
const std::wstring kSkillSurvivalLabel = L"Survival"; const std::string kSkillSurvivalLabel = "Survival";
const int kSkillsCount = 10; const int kSkillsCount = 10;
const std::wstring kSkills[] = { const std::string kSkills[] = {
L"", "",
kSkillAnimalKenLabel, kSkillAnimalKenLabel,
kSkillDriveLabel, kSkillDriveLabel,
kSkillEtiquetteLabel, kSkillEtiquetteLabel,
@@ -97,28 +106,28 @@ namespace SBF {
}; };
const int kKnowledgeBureaucracyId = 1; const int kKnowledgeBureaucracyId = 1;
const std::wstring kKnowledgeBureaucracyLabel = L"Bureaucracy"; const std::string kKnowledgeBureaucracyLabel = "Bureaucracy";
const int kKnowledgeComputerId = 2; const int kKnowledgeComputerId = 2;
const std::wstring kKnowledgeComputerLabel = L"Computer"; const std::string kKnowledgeComputerLabel = "Computer";
const int kKnowledgeFinanceId = 3; const int kKnowledgeFinanceId = 3;
const std::wstring kKnowledgeFinanceLabel = L"Finance"; const std::string kKnowledgeFinanceLabel = "Finance";
const int kKnowledgeInvestigationId = 4; const int kKnowledgeInvestigationId = 4;
const std::wstring kKnowledgeInvestigationLabel = L"Investigation"; const std::string kKnowledgeInvestigationLabel = "Investigation";
const int kKnowledgeLawId = 5; const int kKnowledgeLawId = 5;
const std::wstring kKnowledgeLawLabel = L"Law"; const std::string kKnowledgeLawLabel = "Law";
const int kKnowledgeLinguisticsId = 6; const int kKnowledgeLinguisticsId = 6;
const std::wstring kKnowledgeLinguisticsLabel = L"Linguistics"; const std::string kKnowledgeLinguisticsLabel = "Linguistics";
const int kKnowledgeMedicineId = 7; const int kKnowledgeMedicineId = 7;
const std::wstring kKnowledgeMedicineLabel = L"Medicine"; const std::string kKnowledgeMedicineLabel = "Medicine";
const int kKnowledgeOccultId = 8; const int kKnowledgeOccultId = 8;
const std::wstring kKnowledgeOccultLabel = L"Occult"; const std::string kKnowledgeOccultLabel = "Occult";
const int kKnowledgePoliticsId = 9; const int kKnowledgePoliticsId = 9;
const std::wstring kKnowledgePoliticsLabel = L"Politics"; const std::string kKnowledgePoliticsLabel = "Politics";
const int kKnowledgeScienceId = 10; const int kKnowledgeScienceId = 10;
const std::wstring kKnowledgeScienceLabel = L"Science"; const std::string kKnowledgeScienceLabel = "Science";
const int kKnowledgesCount = 10; const int kKnowledgesCount = 10;
const std::wstring kKnowledges[] = { const std::string kKnowledges[] = {
L"", "",
kKnowledgeBureaucracyLabel, kKnowledgeBureaucracyLabel,
kKnowledgeComputerLabel, kKnowledgeComputerLabel,
kKnowledgeFinanceLabel, kKnowledgeFinanceLabel,
@@ -131,15 +140,73 @@ namespace SBF {
kKnowledgeScienceLabel, kKnowledgeScienceLabel,
}; };
/// @brief This function writes an AbilityType value to an output stream;
/// @param os The output stream to write to.
/// @param abilityGroup The AbilityType to write.
/// @return Thw output stream for chaining.
std::ostream& operator<<(std::ostream& os, const AbilityType& abilityGroup);
/// @brief This function compares two AbilityType values for equality.
/// @param left The first AbilityType.
/// @param right The second AbilityType.
/// @return True if left is equal to right and false otherwise.
bool operator==(const AbilityType& left, const AbilityType& right);
/// @brief Fills the provided vector with all of the available ability groups.
/// @param abilities The vector to fill. It will be cleared before filling.
void FillAbilities(std::vector<AbilityType>& abilities);
/// @brief Fills the provided vector with all of the ability labels in the specified group.
/// @param abilities The vector to fill. It will be cleared before filling.
/// @param abilityGroupId The id of the ability group to fill for.
void FillAbilitiesForAbilityGroup(std::vector<std::string>& abilities, int abilityGroupId);
/// @brief Fills the provided vector with all of the ability labels in the specified group.
/// @param labels The vector to fill. It will be cleared before filling.
/// @param abilityGroupId The id of the ability group to fill for.
void FillAbilityLabels(std::vector<std::string>& labels, int abilityGroupId);
/// @brief Fills the provided vector with all of the knowledge labels.
/// @param knowledgeLabels The vector to fill. It will be cleared before filling.
void FillKnowledgeLabels(std::vector<std::string>& knowledgeLabels);
/// @brief Fills the provided vector with all of the skill labels.
/// @param skillLabels The vector to fill. It will be cleared before filling.
void FillSkillLabels(std::vector<std::string>& skillLabels);
/// @brief Fills the provided vector with all of the talent labels.
/// @param talentLabels The vector to fill. It will be cleared before filling.
void FillTalentLabels(std::vector<std::string>& talentLabels);
/// @brief Gets an ability group for a given id.
/// @param abilityGroupId The id of the ability group to return.
/// @return The ability group with an id of abilityGroupId.
const AbilityType& GetAbility(int abilityGroupId);
/// @brief Gets the label for an ability given its ability group (talents/skills/knowledges) and its id (acting, brawl, dodge, ...).
/// @param abilityGroupId The id for the ability group (talents/skills/knowledges).
/// @param abilityId The id for the ability within the ability group (acting, dodge, brawl, ...).
/// @return The label for the specific ability ("Acting").
const std::string GetAbilityLabel(int abilityGroupId, int abilityId);
/// @brief Gets the label for a knowledge ability given its id.
/// @param knowledgeId The id of the ability to return the label for.
/// @return The label for the specific ability.
const std::string GetKnowledgeLabel(int talentId);
/// @brief Gets the number of abilities in an ability group.
/// @param abilityGroupId The id of the ability group to return the number of abilities for.
/// @return The number of abilities in the specific ability group.
int GetNumItemsForAbilityGroup(int abilityGroupId); int GetNumItemsForAbilityGroup(int abilityGroupId);
const AbilityType GetAbility(int abilityId);
void FillAbilities(std::vector<AbilityType> abilities); /// @brief Gets the label for a skill ability given its id.
const std::wstring GetTalentLabel(int talentId); /// @param talentId The id of the ability to return the label for.
const std::wstring GetSkillLabel(int talentId); /// @return The label of the specific ability.
const std::wstring GetKnowledgeLabel(int talentId); const std::string GetSkillLabel(int talentId);
const std::wstring GetAbilityLabel(int abilityGroupId, int abilityId);
void FillTalentLabels(std::vector<std::wstring> talentLabels); /// @brief Gets the label for a talent ability given its id.
void FillSkillLabels(std::vector<std::wstring> skillLabels); /// @param talentId The id of the ability to return.
void FillKnowledgeLabels(std::vector<std::wstring> knowledgeLabels); /// @return The label for the specific ability.
const std::string GetTalentLabel(int talentId);
} // End namespace SBF } // End namespace SBF
#endif // End !defined ABILITIES_H__ #endif // End !defined ABILITIES_H__

View File

@@ -1,107 +1,659 @@
#include "Abilities.h" #include "Abilities.h"
#include "test.h" #include "test.h"
#include <iostream> #include <iostream>
#include <sstream>
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std; using namespace std;
namespace Test::Abilities { namespace Test::Abilities {
TestResults test_GetNumItemsForAbilityGroup(); TestResults test_AbilityType_operator_extract();
TestResults test_GetAbility(); TestResults test_AbilityType_operator_equal_to();
TestResults test_FillAbilities(); TestResults test_FillAbilities();
TestResults test_GetTalentLabel(); TestResults test_FillAbilitiesForAbilityGroup();
TestResults test_GetSkillLabel(); TestResults test_FillAbilityLabels();
TestResults test_GetKnowledgeLabel(); TestResults test_FillKnowledgeLabels();
TestResults test_GetAbilityLabel(); TestResults test_FillSkillLabels();
TestResults test_FillTalentLabels(); TestResults test_FillTalentLabels();
TestResults test_FillSkillLabels(); TestResults test_GetAbility();
TestResults test_FkilKnowledgeLabels(); TestResults test_GetAbilityLabel();
TestResults test_GetKnowledgeLabel();
TestResults test_GetNumItemsForAbilityGroup();
TestResults test_GetSkillLabel();
TestResults test_GetTalentLabel();
} // End namespace Test::Abilities } // End namespace Test::Abilities
using namespace Test::Abilities; using namespace Test::Abilities;
namespace Test {
extern TestResults do_the_other_thing();
}
// TODO: Find a way to put this in Test::Abilities or at least Test.
TestResults main_test_Abilities(int argc, char** argv) { TestResults main_test_Abilities(int argc, char** argv) {
TestResults results; TestResults results;
// results = results + test_GetNumItemsForAbilityGroup(); results += test_AbilityType_operator_extract();
// results = results + test_GetAbility(); results += test_AbilityType_operator_equal_to();
// results = results + test_FillAbilities(); results += test_FillAbilities();
// results = results + test_GetTalentLabel(); results += test_FillAbilitiesForAbilityGroup();
// results = results + test_GetSkillLabel(); results += test_FillAbilityLabels();
// results = results + test_GetKnowledgeLabel(); results += test_FillKnowledgeLabels();
// results = results + test_GetAbilityLabel(); results += test_FillSkillLabels();
// results = results + test_FillTalentLabels(); results += test_FillTalentLabels();
// results = results + test_FillSkillLabels(); results += test_GetAbility();
// results = results + test_FkilKnowledgeLabels(); results += test_GetAbilityLabel();
results += test_GetKnowledgeLabel();
results += test_GetNumItemsForAbilityGroup();
results += test_GetSkillLabel();
results += test_GetTalentLabel();
results = do_the_other_thing();
return results; return results;
} }
namespace Test::Abilities { namespace Test::Abilities {
TestResults test_GetNumItemsForAbilityGroup() { TestResults test_AbilityType_operator_extract() {
// return test_fn( return execute_suite<string, AbilityType>(
// L"/SBF/Abilities/GetNumItemsForAbilityGroup", make_test_suite(
// GetNumItemsForAbilityGroup, "SBF::AbilityType::operator<<",
// vector({ [](const AbilityType& ability){
// pair(kTalentsCount, make_tuple(kAbilityTalentsId)), ostringstream os;
// pair(kSkillsCount, make_tuple(kAbilitySkillsId)), os << ability;
// pair(kKnowledgesCount, make_tuple(kAbilityKnowledgesId)), return os.str();
// pair(0, make_tuple(0)), },
// pair(0, make_tuple(99)), vector<TestTuple<string, AbilityType>>({
// })); make_test<string, AbilityType>(
return TestResults(); "should print talents",
"AbilityGroup: {id: 1, singular: \"Talent\", plural: \"Talents\"}",
make_tuple(kAbilityGroupTalents)),
make_test<string, AbilityType>(
"should print skills",
"AbilityGroup: {id: 2, singular: \"Skill\", plural: \"Skills\"}",
make_tuple(kAbilityGroupSkills)),
make_test<string, AbilityType>(
"should print knowledges",
"AbilityGroup: {id: 3, singular: \"Knowledge\", plural: \"Knowledges\"}",
make_tuple(kAbilityGroupKnowledges)),
make_test<string, AbilityType>(
"should print an unknown ability group",
"AbilityGroup: {id: 0, singular: \"\", plural: \"\"}",
make_tuple(kAbilityGroupUnknown)),
})
));
}
TestResults test_AbilityType_operator_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 true when comparing an ability group to itself",
true,
make_tuple(kAbilityGroupTalents, kAbilityGroupTalents)),
make_test<bool, AbilityType, AbilityType>(
"should return true when comparing two different instances created with the same values",
true,
make_tuple(kAbilityGroupSkills, AbilityType({kAbilitySkillsId, kAbilitySkillsSingular, kAbilitySkillsPlural}))),
make_test<bool, AbilityType, AbilityType>(
"should return false when comparing two different ability gropus",
false,
make_tuple(kAbilityGroupKnowledges, kAbilityGroupSkills)),
})
));
}
TestResults test_FillAbilities() {
return execute_suite<string>(
make_test_suite(
"SBF::FillAbilities",
[]() {
ostringstream error_message;
vector<AbilityType> actual;
FillAbilities(actual);
if (actual.size() != 3) {
error_message << "size != 3 actually, and was " << actual.size();
}
if (!error_message.str().size() && !(actual[0] == kAbilityGroupTalents)) {
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>>({
make_test<string>(
"should fill abilities",
"",
make_tuple()),
})
));
}
TestResults test_FillAbilitiesForAbilityGroup() {
return execute_suite<vector<string>, int>(
make_test_suite(
"SBF::FillAbilitiesForAbilityGroup",
[](int groupId) {
vector<string> abilities = {"This should be removed"};
FillAbilitiesForAbilityGroup(abilities, groupId);
return abilities;
},
vector<TestTuple<vector<string>, int>>({
make_test<vector<string>, int>(
"should clear the vector for group 0, kAbilityGropuUnknownId",
{},
make_tuple(0)),
make_test<vector<string>, int>(
"should fill talents for group 1 kAbilityGroupTalentsId",
{"", "Acting", "Alertness", "Athletics", "Brawl", "Dodge", "Empathy", "Intimidation", "Leadership", "Streetwise", "Subterfuge"},//, "Alertness", "Athletics", "Brawl", "Dodge", "Empathy", "Intimidation", "Leadership", "Streetwise", "Subterfuge"
make_tuple(1)),
make_test<vector<string>, int>(
"should fill skills for group 2 kAbilityGroupSkillsId",
{"", "Animal Ken", "Drive", "Etiquette", "Firearms", "Melee", "Music", "Repair", "Security", "Stealth", "Survival"},
make_tuple(2)),
make_test<vector<string>, int>(
"should fill knowledges for group 3 kAbilityGroupKnowledgesId",
{"", "Bureaucracy", "Computer", "Finance", "Investigation", "Law", "Linguistics", "Medicine", "Occult", "Politics", "Science"},
make_tuple(3)),
make_test<vector<string>, int>(
"should clear the vector for group 4 an invalid id",
{},
make_tuple(4)),
})
));
}
TestResults test_FillAbilityLabels() {
return execute_suite<vector<string>, int>(
make_test_suite(
"SBF::FillAbilityLabels",
[](int groupId) {
vector<string> abilities = {"This should be removed"};
FillAbilityLabels(abilities, groupId);
return abilities;
},
vector<TestTuple<vector<string>, int>>({
make_test<vector<string>, int>(
"should clear the vector for group 0, kAbilityGropuUnknownId",
{},
make_tuple(0)),
make_test<vector<string>, int>(
"should fill talents for group 1 kAbilityGroupTalentsId",
{"", "Acting", "Alertness", "Athletics", "Brawl", "Dodge", "Empathy", "Intimidation", "Leadership", "Streetwise", "Subterfuge"},
make_tuple(1)),
make_test<vector<string>, int>(
"should fill skills for group 2 kAbilityGroupSkillsId",
{"", "Animal Ken", "Drive", "Etiquette", "Firearms", "Melee", "Music", "Repair", "Security", "Stealth", "Survival"},
make_tuple(2)),
make_test<vector<string>, int>(
"should fill knowledges for group 3 kAbilityGroupKnowledgesId",
{"", "Bureaucracy", "Computer", "Finance", "Investigation", "Law", "Linguistics", "Medicine", "Occult", "Politics", "Science"},
make_tuple(3)),
make_test<vector<string>, int>(
"should clear the vector for group 4 an invalid id",
{},
make_tuple(4)),
})
));
}
TestResults test_FillKnowledgeLabels() {
return execute_suite<string>(
make_test_suite(
"SBF::FillKnowlegeLabels",
[]() {
ostringstream error_message;
vector<string> actual = {"This should be removed"};
FillKnowledgeLabels(actual);
if (actual.size() != 11) {
error_message << "size != 11 actually, and was " << actual.size();
}
if (!error_message.str().size() && !(actual == vector<string>({"", "Bureaucracy", "Computer", "Finance", "Investigation", "Law", "Linguistics", "Medicine", "Occult", "Politics", "Science"}))) {
error_message << "group 0 != talents, and was " << actual[0];
}
return error_message.str();
},
vector<TestTuple<string>>({
make_test<string>(
"should fill knowledge labels",
"",
make_tuple()),
})
));
}
TestResults test_FillSkillLabels() {
return execute_suite<string>(
make_test_suite(
"SBF::FillSkillLabels",
[]() {
ostringstream error_message;
vector<string> actual = {"This should be removed"};
FillSkillLabels(actual);
if (actual.size() != 11) {
error_message << "size != 11 actually, and was " << actual.size();
}
if (!error_message.str().size() && !(actual == vector<string>({"", "Animal Ken", "Drive", "Etiquette", "Firearms", "Melee", "Music", "Repair", "Security", "Stealth", "Survival"}))) {
error_message << "group 0 != talents, and was " << actual[0];
}
return error_message.str();
},
vector<TestTuple<string>>({
make_test<string>(
"should fill skill labels",
"",
make_tuple()),
})
));
}
TestResults test_FillTalentLabels() {
return execute_suite<string>(
make_test_suite(
"SBF::FillTalentLabels",
[]() {
ostringstream error_message;
vector<string> actual = {"This should be removed"};
FillTalentLabels(actual);
if (actual.size() != 11) {
error_message << "size != 11 actually, and was " << actual.size();
}
if (!error_message.str().size() && !(actual == vector<string>({"", "Acting", "Alertness", "Athletics", "Brawl", "Dodge", "Empathy", "Intimidation", "Leadership", "Streetwise", "Subterfuge"}))) {
error_message << "group 0 != talents, and was " << actual[0];
}
return error_message.str();
},
vector<TestTuple<string>>({
make_test<string>(
"should fill knowledge labels",
"",
make_tuple()),
})
));
} }
TestResults test_GetAbility() { TestResults test_GetAbility() {
// return test_fn( return execute_suite<AbilityType, int>(
// L"/SBF/Abilities/GetAbility", make_test_suite(
// GetAbility, "SBF::GetAbility",
// vector({ GetAbility,
// pair(kAbilityKnowledges, make_tuple(kAbilityKnowledgesId)), vector<TestTuple<AbilityType, int>>({
// })); make_test<AbilityType, int>(
return TestResults(); "should get talents",
} kAbilityGroupTalents,
TestResults test_FillAbilities() { make_tuple(kAbilityTalentsId)),
return TestResults(); make_test<AbilityType, int>(
} "should get skills",
TestResults test_GetTalentLabel() { kAbilityGroupSkills,
return TestResults(); make_tuple(kAbilitySkillsId)),
} make_test<AbilityType, int>(
TestResults test_GetSkillLabel() { "should get knowledges",
return TestResults(); kAbilityGroupKnowledges,
} make_tuple(kAbilityKnowledgesId)),
TestResults test_GetKnowledgeLabel() { make_test<AbilityType, int>(
return TestResults(); "should get unknown for id 0",
kAbilityGroupUnknown,
make_tuple(0)),
make_test<AbilityType, int>(
"should get unknown for an invalid id",
kAbilityGroupUnknown,
make_tuple(4)),
})
)
);
} }
TestResults test_GetAbilityLabel() { TestResults test_GetAbilityLabel() {
return TestResults(); return execute_suite<string, int, int>(
make_test_suite(
"SBF::GetAbilityLabel",
GetAbilityLabel,
vector<TestTuple<string, int, int>>({
make_test<string, int, int>(
"should get Acting for group 1 and id 1",
"Acting",
make_tuple(1, 1)),
make_test<string, int, int>(
"should get Alertness for group 1 and id 2",
"Alertness",
make_tuple(1, 2)),
make_test<string, int, int>(
"should get Athletics for group 1 and id 3",
"Athletics",
make_tuple(1, 3)),
make_test<string, int, int>(
"should get Brawl for group 1 and id 4",
"Brawl",
make_tuple(1, 4)),
make_test<string, int, int>(
"should get Dodge for group 1 and id 5",
"Dodge",
make_tuple(1, 5)),
make_test<string, int, int>(
"should get Empathy for group 1 and id 6",
"Empathy",
make_tuple(1, 6)),
make_test<string, int, int>(
"should get Intimidation for group 1 and id 7",
"Intimidation",
make_tuple(1, 7)),
make_test<string, int, int>(
"should get Leadership for group 1 and id 8",
"Leadership",
make_tuple(1, 8)),
make_test<string, int, int>(
"should get Streetwise for group 1 and id 9",
"Streetwise",
make_tuple(1, 9)),
make_test<string, int, int>(
"should get Subterfuge for group 1 and id 10",
"Subterfuge",
make_tuple(1, 10)),
make_test<string, int, int>(
"should get Animal Ken for group 2 and id 1",
"Animal Ken",
make_tuple(2, 1)),
make_test<string, int, int>(
"should get Drive for group 2 and id 2",
"Drive",
make_tuple(2, 2)),
make_test<string, int, int>(
"should get Etiquette for group 2 and id 3",
"Etiquette",
make_tuple(2, 3)),
make_test<string, int, int>(
"should get Firearms for group 2 and id 4",
"Firearms",
make_tuple(2, 4)),
make_test<string, int, int>(
"should get Melee for group 2 and id 5",
"Melee",
make_tuple(2, 5)),
make_test<string, int, int>(
"should get Music for group 2 and id 6",
"Music",
make_tuple(2, 6)),
make_test<string, int, int>(
"should get Repair for group 2 and id 7",
"Repair",
make_tuple(2, 7)),
make_test<string, int, int>(
"should get Security for group 2 and id 8",
"Security",
make_tuple(2, 8)),
make_test<string, int, int>(
"should get Stealth for group 2 and id 9",
"Stealth",
make_tuple(2, 9)),
make_test<string, int, int>(
"should get Survival for group 2 and id 10",
"Survival",
make_tuple(2, 10)),
make_test<string, int, int>(
"should get Bureaucracy for group 3 and id 1",
"Bureaucracy",
make_tuple(3, 1)),
make_test<string, int, int>(
"should get Computer for group 3 and id 2",
"Computer",
make_tuple(3, 2)),
make_test<string, int, int>(
"should get Finance for group 3 and id 3",
"Finance",
make_tuple(3, 3)),
make_test<string, int, int>(
"should get Investigation for group 3 and id 4",
"Investigation",
make_tuple(3, 4)),
make_test<string, int, int>(
"should get Law for group 3 and id 5",
"Law",
make_tuple(3, 5)),
make_test<string, int, int>(
"should get Linguistics for group 3 and id 6",
"Linguistics",
make_tuple(3, 6)),
make_test<string, int, int>(
"should get Medicine for group 3 and id 7",
"Medicine",
make_tuple(3, 7)),
make_test<string, int, int>(
"should get Occult for group 3 and id 8",
"Occult",
make_tuple(3, 8)),
make_test<string, int, int>(
"should get Politics for group 3 and id 9",
"Politics",
make_tuple(3, 9)),
make_test<string, int, int>(
"should get Science for group 3 and id 10",
"Science",
make_tuple(3, 10)),
make_test<string, int, int>(
"should get and empty string for group 0 and id 0",
"",
make_tuple(0, 0)),
make_test<string, int, int>(
"should get and empty string for group 1 and id 11",
"",
make_tuple(1, 11)),
make_test<string, int, int>(
"should get and empty string for group 4 and id 1",
"",
make_tuple(4, 1)),
})
)
);
} }
TestResults test_FillTalentLabels() {
return TestResults();
}
TestResults test_FillSkillLabels() {
return TestResults();
}
TestResults test_FkilKnowledgeLabels() {
return TestResults();
}
// TestResults test_GetNumItemsForAbilityGroup() {
// return std::make_tuple(1, 0);
// }
// results = results + test_fn(L"get_substring", get_substring, vector({ TestResults test_GetKnowledgeLabel() {
// pair(L"234", make_tuple(L"1234567890", 1, 3)), return execute_suite<string, int>(
// pair(L"Paris", make_tuple(L"Where is Paris?", 10-1, 5)), make_test_suite(
// })); "SBF::GetKnowledgeLabel",
GetKnowledgeLabel,
vector<TestTuple<string, int>>({
make_test<string, int>(
"should get Bureaucracy for id 1",
"Bureaucracy",
make_tuple(1)),
make_test<string, int>(
"should get Computer for id 2",
"Computer",
make_tuple(2)),
make_test<string, int>(
"should get Finance for id 3",
"Finance",
make_tuple(3)),
make_test<string, int>(
"should get Investigation for id 4",
"Investigation",
make_tuple(4)),
make_test<string, int>(
"should get Law for id 5",
"Law",
make_tuple(5)),
make_test<string, int>(
"should get Linguistics for id 6",
"Linguistics",
make_tuple(6)),
make_test<string, int>(
"should get Medicine for id 7",
"Medicine",
make_tuple(7)),
make_test<string, int>(
"should get Occult for id 8",
"Occult",
make_tuple(8)),
make_test<string, int>(
"should get Politics for id 9",
"Politics",
make_tuple(9)),
make_test<string, int>(
"should get Science for id 10",
"Science",
make_tuple(10)),
make_test<string, int>(
"should get and empty string for id 0",
"",
make_tuple(0)),
make_test<string, int>(
"should get and empty string for id 11",
"",
make_tuple(11)),
})
)
);
return TestResults();
}
TestResults test_GetNumItemsForAbilityGroup() {
return execute_suite<int, int>(
make_test_suite(
"SBF::GetNumItemsForAbilityGroup",
GetNumItemsForAbilityGroup,
vector<TestTuple<int, int>>({
make_test<int, int>(
"should get 10 abilities for talents",
10,
make_tuple(kAbilityTalentsId)),
make_test<int, int>(
"should get 10 abilities for skills",
10,
make_tuple(kAbilitySkillsId)),
make_test<int, int>(
"should get 10 abilities for knowledges",
10,
make_tuple(kAbilityKnowledgesId)),
make_test<int, int>(
"should get 0 abilities for 0",
0,
make_tuple(0)),
make_test<int, int>(
"should get 0 abilities for an invalid id",
0,
make_tuple(4)),
})
)
);
}
TestResults test_GetSkillLabel() {
return execute_suite<string, int>(
make_test_suite(
"SBF::GetSkillLabel",
GetSkillLabel,
vector<TestTuple<string, int>>({
make_test<string, int>(
"should get Animal Ken for id 1",
"Animal Ken",
make_tuple(1)),
make_test<string, int>(
"should get Drive for id 2",
"Drive",
make_tuple(2)),
make_test<string, int>(
"should get Etiquette for id 3",
"Etiquette",
make_tuple(3)),
make_test<string, int>(
"should get Firearms for id 4",
"Firearms",
make_tuple(4)),
make_test<string, int>(
"should get Melee for id 5",
"Melee",
make_tuple(5)),
make_test<string, int>(
"should get Music for id 6",
"Music",
make_tuple(6)),
make_test<string, int>(
"should get Repair for id 7",
"Repair",
make_tuple(7)),
make_test<string, int>(
"should get Security for id 8",
"Security",
make_tuple(8)),
make_test<string, int>(
"should get Stealth for id 9",
"Stealth",
make_tuple(9)),
make_test<string, int>(
"should get Survival for id 10",
"Survival",
make_tuple(10)),
make_test<string, int>(
"should get and empty string for id 0",
"",
make_tuple(0)),
make_test<string, int>(
"should get and empty string for id 11",
"",
make_tuple(11)),
})
)
);
}
TestResults test_GetTalentLabel() {
return execute_suite<string, int>(
make_test_suite(
"SBF::GetTalentLabel",
GetTalentLabel,
vector<TestTuple<string, int>>({
make_test<string, int>(
"should get Acting for id 1",
"Acting",
make_tuple(1)),
make_test<string, int>(
"should get Alertness for id 2",
"Alertness",
make_tuple(2)),
make_test<string, int>(
"should get Athletics for id 3",
"Athletics",
make_tuple(3)),
make_test<string, int>(
"should get Brawl for id 4",
"Brawl",
make_tuple(4)),
make_test<string, int>(
"should get Dodge for id 5",
"Dodge",
make_tuple(5)),
make_test<string, int>(
"should get Empathy for id 6",
"Empathy",
make_tuple(6)),
make_test<string, int>(
"should get Intimidation for id 7",
"Intimidation",
make_tuple(7)),
make_test<string, int>(
"should get Leadership for id 8",
"Leadership",
make_tuple(8)),
make_test<string, int>(
"should get Streetwise for id 9",
"Streetwise",
make_tuple(9)),
make_test<string, int>(
"should get Subterfuge for id 10",
"Subterfuge",
make_tuple(10)),
make_test<string, int>(
"should get and empty string for id 0",
"",
make_tuple(0)),
make_test<string, int>(
"should get and empty string for id 11",
"",
make_tuple(11)),
})
)
);
}
} // End namespace Test::Abilities } // End namespace Test::Abilities