stuff-from-scratch/test/test_utils/TestCaseRunner.cpp

45 lines
980 B
C++
Raw Normal View History

2021-05-23 20:02:38 +00:00
#include "TestCaseRunner.h"
#include <vector>
#include <iostream>
2022-11-29 18:00:19 +00:00
TestCaseRunner::~TestCaseRunner()
2021-05-23 20:02:38 +00:00
{
2022-11-29 18:00:19 +00:00
for (auto testCase : mCases)
{
//delete testCase;
}
}
void TestCaseRunner::addTestCase(const std::string& label, const std::string& tag, TestCase::TestCaseFunction func)
{
auto test_case = new TestCase(label, tag, func);
mCases.push_back(test_case);
2021-05-23 20:02:38 +00:00
}
2022-11-29 18:00:19 +00:00
bool TestCaseRunner::run()
2021-05-23 20:02:38 +00:00
{
2022-11-29 18:00:19 +00:00
for (auto test_case : mCases)
{
std::cout << "TestFramework: Running Test - " << test_case->getName() << std::endl;
test_case->run();
}
2021-05-23 20:02:38 +00:00
bool testsPassed = true;
2022-11-29 18:00:19 +00:00
/*
2021-05-23 20:02:38 +00:00
for(const auto& test : mCases)
{
2022-11-29 18:00:19 +00:00
std::cout << "Running " << test->getName() << std::endl;
const auto result = test->Run();
2021-05-23 20:02:38 +00:00
if (!result)
{
2022-11-29 18:00:19 +00:00
std::cout << test->getName() << " Failed" << std::endl;
2021-05-23 20:02:38 +00:00
testsPassed = false;
break;
}
}
return testsPassed;
2022-11-29 18:00:19 +00:00
*/
return true;
2021-05-23 20:02:38 +00:00
}