UDocumentation
UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Assertions.h
Go to the documentation of this file.
1
// Copyright Epic Games, Inc. All Rights Reserved.
2
3
#pragma once
4
5
#if WITH_LOW_LEVEL_TESTS
6
#include "TestMacros/Assertions.h"
// HEADER_UNIT_IGNORE
7
#elif defined(WITH_AUTOMATION_TESTS) || (WITH_DEV_AUTOMATION_TESTS || WITH_PERF_AUTOMATION_TESTS)
8
#include "
Misc/AssertionMacros.h
"
9
#include "
Misc/AutomationTest.h
"
10
#include "
Tests/EnsureScope.h
"
11
#include "
Tests/CheckScope.h
"
12
13
//requires that an UE `ensure` fails in this call
14
#define REQUIRE_ENSURE(...) INTERNAL_UE_ENSURE( "REQUIRE_ENSURE", DO_ENSURE, #__VA_ARGS__, __VA_ARGS__ )
15
16
//requires that an UE `ensure` fails with a message that matches the supplied message
17
#define REQUIRE_ENSURE_MSG(msg, ...) INTERNAL_UE_ENSURE_MSG(msg, "REQUIRE_ENSURE", DO_ENSURE, #__VA_ARGS__, __VA_ARGS__ )
18
19
//checks that an UE `ensure` fails in this call
20
#define CHECK_ENSURE(...) INTERNAL_UE_ENSURE( "CHECK_ENSURE", DO_ENSURE, Catch::ResultDisposition::ContinueOnFailure, #__VA_ARGS__, __VA_ARGS__ )
21
22
//checks that an UE `ensure` fails with a message that matches the supplied message
23
#define CHECK_ENSURE_MSG(msg, ...) INTERNAL_UE_ENSURE_MSG(msg, "CHECK_ENSURE", DO_ENSURE, Catch::ResultDisposition::ContinueOnFailure, #__VA_ARGS__, __VA_ARGS__ )
24
25
//requires that a UE `check` fails in this call
26
#define REQUIRE_CHECK(...) INTERNAL_UE_CHECK( "REQUIRE_CHECK", DO_CHECK, #__VA_ARGS__, __VA_ARGS__ )
27
28
//requires that a UE `check` fails in this call contains the supplies message
29
#define REQUIRE_CHECK_MSG(msg, ...) INTERNAL_UE_CHECK_MSG(msg, "REQUIRE_CHECK", DO_CHECK, #__VA_ARGS__, __VA_ARGS__ )
30
31
//requires that a UE `checkSlow` fails in this call
32
#define REQUIRE_CHECK_SLOW(...) INTERNAL_UE_CHECK( "REQUIRE_CHECK_SLOW", DO_GUARD_SLOW, #__VA_ARGS__, __VA_ARGS__ )
33
34
//requires that a UE `checkSlow` fails in this call contains the supplies message
35
#define REQUIRE_CHECK_SLOW_MSG(msg, ...) INTERNAL_UE_CHECK_MSG(msg, "REQUIRE_CHECK_SLOW", DO_GUARD_SLOW, #__VA_ARGS__, __VA_ARGS__ )
36
37
#define INTERNAL_UE_ENSURE( macroName, doEnsure, ensureExpr, ... ) \
38
do { \
39
FEnsureScope scope; \
40
static_cast<void>(__VA_ARGS__); \
41
bool bEncounteredEnsure = scope.GetCount() > 0; \
42
if (doEnsure && !bEncounteredEnsure) \
43
FAutomationTestFramework::Get().GetCurrentTest()->AddError(TEXT("Expected failure of `ensure` not received.")); \
44
} while(false) \
45
46
#define INTERNAL_UE_ENSURE_MSG(msg, macroName, doEnsure, ensureExpr, ... ) \
47
do { \
48
FEnsureScope scope(msg); \
49
static_cast<void>(__VA_ARGS__); \
50
bool bEncounteredEnsure = scope.GetCount() > 0; \
51
if (doEnsure && !bEncounteredEnsure) \
52
FAutomationTestFramework::Get().GetCurrentTest()->AddError(TEXT("Expected failure of `ensure` with message %s not received", msg)); \
53
} while(false) \
54
55
#define INTERNAL_UE_CHECK(macroName, doCheck, checkExpr, ... ) \
56
do { \
57
FCheckScope scope; \
58
(void)(__VA_ARGS__); \
59
bool bEncounteredEnsure = scope.GetCount() > 0; \
60
if (doCheck && !bEncounteredEnsure) \
61
FAutomationTestFramework::Get().GetCurrentTest()->AddError(TEXT("Expected failure of `check` not received")); \
62
} while(false) \
63
64
#define INTERNAL_UE_CHECK_MSG(msg, macroName, doCheck, checkExpr, ... ) \
65
do { \
66
FCheckScope scope(msg); \
67
(void)(__VA_ARGS__); \
68
bool bEncounteredEnsure = scope.GetCount() > 0; \
69
if (doCheck && !bEncounteredEnsure) \
70
FAutomationTestFramework::Get().GetCurrentTest()->AddError(TEXT("Expected failure of `check` containing message %s not received", msg)); \
71
} while(false) \
72
73
#endif
AssertionMacros.h
AutomationTest.h
CheckScope.h
EnsureScope.h
Engine
Source
Runtime
Core
Public
Tests
Assertions.h
Generated by
1.9.8