mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-23 22:53:43 +00:00
committed by
Konstantin Pastbin
parent
c9cbb64f12
commit
76ffc99abd
42
libs/testing/testregister.hpp
Normal file
42
libs/testing/testregister.hpp
Normal file
@@ -0,0 +1,42 @@
|
||||
#pragma once
|
||||
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
|
||||
class TestRegister
|
||||
{
|
||||
public:
|
||||
TestRegister(char const * testname, char const * filename, std::function<void()> && fnTest)
|
||||
: m_testname(testname), m_filename(filename), m_fn(std::move(fnTest)), m_next(nullptr)
|
||||
{
|
||||
if (FirstRegister() == nullptr)
|
||||
{
|
||||
FirstRegister() = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
TestRegister * last = FirstRegister();
|
||||
while (last->m_next != nullptr)
|
||||
last = last->m_next;
|
||||
last->m_next = this;
|
||||
}
|
||||
}
|
||||
|
||||
static TestRegister *& FirstRegister()
|
||||
{
|
||||
static TestRegister * test = nullptr;
|
||||
return test;
|
||||
}
|
||||
|
||||
// Test name.
|
||||
char const * m_testname;
|
||||
|
||||
// File name.
|
||||
char const * m_filename;
|
||||
|
||||
// Function to run test.
|
||||
std::function<void()> m_fn;
|
||||
|
||||
// Next test in chain.
|
||||
TestRegister * m_next;
|
||||
};
|
||||
Reference in New Issue
Block a user