Skip to content

Commit 72c8e2a

Browse files
authored
🧪Fix test on Norwegian culture, order by StringComparer.Ordinal (#1602)
`aa` is sorted as `å` in Norwegian culture with the default comparer it seems, so explicitly specify a string comparer.
1 parent 040892d commit 72c8e2a

File tree

129 files changed

+393
-393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

129 files changed

+393
-393
lines changed

CodeGen/Generators/UnitsNetGen/UnitTestBaseClassGenerator.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public UnitTestBaseClassGenerator(Quantity quantity)
118118
_otherOrBaseUnit = quantity.Units.Where(u => u != _baseUnit).DefaultIfEmpty(_baseUnit).First();
119119
_otherOrBaseUnitFullName = $"{_unitEnumName}.{_otherOrBaseUnit.SingularName}";
120120
_isDimensionless = quantity.BaseDimensions is { L: 0, M: 0, T: 0, I: 0, Θ: 0, N: 0, J: 0 };
121-
121+
122122
_defaultAbbreviationsForCulture = new Dictionary<string, Dictionary<Unit, string>>();
123123
var abbreviationsForCulture = new Dictionary<string, Dictionary<string, List<Unit>>>();
124124
foreach (Unit unit in quantity.Units)
@@ -324,7 +324,7 @@ public void Ctor_UnitSystem_ThrowsArgumentExceptionIfNotSupported()
324324
[Fact]
325325
public void {_quantity.Name}_QuantityInfo_ReturnsQuantityInfoDescribingQuantity()
326326
{{
327-
{_unitEnumName}[] unitsOrderedByName = EnumHelper.GetValues<{_unitEnumName}>().OrderBy(x => x.ToString()).ToArray();
327+
{_unitEnumName}[] unitsOrderedByName = EnumHelper.GetValues<{_unitEnumName}>().OrderBy(x => x.ToString(), StringComparer.OrdinalIgnoreCase).ToArray();
328328
var quantity = new {_quantity.Name}(1, {_baseUnitFullName});
329329
330330
QuantityInfo<{_quantity.Name}, {_unitEnumName}> quantityInfo = quantity.QuantityInfo;
@@ -869,7 +869,7 @@ public void TryParseUnitWithAmbiguousAbbreviation(string culture, string abbrevi
869869
Writer.WL($@"
870870
public void GetAbbreviationForCulture(string culture, {_unitEnumName} unit, string expectedAbbreviation)
871871
{{
872-
var defaultAbbreviation = {_quantity.Name}.GetAbbreviation(unit, CultureInfo.GetCultureInfo(culture));
872+
var defaultAbbreviation = {_quantity.Name}.GetAbbreviation(unit, CultureInfo.GetCultureInfo(culture));
873873
Assert.Equal(expectedAbbreviation, defaultAbbreviation);
874874
}}
875875
");
@@ -881,7 +881,7 @@ public void GetAbbreviationWithDefaultCulture()
881881
{{
882882
var expectedAbbreviation = UnitsNetSetup.Default.UnitAbbreviations.GetDefaultAbbreviation(unit);
883883
884-
var defaultAbbreviation = {_quantity.Name}.GetAbbreviation(unit);
884+
var defaultAbbreviation = {_quantity.Name}.GetAbbreviation(unit);
885885
886886
Assert.Equal(expectedAbbreviation, defaultAbbreviation);
887887
}});
@@ -1124,7 +1124,7 @@ public void Equals_Logarithmic_WithTolerance(double firstValue, double secondVal
11241124
Assert.True(quantity.Equals(quantity, maxTolerance));
11251125
Assert.True(quantity.Equals(otherQuantity, largerTolerance));
11261126
Assert.False(quantity.Equals(otherQuantity, smallerTolerance));
1127-
// note: it's currently not possible to test this due to the rounding error from (quantity - otherQuantity)
1127+
// note: it's currently not possible to test this due to the rounding error from (quantity - otherQuantity)
11281128
// Assert.True(quantity.Equals(otherQuantity, maxTolerance));
11291129
}}
11301130
@@ -1187,7 +1187,7 @@ public void Equals_WithNegativeTolerance_ThrowsArgumentOutOfRangeException()
11871187
");
11881188
}
11891189
}
1190-
1190+
11911191
Writer.WL($@"
11921192
11931193
[Fact]

UnitsNet.Tests/GeneratedCode/TestsBase/AbsorbedDoseOfIonizingRadiationTestsBase.g.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/GeneratedCode/TestsBase/AccelerationTestsBase.g.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/GeneratedCode/TestsBase/AmountOfSubstanceTestsBase.g.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/GeneratedCode/TestsBase/AmplitudeRatioTestsBase.g.cs

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/GeneratedCode/TestsBase/AngleTestsBase.g.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/GeneratedCode/TestsBase/AreaDensityTestsBase.g.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/GeneratedCode/TestsBase/AreaMomentOfInertiaTestsBase.g.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/GeneratedCode/TestsBase/AreaTestsBase.g.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

UnitsNet.Tests/GeneratedCode/TestsBase/BitRateTestsBase.g.cs

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)