diff --git a/sbf-cpp/Abilities_test.cpp b/sbf-cpp/Abilities_test.cpp index b723866..ca1069a 100644 --- a/sbf-cpp/Abilities_test.cpp +++ b/sbf-cpp/Abilities_test.cpp @@ -4,61 +4,13 @@ #include #include "test.h" + +namespace { using namespace SBF; using namespace Test; using namespace std; +} // End namespace -namespace Test::Abilities { -TestResults test_AbilityType_operator_extract(); -TestResults test_AbilityType_operator_equal_to(); -TestResults test_AbilityType_operator_not_equal_to(); -TestResults test_FillAbilities(); -TestResults test_FillAbilitiesForAbilityGroup(); -TestResults test_FillAbilityLabels(); -TestResults test_FillKnowledgeLabels(); -TestResults test_FillSkillLabels(); -TestResults test_FillTalentLabels(); -TestResults test_GetAbility(); -TestResults test_GetAbilityLabel(); -TestResults test_GetKnowledgeLabel(); -TestResults test_GetNumItemsForAbilityGroup(); -TestResults test_GetSkillLabel(); -TestResults test_GetTalentLabel(); -} // End namespace Test::Abilities - -using namespace Test::Abilities; - -TestResults main_test_Abilities(int argc, char* argv[]) { - TestResults results; - - results += test_AbilityType_operator_extract(); - results += test_AbilityType_operator_equal_to(); - results += test_AbilityType_operator_not_equal_to(); - results += test_FillAbilities(); - results += test_FillAbilitiesForAbilityGroup(); - results += test_FillAbilityLabels(); - results += test_FillKnowledgeLabels(); - results += test_FillSkillLabels(); - results += test_FillTalentLabels(); - results += test_GetAbility(); - results += test_GetAbilityLabel(); - results += test_GetKnowledgeLabel(); - results += test_GetNumItemsForAbilityGroup(); - results += test_GetSkillLabel(); - results += test_GetTalentLabel(); - - return results; -} - -int main(int argc, char* argv[]) { - TestResults results = main_test_Abilities(argc, argv); - - PrintResults(cout, results); - - return results.failed() + results.errors(); -} - -namespace Test::Abilities { TestResults test_AbilityType_operator_extract() { return execute_suite(make_test_suite( "SBF::AbilityType::operator<<", @@ -478,4 +430,27 @@ TestResults test_GetTalentLabel() { make_test("should get and empty string for id 11", "", make_tuple(11)), }))); } -} // End namespace Test::Abilities + +int main(int argc, char* argv[]) { + TestResults results; + + results += test_AbilityType_operator_extract(); + results += test_AbilityType_operator_equal_to(); + results += test_AbilityType_operator_not_equal_to(); + results += test_FillAbilities(); + results += test_FillAbilitiesForAbilityGroup(); + results += test_FillAbilityLabels(); + results += test_FillKnowledgeLabels(); + results += test_FillSkillLabels(); + results += test_FillTalentLabels(); + results += test_GetAbility(); + results += test_GetAbilityLabel(); + results += test_GetKnowledgeLabel(); + results += test_GetNumItemsForAbilityGroup(); + results += test_GetSkillLabel(); + results += test_GetTalentLabel(); + + PrintResults(cout, results); + + return results.failed() + results.errors(); +} diff --git a/sbf-cpp/Archetypes_test.cpp b/sbf-cpp/Archetypes_test.cpp index 7f80d69..e7aafb4 100644 --- a/sbf-cpp/Archetypes_test.cpp +++ b/sbf-cpp/Archetypes_test.cpp @@ -4,35 +4,13 @@ #include #include "test.h" + +namespace { using namespace SBF; using namespace Test; using namespace std; +} // End namespace -namespace Test::Archetypes { -TestResults test_GetArchetypeLabel(); -TestResults test_FillArchetypeLabels(); -} // End namespace Test::Archetypes - -using namespace Test::Archetypes; - -TestResults main_test_Archetypes(int argc, char* argv[]) { - TestResults results; - - results += test_GetArchetypeLabel(); - results += test_FillArchetypeLabels(); - - return results; -} - -int main(int argc, char* argv[]) { - TestResults results = main_test_Archetypes(argc, argv); - - PrintResults(cout, results); - - return results.failed() + results.errors(); -} - -namespace Test::Archetypes { TestResults test_GetArchetypeLabel() { return execute_suite(make_test_suite( "SBF::GetArchetypeLabel", @@ -96,4 +74,14 @@ TestResults test_FillArchetypeLabels() { make_test("should fill archetype labels", "no errors", make_tuple()), }))); } -} // End namespace Test::Archetypes + +int main(int argc, char* argv[]) { + TestResults results; + + results += test_GetArchetypeLabel(); + results += test_FillArchetypeLabels(); + + PrintResults(cout, results); + + return results.failed() + results.errors(); +} diff --git a/sbf-cpp/Attributes_test.cpp b/sbf-cpp/Attributes_test.cpp index e8682bd..fe60143 100644 --- a/sbf-cpp/Attributes_test.cpp +++ b/sbf-cpp/Attributes_test.cpp @@ -8,61 +8,12 @@ #include "test.h" +namespace { using namespace SBF; using namespace Test; using namespace std; +} // End namespace -namespace Test::Attributes { -TestResults test_GetAttributeGroupLabel(); -TestResults test_GetAttributeLabel(); -TestResults test_GetAttributeLabelAbbreviation(); -TestResults test_GetNumAttributesInGroup(); -TestResults test_GetPhysicalAttributeLabel(); -TestResults test_GetPhysicalAttributeLabelAbbreviation(); -TestResults test_GetSocialAttributeLabel(); -TestResults test_GetSocialAttributeLabelAbbreviation(); -TestResults test_GetMentalAttributeLabel(); -TestResults test_GetMentalAttributeLabelAbbreviation(); -TestResults test_FillAttributeGroupLabels(); -TestResults test_FillAttributeLabelsInGroup(); -TestResults test_FillPhysicalAttributeLabels(); -TestResults test_FillSocialAttributeLabels(); -TestResults test_FillMentalAttributeLabels(); -} // End namespace Test::Attributes - -using namespace Test::Attributes; - -TestResults main_test_Attributes(int argc, char* argv[]) { - TestResults results; - - results += test_GetAttributeGroupLabel(); - results += test_GetAttributeLabel(); - results += test_GetAttributeLabelAbbreviation(); - results += test_GetNumAttributesInGroup(); - results += test_GetPhysicalAttributeLabel(); - results += test_GetPhysicalAttributeLabelAbbreviation(); - results += test_GetSocialAttributeLabel(); - results += test_GetSocialAttributeLabelAbbreviation(); - results += test_GetMentalAttributeLabel(); - results += test_GetMentalAttributeLabelAbbreviation(); - results += test_FillAttributeGroupLabels(); - results += test_FillAttributeLabelsInGroup(); - results += test_FillPhysicalAttributeLabels(); - results += test_FillSocialAttributeLabels(); - results += test_FillMentalAttributeLabels(); - - return results; -} - -int main(int argc, char* argv[]) { - TestResults results = main_test_Attributes(argc, argv); - - PrintResults(cout, results); - - return results.failed() + results.errors(); -} - -namespace Test::Attributes { TestResults test_GetAttributeGroupLabel() { return execute_suite( make_test_suite("SBF::GetAttributeGroupLabel", @@ -330,4 +281,27 @@ TestResults test_FillMentalAttributeLabels() { make_test("should fill mental attribute labels", "no errors", make_tuple()), }))); } -} // namespace Test::Attributes + +int main(int argc, char* argv[]) { + TestResults results; + + results += test_GetAttributeGroupLabel(); + results += test_GetAttributeLabel(); + results += test_GetAttributeLabelAbbreviation(); + results += test_GetNumAttributesInGroup(); + results += test_GetPhysicalAttributeLabel(); + results += test_GetPhysicalAttributeLabelAbbreviation(); + results += test_GetSocialAttributeLabel(); + results += test_GetSocialAttributeLabelAbbreviation(); + results += test_GetMentalAttributeLabel(); + results += test_GetMentalAttributeLabelAbbreviation(); + results += test_FillAttributeGroupLabels(); + results += test_FillAttributeLabelsInGroup(); + results += test_FillPhysicalAttributeLabels(); + results += test_FillSocialAttributeLabels(); + results += test_FillMentalAttributeLabels(); + + PrintResults(cout, results); + + return results.failed() + results.errors(); +} diff --git a/sbf-cpp/Backgrounds_test.cpp b/sbf-cpp/Backgrounds_test.cpp index c2e15c9..aaf442c 100644 --- a/sbf-cpp/Backgrounds_test.cpp +++ b/sbf-cpp/Backgrounds_test.cpp @@ -8,35 +8,12 @@ #include "test.h" +namespace { using namespace SBF; using namespace Test; using namespace std; +} // namespace -namespace Test::Backgrounds { -TestResults test_GetBackgroundLabel(); -TestResults test_FillBackgroundLabels(); -} // namespace Test::Backgrounds - -using namespace Test::Backgrounds; - -TestResults main_test_Backgrounds(int argc, char* argv[]) { - TestResults results; - - results += test_GetBackgroundLabel(); - results += test_FillBackgroundLabels(); - - return results; -} - -int main(int argc, char* argv[]) { - TestResults results = main_test_Backgrounds(argc, argv); - - PrintResults(cout, results); - - return results.failed() + results.errors(); -} - -namespace Test::Backgrounds { TestResults test_GetBackgroundLabel() { return execute_suite(make_test_suite( "SBF::GetBackgroundLabel", @@ -95,4 +72,14 @@ TestResults test_FillBackgroundLabels() { )); } -} // End namespace Test::Backgrounds + +int main(int argc, char* argv[]) { + TestResults results; + + results += test_GetBackgroundLabel(); + results += test_FillBackgroundLabels(); + + PrintResults(cout, results); + + return results.failed() + results.errors(); +} diff --git a/sbf-cpp/Clans_test.cpp b/sbf-cpp/Clans_test.cpp index 32e75b7..e680112 100644 --- a/sbf-cpp/Clans_test.cpp +++ b/sbf-cpp/Clans_test.cpp @@ -8,35 +8,12 @@ #include "test.h" +namespace { using namespace SBF; using namespace Test; using namespace std; +} // End namespace -namespace Test::Clans { -TestResults test_GetClanLabel(); -TestResults test_FillClanLabels(); -} // End namespace Test::Clans - -using namespace Test::Clans; - -TestResults main_test_Clans(int argc, char* argv[]) { - TestResults results; - - results += test_GetClanLabel(); - results += test_FillClanLabels(); - - PrintResults(cout, results); - - return results; -} - -int main(int argc, char* argv[]) { - TestResults results = main_test_Clans(argc, argv); - - return results.failed() + results.errors(); -} - -namespace Test::Clans { TestResults test_GetClanLabel() { return execute_suite(make_test_suite( "SBF::GetClanLabel", @@ -104,4 +81,12 @@ TestResults test_FillClanLabels() { )); } -} // End namespace Test::Clans + +int main(int argc, char* argv[]) { + TestResults results; + + results += test_GetClanLabel(); + results += test_FillClanLabels(); + + return results.failed() + results.errors(); +} diff --git a/sbf-cpp/Colors_test.cpp b/sbf-cpp/Colors_test.cpp index 28cb857..ebc9ad0 100644 --- a/sbf-cpp/Colors_test.cpp +++ b/sbf-cpp/Colors_test.cpp @@ -8,59 +8,21 @@ #include "test.h" +namespace { using namespace SBF; using namespace Test; using namespace std; - -namespace Test::Colors { -TestResults test_FillColors(); -TestResults test_GetBackgroundColor(); -TestResults test_GetForegroundColor(); -TestResults test_SetBackgroundColor(); -TestResults test_SetForegroundColor(); -TestResults test_Reset(); -TestResults test_ForegroundColor(); -TestResults test_BackgroundColor(); -TestResults test_Colors(); -TestResults test_TrueColorForeground(); -TestResults test_TrueColorBackground(); -string escape_string(const string& text, const string& pattern = "\033", const string& replace = "\\033"); -} // End namespace Test::Colors - -using namespace Test::Colors; +} // End namespace namespace SBF { extern uint8_t g_foreground_color; extern uint8_t g_background_color; } // namespace SBF -TestResults main_test_Colors(int argc, char* argv[]) { - TestResults results; - - results += test_FillColors(); - results += test_GetBackgroundColor(); - results += test_GetForegroundColor(); - results += test_SetBackgroundColor(); - results += test_SetForegroundColor(); - results += test_Reset(); - results += test_ForegroundColor(); - results += test_BackgroundColor(); - results += test_Colors(); - results += test_TrueColorForeground(); - results += test_TrueColorBackground(); - - return results; +string escape_string(const string& text, const string& pattern = "\033", const string& replace = "\\033") { + return regex_replace(text, regex(pattern), replace); } -int main(int argc, char* argv[]) { - TestResults results = main_test_Colors(argc, argv); - - PrintResults(cout, results); - - return results.failed() + results.errors(); -} - -namespace Test::Colors { TestResults test_FillColors() { return execute_suite(make_test_suite( "SBF::FillColors", @@ -368,7 +330,22 @@ TestResults test_TrueColorBackground() { return TestResults().skip("// TODO: test_TrueColorBackground"); } -string escape_string(const string& text, const string& pattern, const string& replace) { - return regex_replace(text, regex(pattern), replace); +int main(int argc, char* argv[]) { + TestResults results; + + results += test_FillColors(); + results += test_GetBackgroundColor(); + results += test_GetForegroundColor(); + results += test_SetBackgroundColor(); + results += test_SetForegroundColor(); + results += test_Reset(); + results += test_ForegroundColor(); + results += test_BackgroundColor(); + results += test_Colors(); + results += test_TrueColorForeground(); + results += test_TrueColorBackground(); + + PrintResults(cout, results); + + return results.failed() + results.errors(); } -} // End namespace Test::Colors diff --git a/sbf-cpp/Derangements_test.cpp b/sbf-cpp/Derangements_test.cpp index 25cee2f..4b98f72 100644 --- a/sbf-cpp/Derangements_test.cpp +++ b/sbf-cpp/Derangements_test.cpp @@ -8,41 +8,12 @@ #include "test.h" +namespace { using namespace SBF; using namespace Test; using namespace std; +} // namespace -namespace Test::Derangements { -TestResults test_DerangementType_operator_extract(); -TestResults test_DerangementType_operator_equal_to(); -TestResults test_DerangementType_operator_not_equal_to(); -TestResults test_GetDerangement(); -TestResults test_FillDerangements(); -} // namespace Test::Derangements - -using namespace Test::Derangements; - -TestResults main_test_Derangements(int argc, char* argv[]) { - TestResults results; - - results += test_DerangementType_operator_extract(); - results += test_DerangementType_operator_equal_to(); - results += test_DerangementType_operator_not_equal_to(); - results += test_GetDerangement(); - results += test_FillDerangements(); - - PrintResults(cout, results); - - return results; -} - -int main(int argc, char* argv[]) { - TestResults results = main_test_Derangements(argc, argv); - - return results.failed() + results.errors(); -} - -namespace Test::Derangements { TestResults test_GetDerangement() { return execute_suite(make_test_suite( "SBF::GetDerangement", @@ -259,4 +230,14 @@ TestResults test_DerangementType_operator_not_equal_to() { }))); } -} // namespace Test::Derangements +int main(int argc, char* argv[]) { + TestResults results; + + results += test_DerangementType_operator_extract(); + results += test_DerangementType_operator_equal_to(); + results += test_DerangementType_operator_not_equal_to(); + results += test_GetDerangement(); + results += test_FillDerangements(); + + return results.failed() + results.errors(); +} diff --git a/sbf-cpp/Disciplines_test.cpp b/sbf-cpp/Disciplines_test.cpp index 2349f6b..3740f2b 100644 --- a/sbf-cpp/Disciplines_test.cpp +++ b/sbf-cpp/Disciplines_test.cpp @@ -8,35 +8,12 @@ #include "test.h" +namespace { using namespace SBF; using namespace Test; using namespace std; +} // End namespace -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(); - - PrintResults(cout, results); - - return results; -} - -int main(int argc, char* argv[]) { - TestResults results = main_test_Disciplines(argc, argv); - - return results.failed() + results.errors(); -} - -namespace Test::Disciplines { TestResults test_GetDisciplineLabel() { return execute_suite(make_test_suite( "SBF::GetDisciplineLabel", @@ -100,4 +77,12 @@ TestResults test_FillDisciplineLabels() { make_test("should fill disciplines", "no errors", make_tuple()), }))); } -} // End namespace Test::Disciplines + +int main(int argc, char* argv[]) { + TestResults results; + + results += test_GetDisciplineLabel(); + results += test_FillDisciplineLabels(); + + return results.failed() + results.errors(); +} diff --git a/sbf-cpp/Freebies_test.cpp b/sbf-cpp/Freebies_test.cpp index 058d771..bfff9d0 100644 --- a/sbf-cpp/Freebies_test.cpp +++ b/sbf-cpp/Freebies_test.cpp @@ -8,41 +8,12 @@ #include "test.h" +namespace { using namespace SBF; using namespace Test; using namespace std; +} // End namespace -namespace Test::Freebies { -TestResults test_FreebieType_operator_extract(); -TestResults test_FreebieType_operator_equal_to(); -TestResults test_FreebieType_operator_not_equal_to(); -TestResults test_GetFreebie(); -TestResults test_FillFreebies(); -} // End namespace Test::Freebies - -using namespace Test::Freebies; - -TestResults main_test_Freebies(int argc, char* argv[]) { - TestResults results; - - results += test_FreebieType_operator_extract(); - results += test_FreebieType_operator_equal_to(); - results += test_FreebieType_operator_not_equal_to(); - results += test_GetFreebie(); - results += test_FillFreebies(); - - PrintResults(cout, results); - - return results; -} - -int main(int argc, char* argv[]) { - TestResults results = main_test_Freebies(argc, argv); - - return results.failed() + results.errors(); -} - -namespace Test::Freebies { TestResults test_FreebieType_operator_extract() { auto fnToTest = [](const FreebieType& freebie) -> string { ostringstream os; @@ -188,4 +159,14 @@ TestResults test_FillFreebies() { vector>({make_test("should fill freebies", "no errors", make_tuple())}))); } -} // End namespace Test::Freebies +int main(int argc, char* argv[]) { + TestResults results; + + results += test_FreebieType_operator_extract(); + results += test_FreebieType_operator_equal_to(); + results += test_FreebieType_operator_not_equal_to(); + results += test_GetFreebie(); + results += test_FillFreebies(); + + return results.failed() + results.errors(); +} diff --git a/sbf-cpp/Genders_test.cpp b/sbf-cpp/Genders_test.cpp index 67fd05f..38a09cb 100644 --- a/sbf-cpp/Genders_test.cpp +++ b/sbf-cpp/Genders_test.cpp @@ -8,35 +8,12 @@ #include "test.h" +namespace { using namespace SBF; using namespace Test; using namespace std; +} // End namespace -namespace Test::Genders { -TestResults test_GetGenderLabel(); -TestResults test_FillGenderLabels(); -} // End namespace Test::Genders - -using namespace Test::Genders; - -TestResults main_test_Genders(int argc, char* argv[]) { - TestResults results; - - results += test_GetGenderLabel(); - results += test_FillGenderLabels(); - - PrintResults(cout, results); - - return results; -} - -int main(int argc, char* argv[]) { - TestResults results = main_test_Genders(argc, argv); - - return results.failed() + results.errors(); -} - -namespace Test::Genders { TestResults test_GetGenderLabel() { return execute_suite(make_test_suite( "SBF::GetGenderLabel", @@ -77,4 +54,12 @@ TestResults test_FillGenderLabels() { make_test("should fill genders", "no errors", make_tuple()), }))); } -} // End namespace Test::Genders + +int main(int argc, char* argv[]) { + TestResults results; + + results += test_GetGenderLabel(); + results += test_FillGenderLabels(); + + return results.failed() + results.errors(); +} diff --git a/sbf-cpp/Menus_test.cpp b/sbf-cpp/Menus_test.cpp index 88f9165..2ae645a 100644 --- a/sbf-cpp/Menus_test.cpp +++ b/sbf-cpp/Menus_test.cpp @@ -10,60 +10,16 @@ #include "Colors.h" #include "test.h" +namespace { using namespace SBF; using namespace Test; using namespace std; +} // End namespace -namespace Test::Menus { -TestResults test_MenuItem_constructor(); -TestResults test_MenuItem_constructor_string_int(); -TestResults test_MenuItem_constructor_string_int_int(); -TestResults test_MenuItem_constructor_string_int_uint8_t(); -TestResults test_MenuStyle_constructor(); -TestResults test_MenuStyle_Adjust(); -TestResults test_GetRandomMenuItemId(); -TestResults test_BuildMenu(); -TestResults test_BuildMenuWithValues(); -TestResults test_BuildMenuWithColors(); -TestResults test_PrintMenu(); -TestResults test_GetTitle(); -TestResults test_GetTitleWithoutValue(); -TestResults test_PrintWithMaybeColor(); -string escape_string(const string& text, const string& pattern = "\033", const string& replace = "\\033"); -} // End namespace Test::Menus - -using namespace Test::Menus; - -TestResults main_test_Menus(int argc, char* argv[]) { - TestResults results; - - results += test_MenuItem_constructor(); - results += test_MenuItem_constructor_string_int(); - results += test_MenuItem_constructor_string_int_int(); - results += test_MenuItem_constructor_string_int_uint8_t(); - results += test_MenuStyle_constructor(); - results += test_MenuStyle_Adjust(); - results += test_GetRandomMenuItemId(); - results += test_BuildMenu(); - results += test_BuildMenuWithValues(); - results += test_BuildMenuWithColors(); - results += test_PrintMenu(); - results += test_GetTitle(); - results += test_GetTitleWithoutValue(); - results += test_PrintWithMaybeColor(); - - PrintResults(cout, results); - - return results; +string escape_string(const string& text, const string& pattern = "\033", const string& replace = "\\033") { + return regex_replace(text, regex(pattern), replace); } -int main(int argc, char* argv[]) { - TestResults results = main_test_Menus(argc, argv); - - return results.failed() + results.errors(); -} - -namespace Test::Menus { TestResults test_MenuItem_constructor() { return TestResults().skip("// TODO: test_MenuItem_constructor"); } @@ -149,7 +105,25 @@ TestResults test_PrintWithMaybeColor() { }))); } -string escape_string(const string& text, const string& pattern, const string& replace) { - return regex_replace(text, regex(pattern), replace); +int main(int argc, char* argv[]) { + TestResults results; + + results += test_MenuItem_constructor(); + results += test_MenuItem_constructor_string_int(); + results += test_MenuItem_constructor_string_int_int(); + results += test_MenuItem_constructor_string_int_uint8_t(); + results += test_MenuStyle_constructor(); + results += test_MenuStyle_Adjust(); + results += test_GetRandomMenuItemId(); + results += test_BuildMenu(); + results += test_BuildMenuWithValues(); + results += test_BuildMenuWithColors(); + results += test_PrintMenu(); + results += test_GetTitle(); + results += test_GetTitleWithoutValue(); + results += test_PrintWithMaybeColor(); + + PrintResults(cout, results); + + return results.failed() + results.errors(); } -} // namespace Test::Menus diff --git a/sbf-cpp/Random_test.cpp b/sbf-cpp/Random_test.cpp index 113bb08..7ed21e0 100644 --- a/sbf-cpp/Random_test.cpp +++ b/sbf-cpp/Random_test.cpp @@ -8,35 +8,22 @@ #include "test.h" +namespace { using namespace SBF; using namespace Test; using namespace std; +} // End namespace -namespace Test::Random { -TestResults test_something(); -} // End namespace Test::Random +TestResults test_something() { + return TestResults().skip("SBF::Random::*"); +} -using namespace Test::Random; - -TestResults main_test_Random(int argc, char* argv[]) { +int main(int argc, char* argv[]) { TestResults results; results += test_something(); PrintResults(cout, results); - return results; -} - -int main(int argc, char* argv[]) { - TestResults results = main_test_Random(argc, argv); - return results.failed() + results.errors(); } - -namespace Test::Random { -TestResults test_something() { - return TestResults().skip("SBF::Random::*"); -} - -} // namespace Test::Random diff --git a/sbf-cpp/Ranks_test.cpp b/sbf-cpp/Ranks_test.cpp index 78a5607..eea875b 100644 --- a/sbf-cpp/Ranks_test.cpp +++ b/sbf-cpp/Ranks_test.cpp @@ -8,41 +8,12 @@ #include "test.h" +namespace { using namespace SBF; using namespace Test; using namespace std; +} // End namespace -namespace Test::Ranks { -TestResults test_RankType_operator_extract(); -TestResults test_RankType_operator_equal_to(); -TestResults test_RankType_operator_not_equal_to(); -TestResults test_GetRank(); -TestResults test_FillRanks(); -} // End namespace Test::Ranks - -using namespace Test::Ranks; - -TestResults main_test_Ranks(int argc, char* argv[]) { - TestResults results; - - results += test_RankType_operator_extract(); - results += test_RankType_operator_equal_to(); - results += test_RankType_operator_not_equal_to(); - results += test_GetRank(); - results += test_FillRanks(); - - PrintResults(cout, results); - - return results; -} - -int main(int argc, char* argv[]) { - TestResults results = main_test_Ranks(argc, argv); - - return results.failed() + results.errors(); -} - -namespace Test::Ranks { TestResults test_GetRank() { return execute_suite(make_test_suite( "SBF::GetRank", @@ -137,4 +108,17 @@ TestResults test_RankType_operator_not_equal_to() { make_tuple(kRankSecondary, kRankTertiary)), }))); } -} // namespace Test::Ranks + +int main(int argc, char* argv[]) { + TestResults results; + + results += test_RankType_operator_extract(); + results += test_RankType_operator_equal_to(); + results += test_RankType_operator_not_equal_to(); + results += test_GetRank(); + results += test_FillRanks(); + + PrintResults(cout, results); + + return results.failed() + results.errors(); +} diff --git a/sbf-cpp/TODO.md b/sbf-cpp/TODO.md index 276b06e..dfd375d 100644 --- a/sbf-cpp/TODO.md +++ b/sbf-cpp/TODO.md @@ -1,3 +1,7 @@ * Character.{h,cpp} and tests * main.{h,cpp} and tests * sbf.{h,cpp} and tests +* bazel build mac app +* bazel test sbf +* bazel build/test main (the test ncurses app) +* bazel build doxygen docs. diff --git a/sbf-cpp/Utils_test.cpp b/sbf-cpp/Utils_test.cpp index acf73c9..a7e02d8 100644 --- a/sbf-cpp/Utils_test.cpp +++ b/sbf-cpp/Utils_test.cpp @@ -7,53 +7,12 @@ #include "test.h" +namespace { using namespace SBF; using namespace Test; using namespace std; +} // End namespace -namespace Test::Utils { -TestResults test_get_index_of(); -TestResults test_get_substring(); -TestResults test_left(); -TestResults test_left_trim(); -TestResults test_make_fit_c(); -TestResults test_make_fit_l(); -TestResults test_make_fit_r(); -TestResults test_right(); -TestResults test_right_trim(); -TestResults test_string_dollar(); -TestResults test_word_wrap(); -} // End namespace Test::Utils - -using namespace Test::Utils; - -TestResults main_test_Utils(int argc, char* argv[]) { - TestResults results; - - results += test_get_index_of(); - results += test_get_substring(); - results += test_left(); - results += test_left_trim(); - results += test_make_fit_c(); - results += test_make_fit_l(); - results += test_make_fit_r(); - results += test_right(); - results += test_right_trim(); - results += test_string_dollar(); - results += test_word_wrap(); - - PrintResults(cout, results); - - return results; -} - -int main(int argc, char* argv[]) { - TestResults results = main_test_Utils(argc, argv); - - return results.failed() + results.errors(); -} - -namespace Test::Utils { TestResults test_get_index_of() { string long_text = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's " @@ -63,7 +22,7 @@ TestResults test_get_index_of() { "sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker " "including versions of Lorem Ipsum."; return execute_suite(make_test_suite( - "SBF::get_index_of", + "SBF::Utils::get_index_of", get_index_of, vector>({ make_test( @@ -97,7 +56,7 @@ TestResults test_get_index_of() { TestResults test_get_substring() { return execute_suite(make_test_suite( - "SBF::get_substring", + "SBF::Utils::get_substring", get_substring, vector>({ make_test( @@ -120,7 +79,7 @@ TestResults test_get_substring() { TestResults test_left() { return execute_suite(make_test_suite( - "SBF::left", + "SBF::Utils::left", SBF::left, vector>({ make_test( @@ -140,7 +99,7 @@ TestResults test_left() { TestResults test_right() { return execute_suite(make_test_suite( - "SBF::right", + "SBF::Utils::right", SBF::right, vector>({ make_test( @@ -160,7 +119,7 @@ TestResults test_right() { TestResults test_make_fit_c() { return execute_suite(make_test_suite( - "SBF::make_fit_c", + "SBF::Utils::make_fit_c", make_fit_c, vector>({ make_test( @@ -179,7 +138,7 @@ TestResults test_make_fit_c() { TestResults test_make_fit_l() { return execute_suite(make_test_suite( - "SBF::make_fit_l", + "SBF::Utils::make_fit_l", make_fit_l, vector>({ make_test( @@ -198,7 +157,7 @@ TestResults test_make_fit_l() { TestResults test_make_fit_r() { return execute_suite(make_test_suite( - "SBF::make_fit_r", + "SBF::Utils::make_fit_r", make_fit_r, vector>({ make_test( @@ -217,7 +176,7 @@ TestResults test_make_fit_r() { TestResults test_left_trim() { return execute_suite(make_test_suite( - "SBF::left_trim", + "SBF::Utils::left_trim", left_trim, vector>({ make_test("should trim a string with spaces", @@ -248,7 +207,7 @@ TestResults test_left_trim() { TestResults test_right_trim() { return execute_suite(make_test_suite( - "SBF::right_trim", + "SBF::Utils::right_trim", right_trim, vector>({ make_test("should trim a string with spaces", @@ -279,7 +238,7 @@ TestResults test_right_trim() { TestResults test_string_dollar() { return execute_suite(make_test_suite( - "SBF::string_dollar", + "SBF::Utils::string_dollar", string_dollar, vector>({ make_test("should make a string", "YYYYY", make_tuple(size_t(5), 'Y')), @@ -289,31 +248,72 @@ TestResults test_string_dollar() { }))); } -// string word_wrap(const string& text, int maxWidth); TestResults test_word_wrap() { - return TestResults().skip("SBF::word_wrap"); - // return execute_suite(make_test_suite( - // "SBF::word_wrap", - // word_wrap, - // vector>({ - // make_test( - // "should return the string if it is shorter than max_width", "0123_", make_tuple(string("0123"), 5)), - // make_test( - // "should return the string if its length is equal to max_width", "01234", make_tuple(string("01234"), - // 5)), - // make_test("should wrap a string to two lines if it has no whitespace", - // "01234\n5____", - // make_tuple(string("012345"), 5)), - // make_test("should wrap a string to three lines if it has no whitespace", - // "01234\n56789\n0____", - // make_tuple(string("01234567890"), 5)), - // make_test("should wrap a string with even spacing", - // "01 23\n45 67\n89 01", - // make_tuple(string("01 23 45 67 89 01"), 5)), - // make_test("should collapse whitespace to a single space", - // "01 34\n67 90\n23 56\n89___", - // make_tuple(string("01 34 67 90 23 56 89 "), 5)), - // // TODO: Treat newlines and tabs in text as spaces. - // }))); + // TODO: Treat newlines and tabs in text as spaces. + auto fnToTest = [](string text, int32_t column_width, vector expected) -> string { + ostringstream error_message; + try { + vector actual = word_wrap(text, column_width); + compare(error_message, expected, actual); + } catch (const exception& ex) { + error_message << ex.what(); + } catch (...) { + error_message << "threw something that was not an exception"; + } + string error_string = error_message.str(); + if (error_string.size() > 0) { + return error_message.str(); + } + return "no errors"; + }; + return execute_suite>(make_test_suite( + "SBF::Utils::word_wrap", + fnToTest, + vector>>({ + make_test>("should return the string if it is shorter than max_width", + "no errors", + make_tuple(string("0123"), 5, vector({"0123_"}))), + make_test>( + "should return the string if its length is equal to max_width", + "no errors", + make_tuple(string("01234"), 5, vector({"01234"}))), + make_test>( + "should wrap a string to two lines if it has no whitespace", + "no errors", + make_tuple(string("012345"), 5, vector({"01234", "5____"}))), + make_test>( + "should wrap a string to three lines if it has no whitespace", + "no errors", + make_tuple(string("01234567890"), 5, vector({"01234", "56789", "0____"}))), + make_test>( + "should wrap a string with even spacing", + "no errors", + make_tuple(string("01 23 45 67 89 01"), 5, vector({"01 23", "45 67", "89 01"}))), + make_test>( + "should collapse whitespace to a single space", + "no errors", + make_tuple( + string("01 34 67 90 23 56 89 "), 5, vector({"01 34", "67 90", "23 56", "89___"}))), + + }))); +} + +int main(int argc, char* argv[]) { + TestResults results; + + results += test_get_index_of(); + results += test_get_substring(); + results += test_left(); + results += test_left_trim(); + results += test_make_fit_c(); + results += test_make_fit_l(); + results += test_make_fit_r(); + results += test_right(); + results += test_right_trim(); + results += test_string_dollar(); + results += test_word_wrap(); + + PrintResults(cout, results); + + return results.failed() + results.errors(); } -} // End namespace Test::Utils diff --git a/sbf-cpp/Virtues_test.cpp b/sbf-cpp/Virtues_test.cpp index e991659..c552e39 100644 --- a/sbf-cpp/Virtues_test.cpp +++ b/sbf-cpp/Virtues_test.cpp @@ -7,35 +7,12 @@ #include "test.h" +namespace { using namespace SBF; using namespace Test; using namespace std; +} // End namespace -namespace Test::Virtues { -TestResults test_GetVirtueLabel(); -TestResults test_FillVirtueLabels(); -} // End namespace Test::Virtues - -using namespace Test::Virtues; - -TestResults main_test_Virtues(int argc, char* argv[]) { - TestResults results; - - results += test_GetVirtueLabel(); - results += test_FillVirtueLabels(); - - PrintResults(cout, results); - - return results; -} - -int main(int argc, char* argv[]) { - TestResults results = main_test_Virtues(argc, argv); - - return results.failed() + results.errors(); -} - -namespace Test::Virtues { TestResults test_GetVirtueLabel() { return execute_suite(make_test_suite( "SBF::GetVirtueLabel", @@ -73,4 +50,13 @@ TestResults test_FillVirtueLabels() { }))); } -} // End namespace Test::Virtues +int main(int argc, char* argv[]) { + TestResults results; + + results += test_GetVirtueLabel(); + results += test_FillVirtueLabels(); + + PrintResults(cout, results); + + return results.failed() + results.errors(); +} diff --git a/sbf-cpp/main_test.cpp b/sbf-cpp/main_test.cpp index 82d6f9c..c63a349 100644 --- a/sbf-cpp/main_test.cpp +++ b/sbf-cpp/main_test.cpp @@ -7,25 +7,16 @@ #include "Menus.h" #include "test.h" +namespace { using namespace SBF; using namespace Test; using namespace std; - -namespace Test::Menus {} // End namespace Test::Menus - -using namespace Test::Menus; - -TestResults main_test_Menus(int argc, char* argv[]) { - TestResults results; - return results; -} +} // End namespace int main(int argc, char* argv[]) { - TestResults results = main_test_Menus(argc, argv); + TestResults results; PrintResults(cout, results); return results.failed() + results.errors(); } - -namespace Test::Menus {} // namespace Test::Menus