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

27 lines
601 B
C++
Raw Normal View History

2021-05-23 20:02:38 +00:00
#include "TestCaseRunner.h"
#include <vector>
#include <iostream>
void TestCaseRunner::AddTestCase(const std::string& label, TestCasePtr testCase)
{
mCases.push_back({label, std::move(testCase)});
}
bool TestCaseRunner::Run()
{
bool testsPassed = true;
for(const auto& test : mCases)
{
std::cout << "Running " << test.first << std::endl;
const auto result = test.second->Run();
if (!result)
{
std::cout << test.first << " Failed" << std::endl;
testsPassed = false;
break;
}
}
return testsPassed;
}