mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
fix static initialisation order issues causing the tests vector to get reset
This commit is contained in:
parent
1ab40c8cde
commit
9a9dd64306
|
@ -1,6 +1,11 @@
|
|||
#include "test_suite.hpp"
|
||||
#include <iostream>
|
||||
|
||||
std::vector<std::pair<std::function<void(void)>, std::string>> test_suite::tests;
|
||||
std::vector<std::pair<std::function<void(void)>, std::string>> &test_suite::tests()
|
||||
{
|
||||
static std::vector<std::pair<std::function<void(void)>, std::string>> all_tests;
|
||||
return all_tests;
|
||||
}
|
||||
|
||||
std::string build_name(const std::string &pretty, const std::string &method)
|
||||
{
|
||||
|
@ -11,12 +16,12 @@ test_status test_suite::go()
|
|||
{
|
||||
test_status status;
|
||||
|
||||
for (auto test : tests)
|
||||
for (auto test : tests())
|
||||
{
|
||||
try
|
||||
{
|
||||
test.first();
|
||||
std::cout << ".";
|
||||
std::cout << '.';
|
||||
status.tests_passed++;
|
||||
}
|
||||
catch (std::exception &ex)
|
||||
|
|
|
@ -31,9 +31,9 @@ public:
|
|||
protected:
|
||||
static void register_test_internal(std::function<void()> t, const std::string &function)
|
||||
{
|
||||
tests.push_back(std::make_pair(t, function));
|
||||
tests().push_back(std::make_pair(t, function));
|
||||
}
|
||||
|
||||
private:
|
||||
static std::vector<std::pair<std::function<void()>, std::string>> tests;
|
||||
static std::vector<std::pair<std::function<void(void)>, std::string>> &tests();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user