diff --git a/sbf-cpp/Disciplines.cpp b/sbf-cpp/Disciplines.cpp index e69de29..958499f 100644 --- a/sbf-cpp/Disciplines.cpp +++ b/sbf-cpp/Disciplines.cpp @@ -0,0 +1,23 @@ +#include "Disciplines.h" +#include +#include + +namespace SBF { +using std::string; +using std::vector; + +string GetDisciplineLabel(int disciplineId) { + if (disciplineId > 0 && disciplineId <= kDisciplinesCount) { + return kDisciplines[disciplineId]; + } + + return ""; +} + +void FillDisciplineLabels(vector& labels) { + labels.clear(); + for (int id = 1; id <= kDisciplinesCount; id++) { + labels.push_back(GetDisciplineLabel(id)); + } +} +} // End namespace SBF diff --git a/sbf-cpp/Disciplines.h b/sbf-cpp/Disciplines.h index d26a924..be8adab 100644 --- a/sbf-cpp/Disciplines.h +++ b/sbf-cpp/Disciplines.h @@ -93,8 +93,8 @@ namespace SBF { kDisciplineThaumaturgyLabel, kDisciplineVicissitudeLabel, }; - const std::string GetDisciplineLabel(int disciplineId); - void FillDisciplineLabels(std::vector disciplineLabels); + std::string GetDisciplineLabel(int disciplineId); + void FillDisciplineLabels(std::vector& disciplineLabels); } // End namespace SBF /** @}*/ #endif // End !defined DISCIPLINES_H__ diff --git a/sbf-cpp/Disciplines_test.cpp b/sbf-cpp/Disciplines_test.cpp index c51083f..f2a895d 100644 --- a/sbf-cpp/Disciplines_test.cpp +++ b/sbf-cpp/Disciplines_test.cpp @@ -1,10 +1,190 @@ #include "Disciplines.h" #include "test.h" +#include +#include +#include +#include + using namespace SBF; 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 results; + results += test_GetDisciplineLabel(); + results += test_FillDisciplineLabels(); + return results; } + +namespace Test::Disciplines { +TestResults test_GetDisciplineLabel() { + return execute_suite(make_test_suite( + "SBF::GetDisciplineLabel", + GetDisciplineLabel, + vector>({ + make_test( + "should get \"\" for invalid discipline id 0", + "", + make_tuple(0)), + make_test( + "should get \"Animalism\" for id 1", + "Animalism", + make_tuple(1)), + make_test( + "should get \"Auspex\" for id 2", + "Auspex", + make_tuple(2)), + make_test( + "should get \"Bardo\" for id 3", + "Bardo", + make_tuple(3)), + make_test( + "should get \"Celerity\" for id 4", + "Celerity", + make_tuple(4)), + make_test( + "should get \"Chimestry\" for id 5", + "Chimestry", + make_tuple(5)), + make_test( + "should get \"Dementation\" for id 6", + "Dementation", + make_tuple(6)), + make_test( + "should get \"Dominate\" for id 7", + "Dominate", + make_tuple(7)), + make_test( + "should get \"Fortitude\" for id 8", + "Fortitude", + make_tuple(8)), + make_test( + "should get \"Melpominee\" for id 9", + "Melpominee", + make_tuple(9)), + make_test( + "should get \"Mortis\" for id 10", + "Mortis", + make_tuple(10)), + make_test( + "should get \"Mytherceria\" for id 11", + "Mytherceria", + make_tuple(11)), + make_test( + "should get \"Necromancy\" for id 12", + "Necromancy", + make_tuple(12)), + make_test( + "should get \"Obeah\" for id 13", + "Obeah", + make_tuple(13)), + make_test( + "should get \"Obfuscate\" for id 14", + "Obfuscate", + make_tuple(14)), + make_test( + "should get \"Obtenebration\" for id 15", + "Obtenebration", + make_tuple(15)), + make_test( + "should get \"Potence\" for id 16", + "Potence", + make_tuple(16)), + make_test( + "should get \"Presence\" for id 17", + "Presence", + make_tuple(17)), + make_test( + "should get \"Protean\" for id 18", + "Protean", + make_tuple(18)), + make_test( + "should get \"Quietus\" for id 19", + "Quietus", + make_tuple(19)), + make_test( + "should get \"Serpentis\" for id 20", + "Serpentis", + make_tuple(20)), + make_test( + "should get \"Spiritus\" for id 21", + "Spiritus", + make_tuple(21)), + make_test( + "should get \"Thanantosis\" for id 22", + "Thanantosis", + make_tuple(22)), + make_test( + "should get \"Thaumaturgy\" for id 23", + "Thaumaturgy", + make_tuple(23)), + make_test( + "should get \"Vicissitude\" for id 24", + "Vicissitude", + make_tuple(24)), + make_test( + "should get \"\" for invalid discipline id 25", + "", + make_tuple(25)), + }) + )); +} + +TestResults test_FillDisciplineLabels() { + auto fnToTest = []()->string { + ostringstream error_message; + vector 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 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(make_test_suite( + "SBF::FillDisciplineLabels", + fnToTest, + vector>({ + make_test( + "should fill disciplines", + "no errors", + make_tuple()), + }) + )); +} +} // End namespace Test::Disciplines