Removes unknown values from fill functions.

Indexes will no longer match Ids.
Updated all tests to use char* argv[] instead of char** argv.
This commit is contained in:
2023-04-22 00:38:48 -07:00
parent e8e9904de3
commit 1f45248ccd
20 changed files with 171 additions and 171 deletions

View File

@@ -34,24 +34,18 @@ void FillAbilitiesForAbilityGroup(vector<string>& 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<string>& labels, int id) {
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]);
}
for (int knowledge_id = 1; knowledge_id <= numAbilities; knowledge_id++) {
labels.push_back(GetKnowledgeLabel(knowledge_id));
}
}
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]);
}
for (int skill_id = 1; skill_id <= numAbilities; skill_id++) {
labels.push_back(GetSkillLabel(skill_id));
}
}
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]);
}
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 "";
}

View File

@@ -145,7 +145,7 @@ TestResults test_FillAbilitiesForAbilityGroup() {
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",
@@ -155,11 +155,12 @@ TestResults test_FillAbilitiesForAbilityGroup() {
"Intimidation",
"Leadership",
"Streetwise",
"Subterfuge"}, //, "Alertness", "Athletics", "Brawl", "Dodge", "Empathy",
"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",
@@ -169,10 +170,11 @@ TestResults test_FillAbilitiesForAbilityGroup() {
"Repair",
"Security",
"Stealth",
"Survival"},
"Survival",
},
make_tuple(2)),
make_test<vector<string>, int>("should fill knowledges for group 3 kAbilityGroupKnowledgesId",
{"",
{
"Bureaucracy",
"Computer",
"Finance",
@@ -182,7 +184,8 @@ TestResults test_FillAbilitiesForAbilityGroup() {
"Medicine",
"Occult",
"Politics",
"Science"},
"Science",
},
make_tuple(3)),
make_test<vector<string>, int>("should clear the vector for group 4 an invalid id", {}, make_tuple(4)),
})));
@@ -200,7 +203,7 @@ TestResults test_FillAbilityLabels() {
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",
@@ -210,10 +213,11 @@ TestResults test_FillAbilityLabels() {
"Intimidation",
"Leadership",
"Streetwise",
"Subterfuge"},
"Subterfuge",
},
make_tuple(1)),
make_test<vector<string>, int>("should fill skills for group 2 kAbilityGroupSkillsId",
{"",
{
"Animal Ken",
"Drive",
"Etiquette",
@@ -223,10 +227,11 @@ TestResults test_FillAbilityLabels() {
"Repair",
"Security",
"Stealth",
"Survival"},
"Survival",
},
make_tuple(2)),
make_test<vector<string>, int>("should fill knowledges for group 3 kAbilityGroupKnowledgesId",
{"",
{
"Bureaucracy",
"Computer",
"Finance",
@@ -236,7 +241,8 @@ TestResults test_FillAbilityLabels() {
"Medicine",
"Occult",
"Politics",
"Science"},
"Science",
},
make_tuple(3)),
make_test<vector<string>, int>("should clear the vector for group 4 an invalid id", {}, make_tuple(4)),
})));
@@ -248,7 +254,7 @@ TestResults test_FillKnowledgeLabels() {
[]() -> string {
ostringstream error_message;
vector<string> actual = {"This should be removed."};
vector<string> expected = {"",
vector<string> expected = {
"Bureaucracy",
"Computer",
"Finance",
@@ -258,7 +264,8 @@ TestResults test_FillKnowledgeLabels() {
"Medicine",
"Occult",
"Politics",
"Science"};
"Science",
};
FillKnowledgeLabels(actual);
compare(error_message, expected, actual);
string error = error_message.str();
@@ -278,7 +285,7 @@ TestResults test_FillSkillLabels() {
[]() -> string {
ostringstream error_message;
vector<string> actual = {"This should be removed."};
vector<string> expected = {"",
vector<string> expected = {
"Animal Ken",
"Drive",
"Etiquette",
@@ -288,7 +295,8 @@ TestResults test_FillSkillLabels() {
"Repair",
"Security",
"Stealth",
"Survival"};
"Survival",
};
FillSkillLabels(actual);
compare(error_message, expected, actual);
string error = error_message.str();
@@ -308,7 +316,7 @@ TestResults test_FillTalentLabels() {
[]() -> string {
ostringstream error_message;
vector<string> actual = {"This should be removed."};
vector<string> expected = {"",
vector<string> expected = {
"Acting",
"Alertness",
"Athletics",
@@ -318,7 +326,8 @@ TestResults test_FillTalentLabels() {
"Intimidation",
"Leadership",
"Streetwise",
"Subterfuge"};
"Subterfuge",
};
FillTalentLabels(actual);
compare(error_message, expected, actual);
string error = error_message.str();

View File

@@ -4,16 +4,16 @@
#include <vector>
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<std::string>& labels) {
labels.clear();
for (int id = 0; id <= kArchetypesCount; id++) {
for (int id = 1; id <= kArchetypesCount; id++) {
labels.push_back(GetArchetypeLabel(id));
}
}

View File

@@ -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<string> 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<string> 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<string> actual = {"This should be removed."};
FillArchetypeLabels(actual);
compare(error_message, expected, actual);

View File

@@ -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();

View File

@@ -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();

View File

@@ -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;

View File

@@ -4,9 +4,9 @@
#include <vector>
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 "";
}

View File

@@ -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();

View File

@@ -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();

View File

@@ -27,7 +27,7 @@ DerangementType GetDerangement(int derangementId) {
if (derangementId > 0 && derangementId <= kDerangementsCount) {
return kDerangements[derangementId];
}
return {};
return kDerangementUnknown;
}
void FillDerangements(std::vector<DerangementType>& derangements) {

View File

@@ -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();

View File

@@ -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();

View File

@@ -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();

View File

@@ -5,10 +5,13 @@
#include <vector>
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;
}

View File

@@ -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();

View File

@@ -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();

View File

@@ -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();

View File

@@ -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);

View File

@@ -293,7 +293,7 @@ using TestSuite = std::tuple<std::string,
// ThingDoer declared in ThingDoer.cpp. This isn't mandatory but is a best practice. You can use function_to_test
// without calling collect_and_report_test_results() 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_test_results(results, function_to_test("do_thing1", ...), argc, argv);
// results = collect_and_report_test_results(results, function_to_test("do_thing2", ...), argc, argv);