Skip to content

Commit

Permalink
Merge pull request #141 from cfis/test_suite
Browse files Browse the repository at this point in the history
Support running test suite
  • Loading branch information
jasonroelofs authored Dec 28, 2020
2 parents 1217d31 + 96d7b95 commit 875c7a8
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions test/unittest.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <algorithm>
#include <iostream>
#include <map>
#include "unittest.hpp"
Expand Down Expand Up @@ -85,18 +86,43 @@ run(Test_Result & result)
}
}

int main()
char* findOption(char** begin, char** end, const std::string& option)
{
char** itr = std::find(begin, end, option);
if (itr != end && ++itr != end)
{
return *itr;
}
return nullptr;
}

int main(int argc, char** argv)
{
std::vector<Test_Suite> suites;

char* moduleName = findOption(argv, argv + argc, "--suite");
if (moduleName)
{
Test_Suite suite = test_suites()[moduleName];
suites.push_back(suite);
}
else
{
std::transform(test_suites().begin(), test_suites().end(),
std::back_inserter(suites),
[](auto& pair)
{
return pair.second;
});
}

Test_Result result;
size_t num_tests = 0;

for(Test_Suites::iterator it = test_suites().begin(),
end = test_suites().end();
it != end;
++it)

for (Test_Suite& suite : suites)
{
it->second.run(result);
num_tests += it->second.size();
suite.run(result);
num_tests += suite.size();
}

std::cout << std::endl;
Expand Down

0 comments on commit 875c7a8

Please sign in to comment.