Assertions¶
Most ATC assertions have two variants. EXPECT and ASSERT. Conditions that fail an ASSERT produce a fatal error and will end the test and stop
further tasks from executing. Conditions that fail an EXPECT will cause a non-fatal error and the test will continue, but will mark the test as
failed. Each variant provides a message regarding the condition and the failure.
Boolean Conditions¶
ATC_ASSERT_TRUE(condition)¶
ATC_EXPECT_TRUE(condition)¶
Verifies if the condition is true.
ATC_ASSERT_FALSE(condition)¶
ATC_EXPECT_FALSE(condition)¶
Verifies if the condition is false.
Equality Checks¶
ATC_ASSERT_EQUAL(actual, expected)¶
ATC_EXPECT_EQUAL(actual, expected)¶
Verifies if the actual and expected values are equal using == comparison.
ATC_ASSERT_NOT_EQUAL(actual, expected)¶
ATC_EXPECT_NOT_EQUAL(actual, expected)¶
Verifies if the actual and expected values are not equal using != comparison.
Arithmetic Checks¶
ATC_ASSERT_LT(A, B)¶
ATC_EXPECT_LT(A, B)¶
Verifies A < B
ATC_ASSERT_LE(A, B)¶
ATC_EXPECT_LE(A, B)¶
Verifies A <= B
ATC_ASSERT_GT(A, B)¶
ATC_EXPECT_GT(A, B)¶
Verifies A > B
ATC_ASSERT_GE(A, B)¶
ATC_EXPECT_GE(A, B)¶
Verifies A >= B
ATC_ASSERT_NEAR(actual, expected, tolerance)¶
ATC_EXPECT_NEAR(actual, expected, tolerance)¶
Verifies if the actual and expected values are within a specified tolerance. ATC_ASSERT_NEAR(CurrentSpeed, 600.f, 0.1f).
Pointer and Object Validity¶
ATC_ASSERT_NULL(value)¶
ATC_EXPECT_NULL(value)¶
Verifies that value == nullptr.
ATC_ASSERT_NOT_NULL(value)¶
ATC_EXPECT_NOT_NULL(value)¶
Verifies that value != nullptr.
Exception Checks¶
These exception checks are only intended for studios who have specifically opted into C++ exceptions in their custom built-from-source Unreal Engine build. Most users will not need these, and you should probably never be throwing exceptions in Unreal Engine.
To use exception-based assertions in ATC, enable exceptions (bForceEnableExceptions = true) and define ATC_WITH_CPP_EXCEPTIONS=1 in your build (e.g. via Target.cs, BuildGraph, or command line).
Attempting to use these macros without enabling exceptions will result in a fatal assertion failure.
ATC_ASSERT_THROW(statement, exceptionType)¶
ATC_EXPECT_THROW(statement, exceptionType)¶
Verifies that statement throws an exception compatible with exceptionType.
ATC_ASSERT_ANY_THROW(statement)¶
ATC_EXPECT_ANY_THROW(statement)¶
Verifies that statement throws an exception of any type.
ATC_ASSERT_NO_THROW(statement)¶
ATC_EXPECT_NO_THROW(statement)¶
Verifies that statement does not throw an exception.
Unreal-Specific Checks¶
ATC_ASSERT_VALID(object)¶
ATC_EXPECT_VALID(object)¶
Verifies object is a usable object; non-null and not pending-kill or garbage collection.
ATC_ASSERT_COMPONENT_EXISTS(component)¶
ATC_EXPECT_COMPONENT_EXISTS(component)¶
Verifies that the given component is a usable component object; non-null and not pending-kill or garbage collection.
ATC_ASSERT_TAG(component, tag)¶
ATC_EXPECT_TAG(component, tag)¶
Verifies that the given component has the specified tag.
ATC_ASSERT_NOT_TAG(component, tag)¶
ATC_EXPECT_NOT_TAG(component, tag)¶
Verifies that the given component does not have the specified tag.
ATC_ASSERT_ACTOR_TAG(actor, tag)¶
ATC_EXPECT_ACTOR_TAG(actor, tag)¶
Verifies that the given actor has the specified tag.
ATC_ASSERT_NOT_ACTOR_TAG(actor, tag)¶
ATC_EXPECT_NOT_ACTOR_TAG(actor, tag)¶
Verifies that the given actor does not have the specified tag.
Asynchronous Checks¶
Asynchronous checks block the execution of further tasks until the check is complete.
Blocking doesn't apply to tasks when taken in the context of ATC_PARALLEL unless the task is explicitly dependent on the result of the asynchronous
check through ATC_DEP.
ATC_ASSERT_EVENTUALLY(condition, timeoutSeconds)¶
ATC_EXPECT_EVENTUALLY(condition, timeoutSeconds)¶
Checks that condition should become true within the timeframe.