LkEngine 0.1.2
 
Loading...
Searching...
No Matches
AutomationTest.h
1#pragma once
2
5#include <LkEngine/Core/Log/Log.h>
7#include <LkEngine/Core/LObject/ObjectPtr.h>
8
9#include "TestMacros.h"
10
11namespace LkEngine::Test {
12
14 {
15 std::string Filename{};
16 int LineNumber = -1;
17 };
18
20 {
21 public:
22 LTestExecutionData() = default;
23 ~LTestExecutionData() = default;
24
25 FORCEINLINE void PushContext(const std::string& Context)
26 {
27 ContextStack.push_front(Context);
28 }
29
30 FORCEINLINE void PopContext()
31 {
32 ContextStack.pop_front();
33 }
34
35 public:
36 bool bSuccessful = false;
37 private:
38 int Warnings = 0;
39 int Errors = 0;
40 std::deque<std::string> ContextStack{};
41
45 std::deque<FTestExecutionEntry> Entries{};
46 };
47
51 class LAutomationTest : public LObject
52 {
53 public:
54 explicit LAutomationTest(const std::string& InName);
55 virtual ~LAutomationTest();
56
60 virtual bool RunTest() = 0;
61
65 virtual ETestSuite GetTestSuite() const = 0;
66
67 public:
68 bool TestEqual(const int32_t Actual, const int32_t Expected, const char* Message);
69 bool TestEqual(const int64_t Actual, const int64_t Expected, const char* Message);
70 bool TestEqual(const std::size_t Actual, const std::size_t Expected, const char* Message);
71 bool TestEqual(const float Actual, const float Expected, const char* Message);
72 bool TestGreaterEqual(const int32_t Actual, const int32_t Expected, const char* Message);
73 bool TestGreaterEqual(const int64_t Actual, const int64_t Expected, const char* Message);
74 bool TestGreaterEqual(const std::size_t Actual, const std::size_t Expected, const char* Message);
75 bool TestGreaterEqual(const float Actual, const float Expected, const char* Message);
76 bool TestGreaterThan(const int32_t Actual, const int32_t Expected, const char* Message);
77 bool TestGreaterThan(const int64_t Actual, const int64_t Expected, const char* Message);
78 bool TestGreaterThan(const float Actual, const float Expected, const char* Message);
79 bool TestGreaterThan(const std::size_t Actual, const std::size_t Expected, const char* Message);
80 bool TestLessEqual(const int32_t Actual, const int32_t Expected, const char* Message);
81 bool TestLessEqual(const int64_t Actual, const int64_t Expected, const char* Message);
82 bool TestLessEqual(const float Actual, const float Expected, const char* Message);
83 bool TestLessThan(const int32_t Actual, const int32_t Expected, const char* Message);
84 bool TestLessThan(const int64_t Actual, const int64_t Expected, const char* Message);
85 bool TestLessThan(const float Actual, const float Expected, const char* Message);
86
87 void AddError(const std::string& ErrorMessage);
88
89 const char* GetName() const { return TestName.c_str(); }
90
91 public:
93 static int SuppressLogs;
94 static bool bElevateWarningsToErrors;
95 protected:
96 LTestExecutionData ExecutionData{};
97 std::string TestName{};
98 private:
100 };
101
102}
Core macros used by the entire engine.
Core types.
LObject implementation.
Definition Object.h:46
Definition AutomationTest.h:52
virtual ETestSuite GetTestSuite() const =0
Get the test suite.
static int SuppressLogs
Definition AutomationTest.h:93
virtual bool RunTest()=0
Run the test.
Definition AutomationTest.h:20
#define LCLASS(Class)
Definition CoreMacros.h:226
Definition AutomationTest.h:14