feat: provide and use a common calling interface to all chapter tests

This commit is contained in:
Michael Mandl 2023-10-21 12:31:23 +02:00
parent dfaee89d56
commit 89d1469088
Signed by: mandlm
GPG key ID: 4AA25D647AA54CC7
13 changed files with 52 additions and 26 deletions

View file

@ -1,5 +1,8 @@
#include <cstdlib>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include "constexp.h"
#include "ifswitch.h"
@ -12,20 +15,18 @@ int main(int argc, char **argv) {
std::cout << "Running " << PROJECT_NAME << ", version " << VERSION << "\n"
<< std::endl;
std::cout << "Null test:" << std::endl;
null::test();
std::vector<std::tuple<std::string, std::unique_ptr<ChapterTest>>>
chapterTests;
chapterTests.emplace_back("Null test", std::make_unique<NullTest>());
chapterTests.emplace_back("If/Switch test", std::make_unique<IfswitchTest>());
chapterTests.emplace_back("Constexpr test", std::make_unique<ConstExpTest>());
chapterTests.emplace_back("Initializer list test",
std::make_unique<InitListTest>());
std::cout << "\n"
<< "Constexpr test:" << std::endl;
constexp::test();
std::cout << "\n"
<< "Ifswitch test:" << std::endl;
ifswitch::test();
std::cout << "\n"
<< "Initializer list test:" << std::endl;
initlist::test();
for (auto &[name, test] : chapterTests) {
std::cout << "\n" << name << std::endl;
test->test();
}
std::cout << "\nExiting" << std::endl;