Configures for bazel build and test.
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,3 +1,7 @@
|
|||||||
|
/bazel-bin
|
||||||
|
/bazel-out
|
||||||
|
/bazel-sbf2000
|
||||||
|
/bazel-testlogs
|
||||||
/dos/qb45
|
/dos/qb45
|
||||||
/dos/qbasic11
|
/dos/qbasic11
|
||||||
/tmp
|
/tmp
|
||||||
|
|||||||
16
WORKSPACE
Normal file
16
WORKSPACE
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
||||||
|
|
||||||
|
# Hedron's Compile Commands Extractor for Bazel
|
||||||
|
# https://github.com/hedronvision/bazel-compile-commands-extractor
|
||||||
|
# To update config run `bazel run @hedron_compile_commands//:refresh_all`
|
||||||
|
http_archive(
|
||||||
|
name = "hedron_compile_commands",
|
||||||
|
sha256 = "99bc3106eb6ce5ffab3c31de8501d4d628de5f1acd74b8b563a876bd39a2e32f",
|
||||||
|
# Replace the commit hash in both places (below) with the latest, rather than using the stale one here.
|
||||||
|
strip_prefix = "bazel-compile-commands-extractor-b33a4b05c2287372c8e932c55ff4d3a37e6761ed",
|
||||||
|
url = "https://github.com/hedronvision/bazel-compile-commands-extractor/archive/b33a4b05c2287372c8e932c55ff4d3a37e6761ed.tar.gz",
|
||||||
|
)
|
||||||
|
|
||||||
|
load("@hedron_compile_commands//:workspace_setup.bzl", "hedron_compile_commands_setup")
|
||||||
|
|
||||||
|
hedron_compile_commands_setup()
|
||||||
@@ -50,6 +50,14 @@ TestResults main_test_Abilities(int argc, char* argv[]) {
|
|||||||
return results;
|
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 {
|
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(
|
||||||
|
|||||||
@@ -24,6 +24,14 @@ TestResults main_test_Archetypes(int argc, char* argv[]) {
|
|||||||
return results;
|
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 {
|
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(
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Attributes.h"
|
#include "Attributes.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
@@ -53,6 +54,14 @@ TestResults main_test_Attributes(int argc, char* argv[]) {
|
|||||||
return results;
|
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 {
|
namespace Test::Attributes {
|
||||||
TestResults test_GetAttributeGroupLabel() {
|
TestResults test_GetAttributeGroupLabel() {
|
||||||
return execute_suite<string, int>(
|
return execute_suite<string, int>(
|
||||||
|
|||||||
306
sbf-cpp/BUILD
Normal file
306
sbf-cpp/BUILD
Normal file
@@ -0,0 +1,306 @@
|
|||||||
|
load("@rules_cc//cc:defs.bzl", "cc_binary", "cc_library", "cc_test")
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "tinytest",
|
||||||
|
srcs = ["test.cpp"],
|
||||||
|
hdrs = ["test.h"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "abilities",
|
||||||
|
srcs = ["Abilities.cpp"],
|
||||||
|
hdrs = ["Abilities.h"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "abilities_test",
|
||||||
|
srcs = ["Abilities_test.cpp"],
|
||||||
|
deps = [
|
||||||
|
":abilities",
|
||||||
|
":tinytest",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "archetypes",
|
||||||
|
srcs = ["Archetypes.cpp"],
|
||||||
|
hdrs = ["Archetypes.h"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "archetypes_test",
|
||||||
|
srcs = ["Archetypes_test.cpp"],
|
||||||
|
deps = [
|
||||||
|
":archetypes",
|
||||||
|
":tinytest",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "attributes",
|
||||||
|
srcs = ["Attributes.cpp"],
|
||||||
|
hdrs = ["Attributes.h"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "attributes_test",
|
||||||
|
srcs = ["Attributes_test.cpp"],
|
||||||
|
deps = [
|
||||||
|
":attributes",
|
||||||
|
":tinytest",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "backgrounds",
|
||||||
|
srcs = ["Backgrounds.cpp"],
|
||||||
|
hdrs = ["Backgrounds.h"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "backgrounds_test",
|
||||||
|
srcs = ["Backgrounds_test.cpp"],
|
||||||
|
deps = [
|
||||||
|
":backgrounds",
|
||||||
|
":tinytest",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "character",
|
||||||
|
srcs = ["Character.cpp"],
|
||||||
|
hdrs = ["Character.h"],
|
||||||
|
deps = [
|
||||||
|
":abilities",
|
||||||
|
":attributes",
|
||||||
|
":backgrounds",
|
||||||
|
":clans",
|
||||||
|
":colors",
|
||||||
|
":derangements",
|
||||||
|
":disciplines",
|
||||||
|
":ranks",
|
||||||
|
":virtues",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "character_test",
|
||||||
|
srcs = ["Character_test.cpp"],
|
||||||
|
deps = [
|
||||||
|
":character",
|
||||||
|
":tinytest",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "clans",
|
||||||
|
srcs = ["Clans.cpp"],
|
||||||
|
hdrs = ["Clans.h"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "clans_test",
|
||||||
|
srcs = ["Clans_test.cpp"],
|
||||||
|
deps = [
|
||||||
|
":clans",
|
||||||
|
":tinytest",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "colors",
|
||||||
|
srcs = ["Colors.cpp"],
|
||||||
|
hdrs = ["Colors.h"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "colors_test",
|
||||||
|
srcs = ["Colors_test.cpp"],
|
||||||
|
deps = [
|
||||||
|
":colors",
|
||||||
|
":tinytest",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "derangements",
|
||||||
|
srcs = ["Derangements.cpp"],
|
||||||
|
hdrs = ["Derangements.h"],
|
||||||
|
deps = [":colors"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "derangements_test",
|
||||||
|
srcs = ["Derangements_test.cpp"],
|
||||||
|
deps = [
|
||||||
|
":derangements",
|
||||||
|
":tinytest",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "disciplines",
|
||||||
|
srcs = ["Disciplines.cpp"],
|
||||||
|
hdrs = ["Disciplines.h"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "disciplines_test",
|
||||||
|
srcs = ["Disciplines_test.cpp"],
|
||||||
|
deps = [
|
||||||
|
":disciplines",
|
||||||
|
":tinytest",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "freebies",
|
||||||
|
srcs = ["Freebies.cpp"],
|
||||||
|
hdrs = ["Freebies.h"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "freebies_test",
|
||||||
|
srcs = ["Freebies_test.cpp"],
|
||||||
|
deps = [
|
||||||
|
":freebies",
|
||||||
|
":tinytest",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "genders",
|
||||||
|
srcs = ["Genders.cpp"],
|
||||||
|
hdrs = ["Genders.h"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "genders_test",
|
||||||
|
srcs = ["Genders_test.cpp"],
|
||||||
|
deps = [
|
||||||
|
":genders",
|
||||||
|
":tinytest",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
# cc_library(
|
||||||
|
# name = "main",
|
||||||
|
# srcs = ["main.cpp"],
|
||||||
|
# hdrs = ["main.h"],
|
||||||
|
# )
|
||||||
|
|
||||||
|
# cc_test(
|
||||||
|
# name = "main_test",
|
||||||
|
# srcs = ["main_test.cpp"],
|
||||||
|
# deps = [
|
||||||
|
# ":main",
|
||||||
|
# ":tinytest",
|
||||||
|
# ],
|
||||||
|
# )
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "menus",
|
||||||
|
srcs = ["Menus.cpp"],
|
||||||
|
hdrs = ["Menus.h"],
|
||||||
|
deps = [
|
||||||
|
":colors",
|
||||||
|
":random",
|
||||||
|
":utils",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "menus_test",
|
||||||
|
srcs = ["Menus_test.cpp"],
|
||||||
|
deps = [
|
||||||
|
":menus",
|
||||||
|
":tinytest",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "random",
|
||||||
|
srcs = ["Random.cpp"],
|
||||||
|
hdrs = ["Random.h"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "random_test",
|
||||||
|
srcs = ["Random_test.cpp"],
|
||||||
|
deps = [
|
||||||
|
":random",
|
||||||
|
":tinytest",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "ranks",
|
||||||
|
srcs = ["Ranks.cpp"],
|
||||||
|
hdrs = ["Ranks.h"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "ranks_test",
|
||||||
|
srcs = ["Ranks_test.cpp"],
|
||||||
|
deps = [
|
||||||
|
":ranks",
|
||||||
|
":tinytest",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_binary(
|
||||||
|
name = "sbf",
|
||||||
|
srcs = [
|
||||||
|
"sbf.cpp",
|
||||||
|
"sbf.h",
|
||||||
|
],
|
||||||
|
deps = [
|
||||||
|
":abilities",
|
||||||
|
":archetypes",
|
||||||
|
":attributes",
|
||||||
|
":backgrounds",
|
||||||
|
":character",
|
||||||
|
":clans",
|
||||||
|
":genders",
|
||||||
|
":menus",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
# cc_test(
|
||||||
|
# name = "sbf_test",
|
||||||
|
# srcs = ["sbf_test.cpp"],
|
||||||
|
# deps = [
|
||||||
|
# ":sbf",
|
||||||
|
# ":tinytest",
|
||||||
|
# ],
|
||||||
|
# )
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "utils",
|
||||||
|
srcs = ["Utils.cpp"],
|
||||||
|
hdrs = ["Utils.h"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "utils_test",
|
||||||
|
srcs = ["Utils_test.cpp"],
|
||||||
|
deps = [
|
||||||
|
":tinytest",
|
||||||
|
":utils",
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_library(
|
||||||
|
name = "virtues",
|
||||||
|
srcs = ["Virtues.cpp"],
|
||||||
|
hdrs = ["Virtues.h"],
|
||||||
|
)
|
||||||
|
|
||||||
|
cc_test(
|
||||||
|
name = "virtues_test",
|
||||||
|
srcs = ["Virtues_test.cpp"],
|
||||||
|
deps = [
|
||||||
|
":tinytest",
|
||||||
|
":virtues",
|
||||||
|
],
|
||||||
|
)
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Backgrounds.h"
|
#include "Backgrounds.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
@@ -27,6 +28,14 @@ TestResults main_test_Backgrounds(int argc, char* argv[]) {
|
|||||||
return results;
|
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 {
|
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(
|
||||||
|
|||||||
@@ -1,11 +1,22 @@
|
|||||||
#include "Character.h"
|
#include "Character.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
using namespace SBF;
|
using namespace SBF;
|
||||||
using namespace Test;
|
using namespace Test;
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
TestResults main_test_Character(int argc, char* argv[]) {
|
TestResults main_test_Character(int argc, char* argv[]) {
|
||||||
TestResults results;
|
TestResults results;
|
||||||
|
|
||||||
|
PrintResults(cout, results);
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
TestResults results = main_test_Character(argc, argv);
|
||||||
|
|
||||||
|
return results.failed() + results.errors();
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Clans.h"
|
#include "Clans.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
@@ -24,9 +25,17 @@ TestResults main_test_Clans(int argc, char* argv[]) {
|
|||||||
results += test_GetClanLabel();
|
results += test_GetClanLabel();
|
||||||
results += test_FillClanLabels();
|
results += test_FillClanLabels();
|
||||||
|
|
||||||
|
PrintResults(cout, results);
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
TestResults results = main_test_Clans(argc, argv);
|
||||||
|
|
||||||
|
return results.failed() + results.errors();
|
||||||
|
}
|
||||||
|
|
||||||
namespace Test::Clans {
|
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(
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Colors.h"
|
#include "Colors.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
@@ -51,6 +52,14 @@ TestResults main_test_Colors(int argc, char* argv[]) {
|
|||||||
return results;
|
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 {
|
namespace Test::Colors {
|
||||||
TestResults test_FillColors() {
|
TestResults test_FillColors() {
|
||||||
return execute_suite<string>(make_test_suite(
|
return execute_suite<string>(make_test_suite(
|
||||||
@@ -351,12 +360,12 @@ TestResults test_Colors() {
|
|||||||
|
|
||||||
TestResults test_TrueColorForeground() {
|
TestResults test_TrueColorForeground() {
|
||||||
// TODO: test_TrueColorForeground();
|
// TODO: test_TrueColorForeground();
|
||||||
return TestResults().fail("// TODO: test_TrueColorForeground");
|
return TestResults().skip("// TODO: test_TrueColorForeground");
|
||||||
}
|
}
|
||||||
|
|
||||||
TestResults test_TrueColorBackground() {
|
TestResults test_TrueColorBackground() {
|
||||||
// TODO: test_TrueColorBackground();
|
// TODO: test_TrueColorBackground();
|
||||||
return TestResults().fail("// TODO: test_TrueColorBackground");
|
return TestResults().skip("// TODO: test_TrueColorBackground");
|
||||||
}
|
}
|
||||||
|
|
||||||
string escape_string(const string& text, const string& pattern, const string& replace) {
|
string escape_string(const string& text, const string& pattern, const string& replace) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Derangements.h"
|
#include "Derangements.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
@@ -30,9 +31,17 @@ TestResults main_test_Derangements(int argc, char* argv[]) {
|
|||||||
results += test_GetDerangement();
|
results += test_GetDerangement();
|
||||||
results += test_FillDerangements();
|
results += test_FillDerangements();
|
||||||
|
|
||||||
|
PrintResults(cout, results);
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
TestResults results = main_test_Derangements(argc, argv);
|
||||||
|
|
||||||
|
return results.failed() + results.errors();
|
||||||
|
}
|
||||||
|
|
||||||
namespace Test::Derangements {
|
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(
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Disciplines.h"
|
#include "Disciplines.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
@@ -24,9 +25,17 @@ TestResults main_test_Disciplines(int argc, char* argv[]) {
|
|||||||
results += test_GetDisciplineLabel();
|
results += test_GetDisciplineLabel();
|
||||||
results += test_FillDisciplineLabels();
|
results += test_FillDisciplineLabels();
|
||||||
|
|
||||||
|
PrintResults(cout, results);
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
TestResults results = main_test_Disciplines(argc, argv);
|
||||||
|
|
||||||
|
return results.failed() + results.errors();
|
||||||
|
}
|
||||||
|
|
||||||
namespace Test::Disciplines {
|
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(
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Freebies.h"
|
#include "Freebies.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
@@ -30,9 +31,17 @@ TestResults main_test_Freebies(int argc, char* argv[]) {
|
|||||||
results += test_GetFreebie();
|
results += test_GetFreebie();
|
||||||
results += test_FillFreebies();
|
results += test_FillFreebies();
|
||||||
|
|
||||||
|
PrintResults(cout, results);
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
TestResults results = main_test_Freebies(argc, argv);
|
||||||
|
|
||||||
|
return results.failed() + results.errors();
|
||||||
|
}
|
||||||
|
|
||||||
namespace Test::Freebies {
|
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 {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Genders.h"
|
#include "Genders.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
@@ -24,9 +25,17 @@ TestResults main_test_Genders(int argc, char* argv[]) {
|
|||||||
results += test_GetGenderLabel();
|
results += test_GetGenderLabel();
|
||||||
results += test_FillGenderLabels();
|
results += test_FillGenderLabels();
|
||||||
|
|
||||||
|
PrintResults(cout, results);
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
TestResults results = main_test_Genders(argc, argv);
|
||||||
|
|
||||||
|
return results.failed() + results.errors();
|
||||||
|
}
|
||||||
|
|
||||||
namespace Test::Genders {
|
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(
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Menus.h"
|
#include "Menus.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <regex>
|
#include <regex>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -51,9 +52,17 @@ TestResults main_test_Menus(int argc, char* argv[]) {
|
|||||||
results += test_GetTitleWithoutValue();
|
results += test_GetTitleWithoutValue();
|
||||||
results += test_PrintWithMaybeColor();
|
results += test_PrintWithMaybeColor();
|
||||||
|
|
||||||
|
PrintResults(cout, results);
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
TestResults results = main_test_Menus(argc, argv);
|
||||||
|
|
||||||
|
return results.failed() + results.errors();
|
||||||
|
}
|
||||||
|
|
||||||
namespace Test::Menus {
|
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");
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#include <Random.h>
|
#include "Random.h"
|
||||||
|
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Random.h"
|
#include "Random.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
@@ -22,9 +23,17 @@ TestResults main_test_Random(int argc, char* argv[]) {
|
|||||||
|
|
||||||
results += test_something();
|
results += test_something();
|
||||||
|
|
||||||
|
PrintResults(cout, results);
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
TestResults results = main_test_Random(argc, argv);
|
||||||
|
|
||||||
|
return results.failed() + results.errors();
|
||||||
|
}
|
||||||
|
|
||||||
namespace Test::Random {
|
namespace Test::Random {
|
||||||
TestResults test_something() {
|
TestResults test_something() {
|
||||||
return TestResults().skip("SBF::Random::*");
|
return TestResults().skip("SBF::Random::*");
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Ranks.h"
|
#include "Ranks.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
@@ -30,9 +31,17 @@ TestResults main_test_Ranks(int argc, char* argv[]) {
|
|||||||
results += test_GetRank();
|
results += test_GetRank();
|
||||||
results += test_FillRanks();
|
results += test_FillRanks();
|
||||||
|
|
||||||
|
PrintResults(cout, results);
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
TestResults results = main_test_Ranks(argc, argv);
|
||||||
|
|
||||||
|
return results.failed() + results.errors();
|
||||||
|
}
|
||||||
|
|
||||||
namespace Test::Ranks {
|
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(
|
||||||
|
|||||||
@@ -7,15 +7,13 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include "test.h"
|
|
||||||
|
|
||||||
using namespace SBF;
|
using namespace SBF;
|
||||||
using namespace Test;
|
|
||||||
|
|
||||||
namespace SBF {
|
namespace SBF {
|
||||||
namespace {
|
namespace {
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::to_string;
|
using std::to_string;
|
||||||
|
using std::vector;
|
||||||
} // End namespace
|
} // End namespace
|
||||||
|
|
||||||
vector<string> word_wrap(const string& text, const size_t max_width) {
|
vector<string> word_wrap(const string& text, const size_t max_width) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Utils.h"
|
#include "Utils.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -41,9 +42,17 @@ TestResults main_test_Utils(int argc, char* argv[]) {
|
|||||||
results += test_string_dollar();
|
results += test_string_dollar();
|
||||||
results += test_word_wrap();
|
results += test_word_wrap();
|
||||||
|
|
||||||
|
PrintResults(cout, results);
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
TestResults results = main_test_Utils(argc, argv);
|
||||||
|
|
||||||
|
return results.failed() + results.errors();
|
||||||
|
}
|
||||||
|
|
||||||
namespace Test::Utils {
|
namespace Test::Utils {
|
||||||
TestResults test_get_index_of() {
|
TestResults test_get_index_of() {
|
||||||
string long_text =
|
string long_text =
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "Virtues.h"
|
#include "Virtues.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -23,9 +24,17 @@ TestResults main_test_Virtues(int argc, char* argv[]) {
|
|||||||
results += test_GetVirtueLabel();
|
results += test_GetVirtueLabel();
|
||||||
results += test_FillVirtueLabels();
|
results += test_FillVirtueLabels();
|
||||||
|
|
||||||
|
PrintResults(cout, results);
|
||||||
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
TestResults results = main_test_Virtues(argc, argv);
|
||||||
|
|
||||||
|
return results.failed() + results.errors();
|
||||||
|
}
|
||||||
|
|
||||||
namespace Test::Virtues {
|
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(
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#include "Menus.h"
|
#include <iostream>
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include "Menus.h"
|
||||||
#include "test.h"
|
#include "test.h"
|
||||||
|
|
||||||
using namespace SBF;
|
using namespace SBF;
|
||||||
@@ -20,4 +20,12 @@ TestResults main_test_Menus(int argc, char* argv[]) {
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
TestResults results = main_test_Menus(argc, argv);
|
||||||
|
|
||||||
|
PrintResults(cout, results);
|
||||||
|
|
||||||
|
return results.failed() + results.errors();
|
||||||
|
}
|
||||||
|
|
||||||
namespace Test::Menus {} // namespace Test::Menus
|
namespace Test::Menus {} // namespace Test::Menus
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#include "sbf.h"
|
#include "sbf.h"
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <tuple>
|
#include <tuple>
|
||||||
@@ -20,4 +21,12 @@ TestResults main_test_sbf(int argc, char* argv[]) {
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
TestResults results = main_test_sbf(argc, argv);
|
||||||
|
|
||||||
|
PrintResults(cout, results);
|
||||||
|
|
||||||
|
return results.failed() + results.errors();
|
||||||
|
}
|
||||||
|
|
||||||
namespace Test::sbf {} // namespace Test::sbf
|
namespace Test::sbf {} // namespace Test::sbf
|
||||||
|
|||||||
@@ -7,13 +7,13 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
// using namespace std;
|
namespace Test {
|
||||||
|
namespace {
|
||||||
|
using std::endl;
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
} // End namespace
|
||||||
|
|
||||||
// using namespace Test;
|
|
||||||
|
|
||||||
namespace Test {
|
|
||||||
// Test lifecycle
|
// Test lifecycle
|
||||||
// suiteSetupFn(); - This is called to allocate any suite level resources. This is called once when the suite begins.
|
// suiteSetupFn(); - This is called to allocate any suite level resources. This is called once when the suite begins.
|
||||||
// These functions may be called in parallel but execution will not proceed past this block until they have all
|
// These functions may be called in parallel but execution will not proceed past this block until they have all
|
||||||
@@ -247,4 +247,33 @@ TestResults& TestResults::operator+=(const TestResults& other) {
|
|||||||
total_ += other.total_;
|
total_ += other.total_;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrintResults(std::ostream& os, TestResults results) {
|
||||||
|
auto skip_messages = results.skip_messages();
|
||||||
|
if (skip_messages.size() > 0) {
|
||||||
|
os << "Skipped:" << endl;
|
||||||
|
for_each(skip_messages.begin(), skip_messages.end(), [&os](const string& message) {
|
||||||
|
os << "🚧Skipped: " << message << endl;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
auto failure_messages = results.failure_messages();
|
||||||
|
if (failure_messages.size() > 0) {
|
||||||
|
os << "Failures:" << endl;
|
||||||
|
for_each(failure_messages.begin(), failure_messages.end(), [&os](const string& message) {
|
||||||
|
os << "❌FAILED: " << message << endl;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
auto error_messages = results.error_messages();
|
||||||
|
if (error_messages.size() > 0) {
|
||||||
|
os << "Errors:" << endl;
|
||||||
|
for_each(error_messages.begin(), error_messages.end(), [&os](const string& message) {
|
||||||
|
os << "🔥ERROR: " << message << endl;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
os << "Total tests: " << results.total() << endl;
|
||||||
|
os << "Passed: " << results.passed() << " ✅" << endl;
|
||||||
|
os << "Failed: " << results.failed() << " ❌" << endl;
|
||||||
|
os << "Skipped: " << results.skipped() << " 🚧" << endl;
|
||||||
|
os << "Errors: " << results.errors() << " 🔥" << endl;
|
||||||
|
}
|
||||||
} // End namespace Test
|
} // End namespace Test
|
||||||
|
|||||||
@@ -486,6 +486,11 @@ MaybeTestConfigureFunction coalesce(MaybeTestConfigureFunction first, MaybeTestC
|
|||||||
return second;
|
return second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// @brief Writes a friendly version of results to the provided stream.
|
||||||
|
/// @param os The stream to write to.
|
||||||
|
/// @param results The TestResults to write.
|
||||||
|
void PrintResults(std::ostream& os, TestResults results);
|
||||||
} // End namespace Test
|
} // End namespace Test
|
||||||
|
|
||||||
// TODO: define operator<< for std::tuple.
|
// TODO: define operator<< for std::tuple.
|
||||||
|
|||||||
Reference in New Issue
Block a user