mirror of
https://github.com/projectM-visualizer/projectm.git
synced 2026-02-07 01:55:38 +00:00
Note: SDL test UI won't compile after this commit. Will be fixed in a later commit, when the playlist library is done.
50 lines
1.3 KiB
C++
50 lines
1.3 KiB
C++
//
|
|
// Created by matthew on 1/7/19.
|
|
//
|
|
|
|
#include <iostream>
|
|
#include <TestRunner.hpp>
|
|
#include <MilkdropPresetFactory/Param.hpp>
|
|
|
|
std::vector<Test *> TestRunner::tests;
|
|
|
|
|
|
bool Test::verify(const char *test, bool success)
|
|
{
|
|
if (!success)
|
|
std::cout << "failed " << test << std::endl;
|
|
return success;
|
|
}
|
|
|
|
|
|
bool TestRunner::run()
|
|
{
|
|
if (tests.empty())
|
|
{
|
|
// We still call register/run tests in NDEBUG (useful for performance testing)
|
|
// but tests may choose to comment out body to save space
|
|
tests.push_back(Param::test());
|
|
tests.push_back(Expr::test());
|
|
}
|
|
|
|
int count = 0;
|
|
bool successful = true;
|
|
for (auto it=tests.begin() ; it < tests.end() ; it++ )
|
|
{
|
|
if (nullptr == (*it))
|
|
continue;
|
|
count++;
|
|
std::cout << "TestRunner: " << (*it)->getName() << " started" << std::endl;
|
|
std::cout.flush();
|
|
bool result = (*it)->test();
|
|
successful &= result;
|
|
if (result)
|
|
std::cout << "TestRunner: " << (*it)->getName() << " passed" << std::endl;
|
|
else
|
|
std::cout << "TestRunner: " << (*it)->getName() << " FAILED" << std::endl;
|
|
}
|
|
if (0 == count)
|
|
std::cout << "TestRunner: no tests found to run" << std::endl;
|
|
return successful;
|
|
}
|