未验证 提交 1e343258 编写于 作者: T Tarek Mahmoud Sayed 提交者: GitHub

[TestOnly] port test fixes (#89063)

上级 21209de7
......@@ -254,8 +254,8 @@ public static IEnumerable<object[]> Ctor_String_TestData()
yield return new object[] { "pa-IN", new [] { "pa-IN" }, true };
yield return new object[] { "pl", new [] { "pl" } };
yield return new object[] { "pl-PL", new [] { "pl-PL" } };
yield return new object[] { "prs", new [] { "prs" }, true };
yield return new object[] { "prs-AF", new [] { "prs-AF" }, true };
yield return new object[] { "prs", new [] { "prs", "fa" }, true };
yield return new object[] { "prs-AF", new [] { "prs-AF", "fa-AF" }, true };
yield return new object[] { "ps", new [] { "ps" }, true };
yield return new object[] { "ps-AF", new [] { "ps-AF" }, true };
yield return new object[] { "pt", new [] { "pt" } };
......@@ -441,7 +441,7 @@ public void TestCreationWithTemporaryLCID(int lcid)
Assert.NotEqual(lcid, new CultureInfo(lcid).LCID);
}
private static bool NotWasmWithIcu => PlatformDetection.IsNotBrowser && PlatformDetection.IsIcuGlobalization;
private static bool NotWasmWithIcu => PlatformDetection.IsNotBrowser && PlatformDetection.IsIcuGlobalization && PlatformDetection.IsNotWindowsServerCore;
[InlineData("zh-TW-u-co-zhuyin", "zh-TW", "zh-TW_zhuyin")]
[InlineData("de-DE-u-co-phonebk", "de-DE", "de-DE_phoneboo")]
......
......@@ -10,20 +10,21 @@ public class NumberFormatInfoCurrencyGroupSizes
{
public static IEnumerable<object[]> CurrencyGroupSizes_TestData()
{
yield return new object[] { NumberFormatInfo.InvariantInfo, new int[] { 3 } };
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, new int[] { 3 } };
yield return new object[] { NumberFormatInfo.InvariantInfo, new int[] { 3 }, null };
yield return new object[] { CultureInfo.GetCultureInfo("en-US").NumberFormat, new int[] { 3 }, null };
if (PlatformDetection.IsNotUsingLimitedCultures && !PlatformDetection.IsUbuntu && !PlatformDetection.IsWindows7 && !PlatformDetection.IsWindows8x && !PlatformDetection.IsFedora)
{
yield return new object[] { CultureInfo.GetCultureInfo("ur-IN").NumberFormat, new int[] { 3, 2 } };
yield return new object[] { CultureInfo.GetCultureInfo("ur-IN").NumberFormat, new int[] { 3, 2 }, new int[] { 3 }};
}
}
[Theory]
[MemberData(nameof(CurrencyGroupSizes_TestData))]
public void CurrencyGroupSizes_Get_ReturnsExpected(NumberFormatInfo format, int[] expected)
public void CurrencyGroupSizes_Get_ReturnsExpected(NumberFormatInfo format, int[] expected, int[] expectedAlternative)
{
Assert.Equal(expected, format.CurrencyGroupSizes);
Assert.True(format.CurrencyGroupSizes.AsSpan().SequenceEqual(expected.AsSpan()) || format.CurrencyGroupSizes.AsSpan().SequenceEqual(expectedAlternative.AsSpan()),
$"Expected {string.Join(", ", expected)} or {string.Join(", ", expectedAlternative ?? Array.Empty<int>())}, got {string.Join(", ", format.CurrencyGroupSizes)}");
}
[Theory]
......
......@@ -54,8 +54,6 @@ public static IEnumerable<object[]> DigitSubstitution_TestData()
yield return new object[] { "nqo-GN" , DigitShapes.NativeNational };
yield return new object[] { "pa-Arab" , DigitShapes.NativeNational };
yield return new object[] { "pa-Arab-PK", DigitShapes.NativeNational };
yield return new object[] { "prs" , DigitShapes.NativeNational };
yield return new object[] { "prs-AF" , DigitShapes.NativeNational };
yield return new object[] { "ps" , DigitShapes.NativeNational };
yield return new object[] { "ps-AF" , DigitShapes.NativeNational };
yield return new object[] { "sd" , DigitShapes.NativeNational };
......@@ -115,5 +113,22 @@ public void DigitSubstitutionListTest(string cultureName, DigitShapes shape)
}
}
[Theory]
[InlineData("prs")]
[InlineData("prs-AF")]
public void PrsNativeDigitsTest(string cultureName)
{
try
{
CultureInfo ci = CultureInfo.GetCultureInfo(cultureName);
// Some OS's set the DigitSubstitution to Context for the culture "prs" and "prs-AF". Majority of Os's set it to NativeNational.
Assert.True(ci.NumberFormat.DigitSubstitution == DigitShapes.Context || ci.NumberFormat.DigitSubstitution == DigitShapes.NativeNational);
}
catch (CultureNotFoundException)
{
// ignore the cultures that we cannot create as it is not supported on the platforms
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册