Implements disciplines and tests.

This commit is contained in:
2023-04-17 18:28:31 -07:00
parent 018cce461d
commit f8394a8d03
3 changed files with 205 additions and 2 deletions

View File

@@ -0,0 +1,23 @@
#include "Disciplines.h"
#include <string>
#include <vector>
namespace SBF {
using std::string;
using std::vector;
string GetDisciplineLabel(int disciplineId) {
if (disciplineId > 0 && disciplineId <= kDisciplinesCount) {
return kDisciplines[disciplineId];
}
return "";
}
void FillDisciplineLabels(vector<string>& labels) {
labels.clear();
for (int id = 1; id <= kDisciplinesCount; id++) {
labels.push_back(GetDisciplineLabel(id));
}
}
} // End namespace SBF

View File

@@ -93,8 +93,8 @@ namespace SBF {
kDisciplineThaumaturgyLabel, kDisciplineThaumaturgyLabel,
kDisciplineVicissitudeLabel, kDisciplineVicissitudeLabel,
}; };
const std::string GetDisciplineLabel(int disciplineId); std::string GetDisciplineLabel(int disciplineId);
void FillDisciplineLabels(std::vector<std::string> disciplineLabels); void FillDisciplineLabels(std::vector<std::string>& disciplineLabels);
} // End namespace SBF } // End namespace SBF
/** @}*/ /** @}*/
#endif // End !defined DISCIPLINES_H__ #endif // End !defined DISCIPLINES_H__

View File

@@ -1,10 +1,190 @@
#include "Disciplines.h" #include "Disciplines.h"
#include "test.h" #include "test.h"
#include <string>
#include <tuple>
#include <vector>
#include <sstream>
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std;
namespace Test::Disciplines {
TestResults test_GetDisciplineLabel();
TestResults test_FillDisciplineLabels();
} // End namespace Test::Disciplines
using namespace Test::Disciplines;
TestResults main_test_Disciplines(int argc, char** argv) { TestResults main_test_Disciplines(int argc, char** argv) {
TestResults results; TestResults results;
results += test_GetDisciplineLabel();
results += test_FillDisciplineLabels();
return results; return results;
} }
namespace Test::Disciplines {
TestResults test_GetDisciplineLabel() {
return execute_suite<string, int>(make_test_suite(
"SBF::GetDisciplineLabel",
GetDisciplineLabel,
vector<TestTuple<string, int>>({
make_test<string, int>(
"should get \"\" for invalid discipline id 0",
"",
make_tuple(0)),
make_test<string, int>(
"should get \"Animalism\" for id 1",
"Animalism",
make_tuple(1)),
make_test<string, int>(
"should get \"Auspex\" for id 2",
"Auspex",
make_tuple(2)),
make_test<string, int>(
"should get \"Bardo\" for id 3",
"Bardo",
make_tuple(3)),
make_test<string, int>(
"should get \"Celerity\" for id 4",
"Celerity",
make_tuple(4)),
make_test<string, int>(
"should get \"Chimestry\" for id 5",
"Chimestry",
make_tuple(5)),
make_test<string, int>(
"should get \"Dementation\" for id 6",
"Dementation",
make_tuple(6)),
make_test<string, int>(
"should get \"Dominate\" for id 7",
"Dominate",
make_tuple(7)),
make_test<string, int>(
"should get \"Fortitude\" for id 8",
"Fortitude",
make_tuple(8)),
make_test<string, int>(
"should get \"Melpominee\" for id 9",
"Melpominee",
make_tuple(9)),
make_test<string, int>(
"should get \"Mortis\" for id 10",
"Mortis",
make_tuple(10)),
make_test<string, int>(
"should get \"Mytherceria\" for id 11",
"Mytherceria",
make_tuple(11)),
make_test<string, int>(
"should get \"Necromancy\" for id 12",
"Necromancy",
make_tuple(12)),
make_test<string, int>(
"should get \"Obeah\" for id 13",
"Obeah",
make_tuple(13)),
make_test<string, int>(
"should get \"Obfuscate\" for id 14",
"Obfuscate",
make_tuple(14)),
make_test<string, int>(
"should get \"Obtenebration\" for id 15",
"Obtenebration",
make_tuple(15)),
make_test<string, int>(
"should get \"Potence\" for id 16",
"Potence",
make_tuple(16)),
make_test<string, int>(
"should get \"Presence\" for id 17",
"Presence",
make_tuple(17)),
make_test<string, int>(
"should get \"Protean\" for id 18",
"Protean",
make_tuple(18)),
make_test<string, int>(
"should get \"Quietus\" for id 19",
"Quietus",
make_tuple(19)),
make_test<string, int>(
"should get \"Serpentis\" for id 20",
"Serpentis",
make_tuple(20)),
make_test<string, int>(
"should get \"Spiritus\" for id 21",
"Spiritus",
make_tuple(21)),
make_test<string, int>(
"should get \"Thanantosis\" for id 22",
"Thanantosis",
make_tuple(22)),
make_test<string, int>(
"should get \"Thaumaturgy\" for id 23",
"Thaumaturgy",
make_tuple(23)),
make_test<string, int>(
"should get \"Vicissitude\" for id 24",
"Vicissitude",
make_tuple(24)),
make_test<string, int>(
"should get \"\" for invalid discipline id 25",
"",
make_tuple(25)),
})
));
}
TestResults test_FillDisciplineLabels() {
auto fnToTest = []()->string {
ostringstream error_message;
vector<string> expected = {
kDisciplineAnimalismLabel,
kDisciplineAuspexLabel,
kDisciplineBardoLabel,
kDisciplineCelerityLabel,
kDisciplineChimestryLabel,
kDisciplineDementationLabel,
kDisciplineDominateLabel,
kDisciplineFortitudeLabel,
kDisciplineMelpomineeLabel,
kDisciplineMortisLabel,
kDisciplineMytherceriaLabel,
kDisciplineNecromancyLabel,
kDisciplineObeahLabel,
kDisciplineObfuscateLabel,
kDisciplineObtenebrationLabel,
kDisciplinePotenceLabel,
kDisciplinePresenceLabel,
kDisciplineProteanLabel,
kDisciplineQuietusLabel,
kDisciplineSerpentisLabel,
kDisciplineSpiritusLabel,
kDisciplineThanantosisLabel,
kDisciplineThaumaturgyLabel,
kDisciplineVicissitudeLabel,
};
vector<string> actual = {"This should be removed."};
FillDisciplineLabels(actual);
compare(error_message, expected, actual);
string error = error_message.str();
if (error.size() > 0) {
return error;
}
return "no errors";
};
return execute_suite<string>(make_test_suite(
"SBF::FillDisciplineLabels",
fnToTest,
vector<TestTuple<string>>({
make_test<string>(
"should fill disciplines",
"no errors",
make_tuple()),
})
));
}
} // End namespace Test::Disciplines