Refactors tests to better fit with how bazel runs them.

This commit is contained in:
2023-04-24 13:59:21 -07:00
parent 3bf43ef62a
commit 8ec8b1dfe0
17 changed files with 306 additions and 562 deletions

View File

@@ -4,61 +4,13 @@
#include <sstream> #include <sstream>
#include "test.h" #include "test.h"
namespace {
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std; 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() { TestResults test_AbilityType_operator_extract() {
return execute_suite<string, AbilityType>(make_test_suite( return execute_suite<string, AbilityType>(make_test_suite(
"SBF::AbilityType::operator<<", "SBF::AbilityType::operator<<",
@@ -478,4 +430,27 @@ TestResults test_GetTalentLabel() {
make_test<string, int>("should get and empty string for id 11", "", make_tuple(11)), make_test<string, int>("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();
}

View File

@@ -4,35 +4,13 @@
#include <sstream> #include <sstream>
#include "test.h" #include "test.h"
namespace {
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std; 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() { TestResults test_GetArchetypeLabel() {
return execute_suite<string, int>(make_test_suite( return execute_suite<string, int>(make_test_suite(
"SBF::GetArchetypeLabel", "SBF::GetArchetypeLabel",
@@ -96,4 +74,14 @@ TestResults test_FillArchetypeLabels() {
make_test<string>("should fill archetype labels", "no errors", make_tuple()), make_test<string>("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();
}

View File

@@ -8,61 +8,12 @@
#include "test.h" #include "test.h"
namespace {
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std; 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() { TestResults test_GetAttributeGroupLabel() {
return execute_suite<string, int>( return execute_suite<string, int>(
make_test_suite("SBF::GetAttributeGroupLabel", make_test_suite("SBF::GetAttributeGroupLabel",
@@ -330,4 +281,27 @@ TestResults test_FillMentalAttributeLabels() {
make_test<string>("should fill mental attribute labels", "no errors", make_tuple()), make_test<string>("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();
}

View File

@@ -8,35 +8,12 @@
#include "test.h" #include "test.h"
namespace {
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std; 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() { TestResults test_GetBackgroundLabel() {
return execute_suite<string, int>(make_test_suite( return execute_suite<string, int>(make_test_suite(
"SBF::GetBackgroundLabel", "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();
}

View File

@@ -8,35 +8,12 @@
#include "test.h" #include "test.h"
namespace {
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std; 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() { TestResults test_GetClanLabel() {
return execute_suite<string, int>(make_test_suite( return execute_suite<string, int>(make_test_suite(
"SBF::GetClanLabel", "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();
}

View File

@@ -8,59 +8,21 @@
#include "test.h" #include "test.h"
namespace {
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std; using namespace std;
} // End namespace
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;
namespace SBF { namespace SBF {
extern uint8_t g_foreground_color; extern uint8_t g_foreground_color;
extern uint8_t g_background_color; extern uint8_t g_background_color;
} // namespace SBF } // namespace SBF
TestResults main_test_Colors(int argc, char* argv[]) { string escape_string(const string& text, const string& pattern = "\033", const string& replace = "\\033") {
TestResults results; return regex_replace(text, regex(pattern), replace);
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;
} }
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() { TestResults test_FillColors() {
return execute_suite<string>(make_test_suite( return execute_suite<string>(make_test_suite(
"SBF::FillColors", "SBF::FillColors",
@@ -368,7 +330,22 @@ TestResults test_TrueColorBackground() {
return TestResults().skip("// TODO: test_TrueColorBackground"); return TestResults().skip("// TODO: test_TrueColorBackground");
} }
string escape_string(const string& text, const string& pattern, const string& replace) { int main(int argc, char* argv[]) {
return regex_replace(text, regex(pattern), replace); 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

View File

@@ -8,41 +8,12 @@
#include "test.h" #include "test.h"
namespace {
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std; 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() { TestResults test_GetDerangement() {
return execute_suite<DerangementType, int>(make_test_suite( return execute_suite<DerangementType, int>(make_test_suite(
"SBF::GetDerangement", "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();
}

View File

@@ -8,35 +8,12 @@
#include "test.h" #include "test.h"
namespace {
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std; 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() { TestResults test_GetDisciplineLabel() {
return execute_suite<string, int>(make_test_suite( return execute_suite<string, int>(make_test_suite(
"SBF::GetDisciplineLabel", "SBF::GetDisciplineLabel",
@@ -100,4 +77,12 @@ TestResults test_FillDisciplineLabels() {
make_test<string>("should fill disciplines", "no errors", make_tuple()), make_test<string>("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();
}

View File

@@ -8,41 +8,12 @@
#include "test.h" #include "test.h"
namespace {
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std; 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() { TestResults test_FreebieType_operator_extract() {
auto fnToTest = [](const FreebieType& freebie) -> string { auto fnToTest = [](const FreebieType& freebie) -> string {
ostringstream os; ostringstream os;
@@ -188,4 +159,14 @@ TestResults test_FillFreebies() {
vector<TestTuple<string>>({make_test<string>("should fill freebies", "no errors", make_tuple())}))); vector<TestTuple<string>>({make_test<string>("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();
}

View File

@@ -8,35 +8,12 @@
#include "test.h" #include "test.h"
namespace {
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std; 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() { TestResults test_GetGenderLabel() {
return execute_suite<string, int>(make_test_suite( return execute_suite<string, int>(make_test_suite(
"SBF::GetGenderLabel", "SBF::GetGenderLabel",
@@ -77,4 +54,12 @@ TestResults test_FillGenderLabels() {
make_test<string>("should fill genders", "no errors", make_tuple()), make_test<string>("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();
}

View File

@@ -10,60 +10,16 @@
#include "Colors.h" #include "Colors.h"
#include "test.h" #include "test.h"
namespace {
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std; using namespace std;
} // End namespace
namespace Test::Menus { string escape_string(const string& text, const string& pattern = "\033", const string& replace = "\\033") {
TestResults test_MenuItem_constructor(); return regex_replace(text, regex(pattern), replace);
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;
} }
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() { TestResults test_MenuItem_constructor() {
return TestResults().skip("// TODO: 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) { int main(int argc, char* argv[]) {
return regex_replace(text, regex(pattern), replace); 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

View File

@@ -8,35 +8,22 @@
#include "test.h" #include "test.h"
namespace {
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std; using namespace std;
} // End namespace
namespace Test::Random { TestResults test_something() {
TestResults test_something(); return TestResults().skip("SBF::Random::*");
} // End namespace Test::Random }
using namespace Test::Random; int main(int argc, char* argv[]) {
TestResults main_test_Random(int argc, char* argv[]) {
TestResults results; TestResults results;
results += test_something(); results += test_something();
PrintResults(cout, results); PrintResults(cout, results);
return results;
}
int main(int argc, char* argv[]) {
TestResults results = main_test_Random(argc, argv);
return results.failed() + results.errors(); return results.failed() + results.errors();
} }
namespace Test::Random {
TestResults test_something() {
return TestResults().skip("SBF::Random::*");
}
} // namespace Test::Random

View File

@@ -8,41 +8,12 @@
#include "test.h" #include "test.h"
namespace {
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std; 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() { TestResults test_GetRank() {
return execute_suite<RankType, int>(make_test_suite( return execute_suite<RankType, int>(make_test_suite(
"SBF::GetRank", "SBF::GetRank",
@@ -137,4 +108,17 @@ TestResults test_RankType_operator_not_equal_to() {
make_tuple(kRankSecondary, kRankTertiary)), 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();
}

View File

@@ -1,3 +1,7 @@
* Character.{h,cpp} and tests * Character.{h,cpp} and tests
* main.{h,cpp} and tests * main.{h,cpp} and tests
* sbf.{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.

View File

@@ -7,53 +7,12 @@
#include "test.h" #include "test.h"
namespace {
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std; 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() { TestResults test_get_index_of() {
string long_text = string long_text =
"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's " "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 " "sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker "
"including versions of Lorem Ipsum."; "including versions of Lorem Ipsum.";
return execute_suite<size_t, string, string, size_t>(make_test_suite( return execute_suite<size_t, string, string, size_t>(make_test_suite(
"SBF::get_index_of", "SBF::Utils::get_index_of",
get_index_of, get_index_of,
vector<TestTuple<size_t, string, string, size_t>>({ vector<TestTuple<size_t, string, string, size_t>>({
make_test<size_t, string, string, size_t>( make_test<size_t, string, string, size_t>(
@@ -97,7 +56,7 @@ TestResults test_get_index_of() {
TestResults test_get_substring() { TestResults test_get_substring() {
return execute_suite<string, string, size_t, size_t>(make_test_suite( return execute_suite<string, string, size_t, size_t>(make_test_suite(
"SBF::get_substring", "SBF::Utils::get_substring",
get_substring, get_substring,
vector<TestTuple<string, string, size_t, size_t>>({ vector<TestTuple<string, string, size_t, size_t>>({
make_test<string, string, size_t, size_t>( make_test<string, string, size_t, size_t>(
@@ -120,7 +79,7 @@ TestResults test_get_substring() {
TestResults test_left() { TestResults test_left() {
return execute_suite<string, string, size_t>(make_test_suite( return execute_suite<string, string, size_t>(make_test_suite(
"SBF::left", "SBF::Utils::left",
SBF::left, SBF::left,
vector<TestTuple<string, string, size_t>>({ vector<TestTuple<string, string, size_t>>({
make_test<string, string, size_t>( make_test<string, string, size_t>(
@@ -140,7 +99,7 @@ TestResults test_left() {
TestResults test_right() { TestResults test_right() {
return execute_suite<string, string, size_t>(make_test_suite( return execute_suite<string, string, size_t>(make_test_suite(
"SBF::right", "SBF::Utils::right",
SBF::right, SBF::right,
vector<TestTuple<string, string, size_t>>({ vector<TestTuple<string, string, size_t>>({
make_test<string, string, size_t>( make_test<string, string, size_t>(
@@ -160,7 +119,7 @@ TestResults test_right() {
TestResults test_make_fit_c() { TestResults test_make_fit_c() {
return execute_suite<string, string, int32_t, char>(make_test_suite( return execute_suite<string, string, int32_t, char>(make_test_suite(
"SBF::make_fit_c", "SBF::Utils::make_fit_c",
make_fit_c, make_fit_c,
vector<TestTuple<string, string, int32_t, char>>({ vector<TestTuple<string, string, int32_t, char>>({
make_test<string, string, int32_t, char>( make_test<string, string, int32_t, char>(
@@ -179,7 +138,7 @@ TestResults test_make_fit_c() {
TestResults test_make_fit_l() { TestResults test_make_fit_l() {
return execute_suite<string, string, int32_t, char>(make_test_suite( return execute_suite<string, string, int32_t, char>(make_test_suite(
"SBF::make_fit_l", "SBF::Utils::make_fit_l",
make_fit_l, make_fit_l,
vector<TestTuple<string, string, int32_t, char>>({ vector<TestTuple<string, string, int32_t, char>>({
make_test<string, string, int32_t, char>( make_test<string, string, int32_t, char>(
@@ -198,7 +157,7 @@ TestResults test_make_fit_l() {
TestResults test_make_fit_r() { TestResults test_make_fit_r() {
return execute_suite<string, string, int32_t, char>(make_test_suite( return execute_suite<string, string, int32_t, char>(make_test_suite(
"SBF::make_fit_r", "SBF::Utils::make_fit_r",
make_fit_r, make_fit_r,
vector<TestTuple<string, string, int32_t, char>>({ vector<TestTuple<string, string, int32_t, char>>({
make_test<string, string, int32_t, char>( make_test<string, string, int32_t, char>(
@@ -217,7 +176,7 @@ TestResults test_make_fit_r() {
TestResults test_left_trim() { TestResults test_left_trim() {
return execute_suite<string, string>(make_test_suite( return execute_suite<string, string>(make_test_suite(
"SBF::left_trim", "SBF::Utils::left_trim",
left_trim, left_trim,
vector<TestTuple<string, string>>({ vector<TestTuple<string, string>>({
make_test<string, string>("should trim a string with spaces", make_test<string, string>("should trim a string with spaces",
@@ -248,7 +207,7 @@ TestResults test_left_trim() {
TestResults test_right_trim() { TestResults test_right_trim() {
return execute_suite<string, string>(make_test_suite( return execute_suite<string, string>(make_test_suite(
"SBF::right_trim", "SBF::Utils::right_trim",
right_trim, right_trim,
vector<TestTuple<string, string>>({ vector<TestTuple<string, string>>({
make_test<string, string>("should trim a string with spaces", make_test<string, string>("should trim a string with spaces",
@@ -279,7 +238,7 @@ TestResults test_right_trim() {
TestResults test_string_dollar() { TestResults test_string_dollar() {
return execute_suite<string, size_t, char>(make_test_suite( return execute_suite<string, size_t, char>(make_test_suite(
"SBF::string_dollar", "SBF::Utils::string_dollar",
string_dollar, string_dollar,
vector<TestTuple<string, size_t, char>>({ vector<TestTuple<string, size_t, char>>({
make_test<string, size_t, char>("should make a string", "YYYYY", make_tuple(size_t(5), 'Y')), make_test<string, size_t, char>("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() { TestResults test_word_wrap() {
return TestResults().skip("SBF::word_wrap"); // TODO: Treat newlines and tabs in text as spaces.
// return execute_suite<string, string, int32_t>(make_test_suite( auto fnToTest = [](string text, int32_t column_width, vector<string> expected) -> string {
// "SBF::word_wrap", ostringstream error_message;
// word_wrap, try {
// vector<TestTuple<string, string, int32_t>>({ vector<string> actual = word_wrap(text, column_width);
// make_test<string, string, int32_t>( compare(error_message, expected, actual);
// "should return the string if it is shorter than max_width", "0123_", make_tuple(string("0123"), 5)), } catch (const exception& ex) {
// make_test<string, string, int32_t>( error_message << ex.what();
// "should return the string if its length is equal to max_width", "01234", make_tuple(string("01234"), } catch (...) {
// 5)), error_message << "threw something that was not an exception";
// make_test<string, string, int32_t>("should wrap a string to two lines if it has no whitespace", }
// "01234\n5____", string error_string = error_message.str();
// make_tuple(string("012345"), 5)), if (error_string.size() > 0) {
// make_test<string, string, int32_t>("should wrap a string to three lines if it has no whitespace", return error_message.str();
// "01234\n56789\n0____", }
// make_tuple(string("01234567890"), 5)), return "no errors";
// make_test<string, string, int32_t>("should wrap a string with even spacing", };
// "01 23\n45 67\n89 01", return execute_suite<string, string, int32_t, vector<string>>(make_test_suite(
// make_tuple(string("01 23 45 67 89 01"), 5)), "SBF::Utils::word_wrap",
// make_test<string, string, int32_t>("should collapse whitespace to a single space", fnToTest,
// "01 34\n67 90\n23 56\n89___", vector<TestTuple<string, string, int32_t, vector<string>>>({
// make_tuple(string("01 34 67 90 23 56 89 "), 5)), make_test<string, string, int32_t, vector<string>>("should return the string if it is shorter than max_width",
// // TODO: Treat newlines and tabs in text as spaces. "no errors",
// }))); make_tuple(string("0123"), 5, vector<string>({"0123_"}))),
make_test<string, string, int32_t, vector<string>>(
"should return the string if its length is equal to max_width",
"no errors",
make_tuple(string("01234"), 5, vector<string>({"01234"}))),
make_test<string, string, int32_t, vector<string>>(
"should wrap a string to two lines if it has no whitespace",
"no errors",
make_tuple(string("012345"), 5, vector<string>({"01234", "5____"}))),
make_test<string, string, int32_t, vector<string>>(
"should wrap a string to three lines if it has no whitespace",
"no errors",
make_tuple(string("01234567890"), 5, vector<string>({"01234", "56789", "0____"}))),
make_test<string, string, int32_t, vector<string>>(
"should wrap a string with even spacing",
"no errors",
make_tuple(string("01 23 45 67 89 01"), 5, vector<string>({"01 23", "45 67", "89 01"}))),
make_test<string, string, int32_t, vector<string>>(
"should collapse whitespace to a single space",
"no errors",
make_tuple(
string("01 34 67 90 23 56 89 "), 5, vector<string>({"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

View File

@@ -7,35 +7,12 @@
#include "test.h" #include "test.h"
namespace {
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std; 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() { TestResults test_GetVirtueLabel() {
return execute_suite<string, int>(make_test_suite( return execute_suite<string, int>(make_test_suite(
"SBF::GetVirtueLabel", "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();
}

View File

@@ -7,25 +7,16 @@
#include "Menus.h" #include "Menus.h"
#include "test.h" #include "test.h"
namespace {
using namespace SBF; using namespace SBF;
using namespace Test; using namespace Test;
using namespace std; using namespace std;
} // End namespace
namespace Test::Menus {} // End namespace Test::Menus
using namespace Test::Menus;
TestResults main_test_Menus(int argc, char* argv[]) {
TestResults results;
return results;
}
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
TestResults results = main_test_Menus(argc, argv); TestResults results;
PrintResults(cout, results); PrintResults(cout, results);
return results.failed() + results.errors(); return results.failed() + results.errors();
} }
namespace Test::Menus {} // namespace Test::Menus