Skip to content

Commit

Permalink
Merge pull request #734 from Peter-B-/fix/unit-test-culture-invariant
Browse files Browse the repository at this point in the history
Use invariant culture in unit test string comparison
  • Loading branch information
SteveDunn authored Dec 28, 2024
2 parents 7f8b83e + ddbc895 commit 264d533
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ public void TryFormat_delegates_to_primitive()

MyDecimal d = MyDecimal.From(1.23m);

$"{d:0.000}".Should().Be("1.230");
FormattableString.Invariant($"{d:0.000}").Should().Be("1.230");
d.ToString("0.00", new CultureInfo("fr")).Should().Be("1,23");
$"{d:0.000}".Should().Be("1.230");
FormattableString.Invariant($"{d:0.000}").Should().Be("1.230");

Span<char> s2 = stackalloc char[8];
MyDecimal.From(1.23m).TryFormat(s2, out written, "000.00", CultureInfo.InvariantCulture).Should().BeTrue();
Expand Down
6 changes: 4 additions & 2 deletions tests/ConsumerTests/ToStringTests/BasicFunctionality.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Vogen.Tests.Types;
using System.Globalization;
using Vogen.Tests.Types;

namespace ConsumerTests.ToStringTests;

Expand Down Expand Up @@ -74,7 +75,8 @@ public void ToString_with_format_uses_IFormattable_methods()
Age.From(100).ToString("x8").Should().Be("00000064");


Age.From((int)Math.Pow(2, 8)).ToString("E").Should().Be("2.560000E+002");
Age.From((int)Math.Pow(2, 8)).ToString("E", CultureInfo.InvariantCulture)
.Should().Be("2.560000E+002");

Name.From("fred").ToString().Should().Be("fred");
Name.From("barney").ToString().Should().Be("barney");
Expand Down

0 comments on commit 264d533

Please sign in to comment.