Skip to content

Commit b0ae2c3

Browse files
committed
AssertEx: Add more info when EqualTolerance() assert fails
Print expected, actual and diff values as well as the tolerance value.
1 parent beadd3d commit b0ae2c3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

UnitsNet.Tests/AssertEx.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Xunit;
1+
using Xunit;
22

33
namespace UnitsNet.Tests
44
{
@@ -9,7 +9,7 @@ public static class AssertEx
99
{
1010
public static void EqualTolerance(double expected, double actual, double tolerance)
1111
{
12-
Assert.True(actual >= expected - tolerance && actual <= expected + tolerance, "Within tolerance: " + tolerance);
12+
Assert.True(actual >= expected - tolerance && actual <= expected + tolerance, $"Values are not equal within tolerance: {tolerance}\nExpected: {expected}\nActual: {actual}\nDiff: {actual - expected:e}");
1313
}
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)