Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small cleanup to Assert.AreEqual #4472

Merged
merged 1 commit into from
Dec 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 4 additions & 28 deletions src/TestFramework/TestFramework/Assertions/Assert.AreEqual.cs
Original file line number Diff line number Diff line change
Expand Up @@ -561,20 +561,8 @@ public static void AreEqual(float expected, float actual, float delta, string? m
public static void AreEqual(float expected, float actual, float delta, [StringSyntax(StringSyntaxAttribute.CompositeFormat)] string? message,
params object?[]? parameters)
{
if (float.IsNaN(expected) || float.IsNaN(actual) || float.IsNaN(delta))
{
string userMessage = BuildUserMessage(message, parameters);
string finalMessage = string.Format(
CultureInfo.CurrentCulture,
FrameworkMessages.AreEqualDeltaFailMsg,
userMessage,
expected.ToString(CultureInfo.CurrentCulture.NumberFormat),
actual.ToString(CultureInfo.CurrentCulture.NumberFormat),
delta.ToString(CultureInfo.CurrentCulture.NumberFormat));
ThrowAssertFailed("Assert.AreEqual", finalMessage);
}

if (Math.Abs(expected - actual) > delta)
if (float.IsNaN(expected) || float.IsNaN(actual) || float.IsNaN(delta) ||
Math.Abs(expected - actual) > delta)
{
string userMessage = BuildUserMessage(message, parameters);
string finalMessage = string.Format(
Expand Down Expand Up @@ -1130,20 +1118,8 @@ public static void AreEqual(double expected, double actual, double delta, string
public static void AreEqual(double expected, double actual, double delta, [StringSyntax(StringSyntaxAttribute.CompositeFormat)] string? message,
params object?[]? parameters)
{
if (double.IsNaN(expected) || double.IsNaN(actual) || double.IsNaN(delta))
{
string userMessage = BuildUserMessage(message, parameters);
string finalMessage = string.Format(
CultureInfo.CurrentCulture,
FrameworkMessages.AreEqualDeltaFailMsg,
userMessage,
expected.ToString(CultureInfo.CurrentCulture.NumberFormat),
actual.ToString(CultureInfo.CurrentCulture.NumberFormat),
delta.ToString(CultureInfo.CurrentCulture.NumberFormat));
ThrowAssertFailed("Assert.AreEqual", finalMessage);
}

if (Math.Abs(expected - actual) > delta)
if (double.IsNaN(expected) || double.IsNaN(actual) || double.IsNaN(delta) ||
Math.Abs(expected - actual) > delta)
{
string userMessage = BuildUserMessage(message, parameters);
string finalMessage = string.Format(
Expand Down
Loading