forked from fastbuild/fastbuild
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTestManager.h
More file actions
59 lines (48 loc) · 1.98 KB
/
TestManager.h
File metadata and controls
59 lines (48 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// TestManager
//------------------------------------------------------------------------------
#pragma once
// Includes
//------------------------------------------------------------------------------
#include "Core/Containers/Singleton.h"
#include "Core/Env/Assert.h"
#include "Core/Env/MSVCStaticAnalysis.h"
#include "Core/Env/Types.h"
#include "Core/Time/Timer.h"
// Forward Declarations
//------------------------------------------------------------------------------
class TestGroup;
// TestManager
//------------------------------------------------------------------------------
class TestManager : public Singleton<TestManager>
{
public:
TestManager();
~TestManager();
// run all tests, or tests from a group
bool RunTests( const char * testGroup = nullptr );
// tests register (using the test declaration macros) via this interface
static void RegisterTestGroup( TestGroup * testGroup );
// When tests are being executed, they are wrapped with these
void TestBegin( TestGroup * testGroup, const char * testName );
void TestEnd();
// TEST_ASSERT uses this interface to notify of assertion failures
static bool AssertFailure( const char * message, const char * file, uint32_t line );
// TEST_ASSERTM uses this interface to notify of assertion failures
static bool AssertFailureM( const char* message, const char* file, uint32_t line, MSVC_SAL_PRINTF const char* formatString, ... ) FORMAT_STRING( 4, 5 );
private:
Timer m_Timer;
enum : uint32_t { MAX_TESTS = 1024 };
class TestInfo
{
public:
TestGroup * m_TestGroup = nullptr;
const char * m_TestName = nullptr;
bool m_Passed = false;
bool m_MemoryLeaks = false;
float m_TimeTaken = 0.0f;
};
static uint32_t s_NumTests;
static TestInfo s_TestInfos[ MAX_TESTS ];
static TestGroup * s_FirstTest;
};
//------------------------------------------------------------------------------