Skip to content

Commit

Permalink
Add asserting equality of names, strings and texts without case.
Browse files Browse the repository at this point in the history
  • Loading branch information
npruehs committed May 15, 2020
1 parent bec729c commit 389157c
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 16 deletions.
Binary file not shown.
Binary file modified DaedalicTestAutomationPlugin/Content/TestEquals/TestEquals.umap
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -178,10 +178,13 @@ void UDaeTestAssertBlueprintFunctionLibrary::AssertNotEqualFloat(float Actual, f

void UDaeTestAssertBlueprintFunctionLibrary::AssertEqualName(const FName& Actual,
const FName& Expected,
const FString& What,
bool bIgnoreCase, const FString& What,
UObject* Context /*= nullptr*/)
{
if (!Actual.IsEqual(Expected))
bool bEquals = bIgnoreCase ? Actual.IsEqual(Expected, ENameCase::IgnoreCase)
: Actual.IsEqual(Expected, ENameCase::CaseSensitive);

if (!bEquals)
{
FString Message = FString::Format(*ErrorMessageFormatEqual,
{What, Expected.ToString(), Actual.ToString()});
Expand All @@ -191,10 +194,14 @@ void UDaeTestAssertBlueprintFunctionLibrary::AssertEqualName(const FName& Actual

void UDaeTestAssertBlueprintFunctionLibrary::AssertNotEqualName(const FName& Actual,
const FName& Unexpected,
bool bIgnoreCase,
const FString& What,
UObject* Context /*= nullptr*/)
{
if (Actual.IsEqual(Unexpected))
bool bEquals = bIgnoreCase ? Actual.IsEqual(Unexpected, ENameCase::IgnoreCase)
: Actual.IsEqual(Unexpected, ENameCase::CaseSensitive);

if (bEquals)
{
FString Message =
FString::Format(*ErrorMessageFormatNotEqual, {What, Unexpected.ToString()});
Expand All @@ -204,10 +211,14 @@ void UDaeTestAssertBlueprintFunctionLibrary::AssertNotEqualName(const FName& Act

void UDaeTestAssertBlueprintFunctionLibrary::AssertEqualString(const FString& Actual,
const FString& Expected,
bool bIgnoreCase,
const FString& What,
UObject* Context /*= nullptr*/)
{
if (!Actual.Equals(Expected))
ESearchCase::Type SearchCase = bIgnoreCase ? ESearchCase::IgnoreCase
: ESearchCase::CaseSensitive;

if (!Actual.Equals(Expected, SearchCase))
{
FString Message = FString::Format(*ErrorMessageFormatEqual, {What, Expected, Actual});
OnTestFailed(Context, Message);
Expand All @@ -216,10 +227,14 @@ void UDaeTestAssertBlueprintFunctionLibrary::AssertEqualString(const FString& Ac

void UDaeTestAssertBlueprintFunctionLibrary::AssertNotEqualString(const FString& Actual,
const FString& Unexpected,
bool bIgnoreCase,
const FString& What,
UObject* Context /*= nullptr*/)
{
if (Actual.Equals(Unexpected))
ESearchCase::Type SearchCase = bIgnoreCase ? ESearchCase::IgnoreCase
: ESearchCase::CaseSensitive;

if (Actual.Equals(Unexpected, SearchCase))
{
FString Message = FString::Format(*ErrorMessageFormatNotEqual, {What, Unexpected});
OnTestFailed(Context, Message);
Expand All @@ -228,10 +243,12 @@ void UDaeTestAssertBlueprintFunctionLibrary::AssertNotEqualString(const FString&

void UDaeTestAssertBlueprintFunctionLibrary::AssertEqualText(const FText& Actual,
const FText& Expected,
const FString& What,
bool bIgnoreCase, const FString& What,
UObject* Context /*= nullptr*/)
{
if (!Actual.EqualTo(Expected))
bool bEquals = bIgnoreCase ? Actual.EqualToCaseIgnored(Expected) : Actual.EqualTo(Expected);

if (!bEquals)
{
FString Message = FString::Format(*ErrorMessageFormatEqual,
{What, Expected.ToString(), Actual.ToString()});
Expand All @@ -241,10 +258,13 @@ void UDaeTestAssertBlueprintFunctionLibrary::AssertEqualText(const FText& Actual

void UDaeTestAssertBlueprintFunctionLibrary::AssertNotEqualText(const FText& Actual,
const FText& Unexpected,
bool bIgnoreCase,
const FString& What,
UObject* Context /*= nullptr*/)
{
if (Actual.EqualTo(Unexpected))
bool bEquals = bIgnoreCase ? Actual.EqualToCaseIgnored(Unexpected) : Actual.EqualTo(Unexpected);

if (bEquals)
{
FString Message =
FString::Format(*ErrorMessageFormatNotEqual, {What, Unexpected.ToString()});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,37 +99,38 @@ class DAEDALICTESTAUTOMATIONPLUGIN_API UDaeTestAssertBlueprintFunctionLibrary
/** Expects the specified names to be equal. */
UFUNCTION(BlueprintCallable, meta = (HidePin = "Context", DefaultToSelf = "Context",
DisplayName = "Assert Equal (Name)"))
static void AssertEqualName(const FName& Actual, const FName& Expected, const FString& What,
UObject* Context = nullptr);
static void AssertEqualName(const FName& Actual, const FName& Expected, bool bIgnoreCase,
const FString& What, UObject* Context = nullptr);

/** Expects the specified names not to be equal. */
UFUNCTION(BlueprintCallable, meta = (HidePin = "Context", DefaultToSelf = "Context",
DisplayName = "Assert Not Equal (Name)"))
static void AssertNotEqualName(const FName& Actual, const FName& Unexpected,
static void AssertNotEqualName(const FName& Actual, const FName& Unexpected, bool bIgnoreCase,
const FString& What, UObject* Context = nullptr);

/** Expects the specified strings to be equal. */
UFUNCTION(BlueprintCallable, meta = (HidePin = "Context", DefaultToSelf = "Context",
DisplayName = "Assert Equal (String)"))
static void AssertEqualString(const FString& Actual, const FString& Expected,
static void AssertEqualString(const FString& Actual, const FString& Expected, bool bIgnoreCase,
const FString& What, UObject* Context = nullptr);

/** Expects the specified strings not to be equal. */
UFUNCTION(BlueprintCallable, meta = (HidePin = "Context", DefaultToSelf = "Context",
DisplayName = "Assert Not Equal (String)"))
static void AssertNotEqualString(const FString& Actual, const FString& Unexpected,
const FString& What, UObject* Context = nullptr);
bool bIgnoreCase, const FString& What,
UObject* Context = nullptr);

/** Expects the specified texts to be equal. */
UFUNCTION(BlueprintCallable, meta = (HidePin = "Context", DefaultToSelf = "Context",
DisplayName = "Assert Equal (Text)"))
static void AssertEqualText(const FText& Actual, const FText& Expected, const FString& What,
UObject* Context = nullptr);
static void AssertEqualText(const FText& Actual, const FText& Expected, bool bIgnoreCase,
const FString& What, UObject* Context = nullptr);

/** Expects the specified texts not to be equal. */
UFUNCTION(BlueprintCallable, meta = (HidePin = "Context", DefaultToSelf = "Context",
DisplayName = "Assert Not Equal (Text)"))
static void AssertNotEqualText(const FText& Actual, const FText& Unexpected,
static void AssertNotEqualText(const FText& Actual, const FText& Unexpected, bool bIgnoreCase,
const FString& What, UObject* Context = nullptr);

/** Expects the specified vectors to be (nearly) equal. */
Expand Down

0 comments on commit 389157c

Please sign in to comment.