Files
UnrealEngineUWP/Engine/Source/Developer/LowLevelTestsRunner/Private/EnsureScope.cpp
joe pribele 746e381b12 compile fix for when DO_ENSURE is off
and compile fix for SHIPPING
#preflight 6390d7c4c0652bbec2055937

[CL 23431790 by joe pribele in ue5-main branch]
2022-12-07 13:40:53 -05:00

46 lines
870 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)
{
#if DO_ENSURE
OldHandler = SetEnsureHandler([this, EnsureFunc](const FEnsureHandlerArgs& Args) -> bool
{
bool Handled = EnsureFunc(Args);
if (Handled)
{
++Count;
}
return Handled;
});
#endif
}
FEnsureScope::~FEnsureScope()
{
#if DO_ENSURE
SetEnsureHandler(OldHandler);
#endif
}
}