1
0

refactor: move test name into test class

This commit is contained in:
mandlm 2023-10-21 21:29:36 +02:00
parent 543b4b832a
commit 3c193fc47b
Signed by: mandlm
GPG Key ID: 4AA25D647AA54CC7
7 changed files with 17 additions and 14 deletions

View File

@ -5,4 +5,5 @@
class ConstExpTest : public ChapterTest {
public:
virtual void run() override;
virtual const char *name() const override { return "Constexpr test"; }
};

View File

@ -5,4 +5,5 @@
class IfswitchTest : public ChapterTest {
public:
virtual void run() override;
virtual const char *name() const override { return "If/switch test"; }
};

View File

@ -5,4 +5,5 @@
class InitListTest : public ChapterTest {
public:
virtual void run() override;
virtual const char *name() const override { return "Initializer list test"; }
};

View File

@ -5,4 +5,5 @@
class NullTest : public ChapterTest {
public:
virtual void run() override;
virtual const char *name() const override { return "Nullptr test"; }
};

View File

@ -5,4 +5,7 @@
class StructuredBindingTest : public ChapterTest {
public:
virtual void run() override;
virtual const char *name() const override {
return "Structured binding test";
}
};

View File

@ -4,4 +4,5 @@ class ChapterTest {
public:
virtual ~ChapterTest() = default;
virtual void run() = 0;
virtual const char *name() const = 0;
};

View File

@ -12,24 +12,19 @@
int main(int argc, char **argv) {
std::cout << "Running " << PROJECT_NAME << ", version " << VERSION << "\n"
std::cout << "Running " << PROJECT_NAME << ", version " << VERSION
<< std::endl;
std::vector<std::tuple<const char *, std::unique_ptr<ChapterTest>>>
chapter_2_tests;
std::vector<std::unique_ptr<ChapterTest>> chapter_2_tests;
chapter_2_tests.emplace_back("Nullptr test", std::make_unique<NullTest>());
chapter_2_tests.emplace_back("If/Switch test",
std::make_unique<IfswitchTest>());
chapter_2_tests.emplace_back("Constexpr test",
std::make_unique<ConstExpTest>());
chapter_2_tests.emplace_back("Initializer list test",
std::make_unique<InitListTest>());
chapter_2_tests.emplace_back("Structured binding test",
std::make_unique<StructuredBindingTest>());
chapter_2_tests.emplace_back(std::make_unique<NullTest>());
chapter_2_tests.emplace_back(std::make_unique<IfswitchTest>());
chapter_2_tests.emplace_back(std::make_unique<ConstExpTest>());
chapter_2_tests.emplace_back(std::make_unique<InitListTest>());
chapter_2_tests.emplace_back(std::make_unique<StructuredBindingTest>());
for (auto &[test_description, test] : chapter_2_tests) {
std::cout << "\n" << test_description << ":" << std::endl;
for (auto &test : chapter_2_tests) {
std::cout << "\n" << test->name() << ":" << std::endl;
test->run();
}