diff --git a/sbf-cpp/Abilities.cpp b/sbf-cpp/Abilities.cpp index 93cf3db..11fd8a4 100644 --- a/sbf-cpp/Abilities.cpp +++ b/sbf-cpp/Abilities.cpp @@ -34,24 +34,18 @@ void FillAbilitiesForAbilityGroup(vector& abilities, int id) { int numAbilities = GetNumItemsForAbilityGroup(id); switch (id) { case kAbilityTalentsId: - for (int talentId = 0; talentId <= numAbilities; talentId++) { - if (talentId >= 0 && talentId <= kTalentsCount) { - abilities.push_back(kTalents[talentId]); - } + for (int talent_id = 1; talent_id <= numAbilities; talent_id++) { + abilities.push_back(GetTalentLabel(talent_id)); } break; case kAbilitySkillsId: - for (int skillId = 0; skillId <= numAbilities; skillId++) { - if (skillId >= 0 && skillId <= kSkillsCount) { - abilities.push_back(kSkills[skillId]); - } + for (int skill_id = 1; skill_id <= numAbilities; skill_id++) { + abilities.push_back(GetSkillLabel(skill_id)); } break; case kAbilityKnowledgesId: - for (int knowledgeId = 0; knowledgeId <= numAbilities; knowledgeId++) { - if (knowledgeId >= 0 && knowledgeId <= kKnowledgesCount) { - abilities.push_back(kKnowledges[knowledgeId]); - } + for (int knowledge_id = 1; knowledge_id <= numAbilities; knowledge_id++) { + abilities.push_back(GetKnowledgeLabel(knowledge_id)); } break; } @@ -75,35 +69,29 @@ void FillAbilityLabels(vector& labels, int id) { void FillKnowledgeLabels(vector& labels) { labels.clear(); int numAbilities = GetNumItemsForAbilityGroup(kAbilityKnowledgesId); - for (int knowledgeId = 0; knowledgeId <= numAbilities; knowledgeId++) { - if (knowledgeId >= 0 && knowledgeId <= kKnowledgesCount) { - labels.push_back(kKnowledges[knowledgeId]); - } + for (int knowledge_id = 1; knowledge_id <= numAbilities; knowledge_id++) { + labels.push_back(GetKnowledgeLabel(knowledge_id)); } } void FillSkillLabels(vector& labels) { labels.clear(); int numAbilities = GetNumItemsForAbilityGroup(kAbilitySkillsId); - for (int skillId = 0; skillId <= numAbilities; skillId++) { - if (skillId >= 0 && skillId <= kSkillsCount) { - labels.push_back(kSkills[skillId]); - } + for (int skill_id = 1; skill_id <= numAbilities; skill_id++) { + labels.push_back(GetSkillLabel(skill_id)); } } void FillTalentLabels(vector& labels) { labels.clear(); int numAbilities = GetNumItemsForAbilityGroup(kAbilityTalentsId); - for (int talentId = 0; talentId <= numAbilities; talentId++) { - if (talentId >= 0 && talentId <= kTalentsCount) { - labels.push_back(kTalents[talentId]); - } + for (int talent_id = 1; talent_id <= numAbilities; talent_id++) { + labels.push_back(GetTalentLabel(talent_id)); } } -const AbilityType& GetAbility(int abilityGroupId) { - switch (abilityGroupId) { +const AbilityType& GetAbility(int ability_group_id) { + switch (ability_group_id) { case kAbilityTalentsId: return kAbilityGroupTalents; case kAbilitySkillsId: @@ -114,27 +102,27 @@ const AbilityType& GetAbility(int abilityGroupId) { return kAbilityGroupUnknown; } -const string GetAbilityLabel(int abilityGroupId, int abilityId) { - switch (abilityGroupId) { +const string GetAbilityLabel(int ability_group_id, int ability_id) { + switch (ability_group_id) { case kAbilityTalentsId: - return GetTalentLabel(abilityId); + return GetTalentLabel(ability_id); case kAbilitySkillsId: - return GetSkillLabel(abilityId); + return GetSkillLabel(ability_id); case kAbilityKnowledgesId: - return GetKnowledgeLabel(abilityId); + return GetKnowledgeLabel(ability_id); }; return ""; } -const std::string GetKnowledgeLabel(int talentId) { - if (talentId > 0 && talentId <= kKnowledgesCount) { - return kKnowledges[talentId]; +const std::string GetKnowledgeLabel(int talent_id) { + if (talent_id > 0 && talent_id <= kKnowledgesCount) { + return kKnowledges[talent_id]; } return ""; } -int GetNumItemsForAbilityGroup(int abilityGroupId) { - switch (abilityGroupId) { +int GetNumItemsForAbilityGroup(int ability_group_id) { + switch (ability_group_id) { case kAbilityTalentsId: return kTalentsCount; case kAbilitySkillsId: @@ -145,16 +133,16 @@ int GetNumItemsForAbilityGroup(int abilityGroupId) { return 0; } -const std::string GetSkillLabel(int skillId) { - if (skillId > 0 && skillId <= kSkillsCount) { - return kSkills[skillId]; +const std::string GetSkillLabel(int skill_id) { + if (skill_id > 0 && skill_id <= kSkillsCount) { + return kSkills[skill_id]; } return ""; } -const std::string GetTalentLabel(int talentId) { - if (talentId > 0 && talentId <= kTalentsCount) { - return kTalents[talentId]; +const std::string GetTalentLabel(int talent_id) { + if (talent_id > 0 && talent_id <= kTalentsCount) { + return kTalents[talent_id]; } return ""; } diff --git a/sbf-cpp/Abilities_test.cpp b/sbf-cpp/Abilities_test.cpp index 037428a..84f0d7e 100644 --- a/sbf-cpp/Abilities_test.cpp +++ b/sbf-cpp/Abilities_test.cpp @@ -145,44 +145,47 @@ TestResults test_FillAbilitiesForAbilityGroup() { make_test, int>( "should clear the vector for group 0, kAbilityGropuUnknownId", {}, make_tuple(0)), make_test, 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" + { + "Acting", + "Alertness", + "Athletics", + "Brawl", + "Dodge", + "Empathy", + "Intimidation", + "Leadership", + "Streetwise", + "Subterfuge", + }, //, "Alertness", "Athletics", "Brawl", "Dodge", "Empathy", + //"Intimidation", "Leadership", "Streetwise", "Subterfuge" make_tuple(1)), make_test, int>("should fill skills for group 2 kAbilityGroupSkillsId", - {"", - "Animal Ken", - "Drive", - "Etiquette", - "Firearms", - "Melee", - "Music", - "Repair", - "Security", - "Stealth", - "Survival"}, + { + "Animal Ken", + "Drive", + "Etiquette", + "Firearms", + "Melee", + "Music", + "Repair", + "Security", + "Stealth", + "Survival", + }, make_tuple(2)), make_test, int>("should fill knowledges for group 3 kAbilityGroupKnowledgesId", - {"", - "Bureaucracy", - "Computer", - "Finance", - "Investigation", - "Law", - "Linguistics", - "Medicine", - "Occult", - "Politics", - "Science"}, + { + "Bureaucracy", + "Computer", + "Finance", + "Investigation", + "Law", + "Linguistics", + "Medicine", + "Occult", + "Politics", + "Science", + }, make_tuple(3)), make_test, int>("should clear the vector for group 4 an invalid id", {}, make_tuple(4)), }))); @@ -200,43 +203,46 @@ TestResults test_FillAbilityLabels() { make_test, int>( "should clear the vector for group 0, kAbilityGropuUnknownId", {}, make_tuple(0)), make_test, int>("should fill talents for group 1 kAbilityGroupTalentsId", - {"", - "Acting", - "Alertness", - "Athletics", - "Brawl", - "Dodge", - "Empathy", - "Intimidation", - "Leadership", - "Streetwise", - "Subterfuge"}, + { + "Acting", + "Alertness", + "Athletics", + "Brawl", + "Dodge", + "Empathy", + "Intimidation", + "Leadership", + "Streetwise", + "Subterfuge", + }, make_tuple(1)), make_test, int>("should fill skills for group 2 kAbilityGroupSkillsId", - {"", - "Animal Ken", - "Drive", - "Etiquette", - "Firearms", - "Melee", - "Music", - "Repair", - "Security", - "Stealth", - "Survival"}, + { + "Animal Ken", + "Drive", + "Etiquette", + "Firearms", + "Melee", + "Music", + "Repair", + "Security", + "Stealth", + "Survival", + }, make_tuple(2)), make_test, int>("should fill knowledges for group 3 kAbilityGroupKnowledgesId", - {"", - "Bureaucracy", - "Computer", - "Finance", - "Investigation", - "Law", - "Linguistics", - "Medicine", - "Occult", - "Politics", - "Science"}, + { + "Bureaucracy", + "Computer", + "Finance", + "Investigation", + "Law", + "Linguistics", + "Medicine", + "Occult", + "Politics", + "Science", + }, make_tuple(3)), make_test, int>("should clear the vector for group 4 an invalid id", {}, make_tuple(4)), }))); @@ -248,17 +254,18 @@ TestResults test_FillKnowledgeLabels() { []() -> string { ostringstream error_message; vector actual = {"This should be removed."}; - vector expected = {"", - "Bureaucracy", - "Computer", - "Finance", - "Investigation", - "Law", - "Linguistics", - "Medicine", - "Occult", - "Politics", - "Science"}; + vector expected = { + "Bureaucracy", + "Computer", + "Finance", + "Investigation", + "Law", + "Linguistics", + "Medicine", + "Occult", + "Politics", + "Science", + }; FillKnowledgeLabels(actual); compare(error_message, expected, actual); string error = error_message.str(); @@ -278,17 +285,18 @@ TestResults test_FillSkillLabels() { []() -> string { ostringstream error_message; vector actual = {"This should be removed."}; - vector expected = {"", - "Animal Ken", - "Drive", - "Etiquette", - "Firearms", - "Melee", - "Music", - "Repair", - "Security", - "Stealth", - "Survival"}; + vector expected = { + "Animal Ken", + "Drive", + "Etiquette", + "Firearms", + "Melee", + "Music", + "Repair", + "Security", + "Stealth", + "Survival", + }; FillSkillLabels(actual); compare(error_message, expected, actual); string error = error_message.str(); @@ -308,17 +316,18 @@ TestResults test_FillTalentLabels() { []() -> string { ostringstream error_message; vector actual = {"This should be removed."}; - vector expected = {"", - "Acting", - "Alertness", - "Athletics", - "Brawl", - "Dodge", - "Empathy", - "Intimidation", - "Leadership", - "Streetwise", - "Subterfuge"}; + vector expected = { + "Acting", + "Alertness", + "Athletics", + "Brawl", + "Dodge", + "Empathy", + "Intimidation", + "Leadership", + "Streetwise", + "Subterfuge", + }; FillTalentLabels(actual); compare(error_message, expected, actual); string error = error_message.str(); diff --git a/sbf-cpp/Archetypes.cpp b/sbf-cpp/Archetypes.cpp index 1986c91..04ddc71 100644 --- a/sbf-cpp/Archetypes.cpp +++ b/sbf-cpp/Archetypes.cpp @@ -4,16 +4,16 @@ #include namespace SBF { -std::string GetArchetypeLabel(int archetypeId) { - if (archetypeId >= 0 && archetypeId <= kArchetypesCount) { - return kArchetypes[archetypeId]; +std::string GetArchetypeLabel(int archetype_id) { + if (archetype_id >= 0 && archetype_id <= kArchetypesCount) { + return kArchetypes[archetype_id]; } return ""; } void FillArchetypeLabels(std::vector& labels) { labels.clear(); - for (int id = 0; id <= kArchetypesCount; id++) { + for (int id = 1; id <= kArchetypesCount; id++) { labels.push_back(GetArchetypeLabel(id)); } } diff --git a/sbf-cpp/Archetypes_test.cpp b/sbf-cpp/Archetypes_test.cpp index a14316d..a3c167e 100644 --- a/sbf-cpp/Archetypes_test.cpp +++ b/sbf-cpp/Archetypes_test.cpp @@ -15,7 +15,7 @@ TestResults test_FillArchetypeLabels(); using namespace Test::Archetypes; -TestResults main_test_Archetypes(int argc, char** argv) { +TestResults main_test_Archetypes(int argc, char* argv[]) { TestResults results; results += test_GetArchetypeLabel(); @@ -70,11 +70,11 @@ TestResults test_FillArchetypeLabels() { "SBF::FillArchetypeLabels", []() -> string { ostringstream error_message; - vector expected = { - "", "Architect", "Autocrat", "Barbarian", "Bon Vivant", "Bravo", "Caregiver", "Caretaker", - "Celebrant", "Child", "Conformist", "Conniver", "Curmudgeon", "Defender", "Deviant", "Director", - "Fanatic", "Gallant", "Innovator", "Jester", "Judge", "Loaner", "Martyr", "Monster", - "Penitent", "Rebel", "Rogue", "Survivor", "Traditionalist", "Tyrant", "Visionary"}; + vector expected = {"Architect", "Autocrat", "Barbarian", "Bon Vivant", "Bravo", "Caregiver", + "Caretaker", "Celebrant", "Child", "Conformist", "Conniver", "Curmudgeon", + "Defender", "Deviant", "Director", "Fanatic", "Gallant", "Innovator", + "Jester", "Judge", "Loaner", "Martyr", "Monster", "Penitent", + "Rebel", "Rogue", "Survivor", "Traditionalist", "Tyrant", "Visionary"}; vector actual = {"This should be removed."}; FillArchetypeLabels(actual); compare(error_message, expected, actual); diff --git a/sbf-cpp/Attributes_test.cpp b/sbf-cpp/Attributes_test.cpp index 8551566..514701b 100644 --- a/sbf-cpp/Attributes_test.cpp +++ b/sbf-cpp/Attributes_test.cpp @@ -31,7 +31,7 @@ TestResults test_FillMentalAttributeLabels(); using namespace Test::Attributes; -TestResults main_test_Attributes(int argc, char** argv) { +TestResults main_test_Attributes(int argc, char* argv[]) { TestResults results; results += test_GetAttributeGroupLabel(); diff --git a/sbf-cpp/Backgrounds_test.cpp b/sbf-cpp/Backgrounds_test.cpp index eaa545a..396cf09 100644 --- a/sbf-cpp/Backgrounds_test.cpp +++ b/sbf-cpp/Backgrounds_test.cpp @@ -18,7 +18,7 @@ TestResults test_FillBackgroundLabels(); using namespace Test::Backgrounds; -TestResults main_test_Backgrounds(int argc, char** argv) { +TestResults main_test_Backgrounds(int argc, char* argv[]) { TestResults results; results += test_GetBackgroundLabel(); diff --git a/sbf-cpp/Character_test.cpp b/sbf-cpp/Character_test.cpp index 038a894..790a183 100644 --- a/sbf-cpp/Character_test.cpp +++ b/sbf-cpp/Character_test.cpp @@ -4,7 +4,7 @@ using namespace SBF; using namespace Test; -TestResults main_test_Character(int argc, char** argv) { +TestResults main_test_Character(int argc, char* argv[]) { TestResults results; return results; diff --git a/sbf-cpp/Clans.cpp b/sbf-cpp/Clans.cpp index 3edd4fb..9da8775 100644 --- a/sbf-cpp/Clans.cpp +++ b/sbf-cpp/Clans.cpp @@ -4,9 +4,9 @@ #include namespace SBF { -std::string GetClanLabel(int clanId) { - if (clanId > 0 && clanId <= kClansCount) { - return kClanLabels[clanId]; +std::string GetClanLabel(int clan_id) { + if (clan_id > 0 && clan_id <= kClansCount) { + return kClanLabels[clan_id]; } return ""; } diff --git a/sbf-cpp/Clans_test.cpp b/sbf-cpp/Clans_test.cpp index 05042b3..ab51a9e 100644 --- a/sbf-cpp/Clans_test.cpp +++ b/sbf-cpp/Clans_test.cpp @@ -18,7 +18,7 @@ TestResults test_FillClanLabels(); using namespace Test::Clans; -TestResults main_test_Clans(int argc, char** argv) { +TestResults main_test_Clans(int argc, char* argv[]) { TestResults results; results += test_GetClanLabel(); diff --git a/sbf-cpp/Colors_test.cpp b/sbf-cpp/Colors_test.cpp index e39a127..76be409 100644 --- a/sbf-cpp/Colors_test.cpp +++ b/sbf-cpp/Colors_test.cpp @@ -25,7 +25,7 @@ extern uint8_t g_foregroundColor; extern uint8_t g_backgroundColor; } // namespace SBF -TestResults main_test_Colors(int argc, char** argv) { +TestResults main_test_Colors(int argc, char* argv[]) { TestResults results; results += test_FillColors(); diff --git a/sbf-cpp/Derangements.cpp b/sbf-cpp/Derangements.cpp index 5d87de1..daaebb3 100644 --- a/sbf-cpp/Derangements.cpp +++ b/sbf-cpp/Derangements.cpp @@ -27,7 +27,7 @@ DerangementType GetDerangement(int derangementId) { if (derangementId > 0 && derangementId <= kDerangementsCount) { return kDerangements[derangementId]; } - return {}; + return kDerangementUnknown; } void FillDerangements(std::vector& derangements) { diff --git a/sbf-cpp/Derangements_test.cpp b/sbf-cpp/Derangements_test.cpp index 8521b2b..cec5068 100644 --- a/sbf-cpp/Derangements_test.cpp +++ b/sbf-cpp/Derangements_test.cpp @@ -21,7 +21,7 @@ TestResults test_FillDerangements(); using namespace Test::Derangements; -TestResults main_test_Derangements(int argc, char** argv) { +TestResults main_test_Derangements(int argc, char* argv[]) { TestResults results; results += test_DerangementType_operator_extract(); diff --git a/sbf-cpp/Disciplines_test.cpp b/sbf-cpp/Disciplines_test.cpp index 1626838..97b8b28 100644 --- a/sbf-cpp/Disciplines_test.cpp +++ b/sbf-cpp/Disciplines_test.cpp @@ -18,7 +18,7 @@ TestResults test_FillDisciplineLabels(); using namespace Test::Disciplines; -TestResults main_test_Disciplines(int argc, char** argv) { +TestResults main_test_Disciplines(int argc, char* argv[]) { TestResults results; results += test_GetDisciplineLabel(); diff --git a/sbf-cpp/Genders_test.cpp b/sbf-cpp/Genders_test.cpp index 8237dc8..7198d89 100644 --- a/sbf-cpp/Genders_test.cpp +++ b/sbf-cpp/Genders_test.cpp @@ -18,7 +18,7 @@ TestResults test_FillGenderLabels(); using namespace Test::Genders; -TestResults main_test_Genders(int argc, char** argv) { +TestResults main_test_Genders(int argc, char* argv[]) { TestResults results; results += test_GetGenderLabel(); diff --git a/sbf-cpp/Ranks.cpp b/sbf-cpp/Ranks.cpp index 34b2bfb..7fb0372 100644 --- a/sbf-cpp/Ranks.cpp +++ b/sbf-cpp/Ranks.cpp @@ -5,10 +5,13 @@ #include namespace SBF { +namespace { +using std::ostream; using std::string; using std::vector; +} // End namespace -std::ostream& operator<<(std::ostream& os, const RankType& rank) { +ostream& operator<<(ostream& os, const RankType& rank) { os << "Rank: {id: " << rank.id << ", label: \"" << rank.label << "\"}"; return os; } diff --git a/sbf-cpp/Ranks_test.cpp b/sbf-cpp/Ranks_test.cpp index b0311ea..ac98609 100644 --- a/sbf-cpp/Ranks_test.cpp +++ b/sbf-cpp/Ranks_test.cpp @@ -21,7 +21,7 @@ TestResults test_FillRanks(); using namespace Test::Ranks; -TestResults main_test_Ranks(int argc, char** argv) { +TestResults main_test_Ranks(int argc, char* argv[]) { TestResults results; results += test_RankType_operator_extract(); diff --git a/sbf-cpp/Utils_test.cpp b/sbf-cpp/Utils_test.cpp index 74adee8..01e889e 100644 --- a/sbf-cpp/Utils_test.cpp +++ b/sbf-cpp/Utils_test.cpp @@ -21,7 +21,7 @@ TestResults test_word_wrap(); using namespace Test::Utils; -TestResults main_test_Utils(int argc, char** argv) { +TestResults main_test_Utils(int argc, char* argv[]) { TestResults results; results += test_get_index_of(); diff --git a/sbf-cpp/Virtues_test.cpp b/sbf-cpp/Virtues_test.cpp index b6d320f..b9a9845 100644 --- a/sbf-cpp/Virtues_test.cpp +++ b/sbf-cpp/Virtues_test.cpp @@ -17,7 +17,7 @@ TestResults test_FillVirtueLabels(); using namespace Test::Virtues; -TestResults main_test_Virtues(int argc, char** argv) { +TestResults main_test_Virtues(int argc, char* argv[]) { TestResults results; results += test_GetVirtueLabel(); diff --git a/sbf-cpp/test.cpp b/sbf-cpp/test.cpp index 3024dc2..23a4c46 100644 --- a/sbf-cpp/test.cpp +++ b/sbf-cpp/test.cpp @@ -88,9 +88,9 @@ namespace Test { // ); // The suites can be run from one file as such. From a file called ThingDoer_test.cpp to test the class/methods // ThingDoer declared in ThingDoer.cpp. This isn't mandatory but is a best practice. You can use testFn without calling -// collect_and_report_TestResults() and also could call it from a normal int main(int argc, char** argv) or other +// collect_and_report_TestResults() and also could call it from a normal int main(int argc, char* argv[]) or other // function. -// TestResults test_main_ThingDoer(int argc, char** argv) { +// TestResults test_main_ThingDoer(int argc, char* argv[]) { // TestResults results; // results = collect_and_report_TestResults(results, testFn("doThing1", ...), argc, argv); // results = collect_and_report_TestResults(results, testFn("doThing2", ...), argc, argv); diff --git a/sbf-cpp/test.h b/sbf-cpp/test.h index b0d88b6..8ce7116 100644 --- a/sbf-cpp/test.h +++ b/sbf-cpp/test.h @@ -293,7 +293,7 @@ using TestSuite = std::tuple