You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
added a tls for an ensure handler callback to let the reporting log of ensures to be overridden the following macros are supported in lowlevel tests REQUIRE_ENSURE CHECK_ENSURE REQUIRE_CHECK #rb devin.doucette #preflight 634827c457048bdb82b43ffe [CL 22505260 by joe pribele in ue5-main branch]
42 lines
828 B
C++
42 lines
828 B
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
#include "LowLevelTestsRunner/EnsureScope.h"
|
|
#include "Containers/StringConv.h"
|
|
|
|
namespace UE::LowLevelTests
|
|
{
|
|
|
|
FEnsureScope::FEnsureScope()
|
|
: FEnsureScope([](const FEnsureHandlerArgs&) { return true; })
|
|
{
|
|
}
|
|
|
|
|
|
FEnsureScope::FEnsureScope(const ANSICHAR* ExpectedMsg)
|
|
: FEnsureScope([ExpectedMsg](const FEnsureHandlerArgs& Args)
|
|
{
|
|
return FPlatformString::Stricmp(ExpectedMsg, Args.Message) == 0;
|
|
})
|
|
{
|
|
}
|
|
|
|
FEnsureScope::FEnsureScope(TFunction<bool(const FEnsureHandlerArgs& Args)> EnsureFunc)
|
|
: Count(0)
|
|
{
|
|
OldHandler = SetEnsureHandler([this, EnsureFunc](const FEnsureHandlerArgs& Args) -> bool
|
|
{
|
|
bool Handled = EnsureFunc(Args);
|
|
if (Handled)
|
|
{
|
|
++Count;
|
|
}
|
|
return Handled;
|
|
});
|
|
}
|
|
|
|
FEnsureScope::~FEnsureScope()
|
|
{
|
|
SetEnsureHandler(OldHandler);
|
|
}
|
|
|
|
} |