stuff-from-scratch/test/test_utils/TestCase.h

46 lines
734 B
C
Raw Normal View History

2021-05-23 20:02:38 +00:00
#pragma once
#include <memory>
2022-11-29 18:00:19 +00:00
#include <string>
#include <functional>
2021-05-23 20:02:38 +00:00
class TestCase
{
public:
2022-11-29 18:00:19 +00:00
using TestCaseFunction = std::function<void()>;
TestCase(const std::string& name, const std::string& tags, TestCaseFunction func)
2023-01-23 11:06:30 +00:00
: mTestFunction(func),
mName(name),
mTags(tags)
2022-11-29 18:00:19 +00:00
{
};
2021-05-23 20:02:38 +00:00
virtual ~TestCase() = default;
2022-11-29 18:00:19 +00:00
const std::string& getName() const
{
return mName;
}
const std::string& getTags() const
{
return mTags;
}
virtual void run()
{
mTestFunction();
};
public:
TestCaseFunction mTestFunction{nullptr};
private:
std::string mName;
std::string mTags;
2021-05-23 20:02:38 +00:00
};
using TestCasePtr = std::unique_ptr<TestCase>;