mirror of
https://github.com/VSadov/Satori.git
synced 2025-06-09 09:34:49 +09:00
[Apple-Mobile][Globalization] Refactoring of CalendarData.iOS and new DateTimeFormatInfo* tests (#102464)
* enable ShortDatePattern tests + refactor * LongDatePattern correct format * LongDatePattern tests * fix EnumDatePatterns AddRange for Apple Hybrid * remove duplicate invariant ShorDatePattern test * remove duplicate en-US LongDatePattern case * MonthDayPattern test cases * add _ICU suffix to DatePattern names * DayNames ICU test cases * AbbreviatedDayNames ICU tests * Move GetCalendarInfoNative to EnumCalendarInfo ICU * MonthNames test suit for ICU * AbbreviatedMonthGenitiveNames ICU test suit * AbbreviatedMonthNames ICU test suit * MonthGenitive ICU test suit * refactor CalendarData.iOS.cs to use more of the shared CalendarData.ICU code * refactor new DateTiemFormatInfo* API tests
This commit is contained in:
parent
c09ec6552f
commit
42b2b19e88
13 changed files with 160 additions and 75 deletions
|
@ -436,7 +436,12 @@ namespace System.Globalization
|
|||
#pragma warning disable CS8500 // takes address of managed type
|
||||
private static unsafe bool EnumCalendarInfo(string localeName, CalendarId calendarId, CalendarDataType dataType, IcuEnumCalendarsData* callbackContext)
|
||||
{
|
||||
#if TARGET_MACCATALYST || TARGET_IOS || TARGET_TVOS
|
||||
callbackContext->Results.AddRange(GetCalendarInfoNative(localeName, calendarId, dataType).Split("||"));
|
||||
return callbackContext->Results.Count > 0;
|
||||
#else
|
||||
return Interop.Globalization.EnumCalendarInfo(&EnumCalendarInfoCallback, localeName, calendarId, dataType, (IntPtr)callbackContext);
|
||||
#endif
|
||||
}
|
||||
#pragma warning restore CS8500
|
||||
|
||||
|
|
|
@ -17,24 +17,15 @@ namespace System.Globalization
|
|||
|
||||
sNativeName = GetCalendarInfoNative(localeName, calendarId, CalendarDataType.NativeName);
|
||||
sMonthDay = GetCalendarInfoNative(localeName, calendarId, CalendarDataType.MonthDay);
|
||||
saShortDates = GetCalendarInfoNative(localeName, calendarId, CalendarDataType.ShortDates).Split("||");
|
||||
// Handle ShortDatePattern to have "yyyy" year format
|
||||
List<string> shortDatePatternList = new List<string>(saShortDates);
|
||||
for (int i = 0; i < shortDatePatternList.Count; i++)
|
||||
{
|
||||
shortDatePatternList[i] = NormalizeDatePattern(shortDatePatternList[i]);
|
||||
}
|
||||
FixDefaultShortDatePattern(shortDatePatternList);
|
||||
saShortDates = shortDatePatternList.ToArray();
|
||||
|
||||
saLongDates = GetCalendarInfoNative(localeName, calendarId, CalendarDataType.LongDates).Split("||");
|
||||
saYearMonths = GetCalendarInfoNative(localeName, calendarId, CalendarDataType.YearMonths).Split("||");
|
||||
saDayNames = GetCalendarInfoNative(localeName, calendarId, CalendarDataType.DayNames).Split("||");
|
||||
saAbbrevDayNames = GetCalendarInfoNative(localeName, calendarId, CalendarDataType.AbbrevDayNames).Split("||");
|
||||
saSuperShortDayNames = GetCalendarInfoNative(localeName, calendarId, CalendarDataType.SuperShortDayNames).Split("||");
|
||||
EnumDatePatterns(localeName, calendarId, CalendarDataType.ShortDates, out this.saShortDates!);
|
||||
EnumDatePatterns(localeName, calendarId, CalendarDataType.LongDates, out this.saLongDates!);
|
||||
EnumDatePatterns(localeName, calendarId, CalendarDataType.YearMonths, out this.saYearMonths!);
|
||||
EnumCalendarInfo(localeName, calendarId, CalendarDataType.DayNames, out this.saDayNames!);
|
||||
EnumCalendarInfo(localeName, calendarId, CalendarDataType.AbbrevDayNames, out this.saAbbrevDayNames!);
|
||||
EnumCalendarInfo(localeName, calendarId, CalendarDataType.SuperShortDayNames, out this.saSuperShortDayNames!);
|
||||
|
||||
string? leapHebrewMonthName = null;
|
||||
saMonthNames = NormalizeMonthArray(GetCalendarInfoNative(localeName, calendarId, CalendarDataType.MonthNames).Split("||"), calendarId, ref leapHebrewMonthName);
|
||||
EnumMonthNames(localeName, calendarId, CalendarDataType.MonthNames, out this.saMonthNames!, ref leapHebrewMonthName);
|
||||
if (leapHebrewMonthName != null)
|
||||
{
|
||||
Debug.Assert(saMonthNames != null);
|
||||
|
@ -51,12 +42,12 @@ namespace System.Globalization
|
|||
saMonthNames[6] = leapHebrewMonthName;
|
||||
|
||||
}
|
||||
saAbbrevMonthNames = NormalizeMonthArray(GetCalendarInfoNative(localeName, calendarId, CalendarDataType.AbbrevMonthNames).Split("||"), calendarId, ref leapHebrewMonthName);
|
||||
saMonthGenitiveNames = NormalizeMonthArray(GetCalendarInfoNative(localeName, calendarId, CalendarDataType.MonthGenitiveNames).Split("||"), calendarId, ref leapHebrewMonthName);
|
||||
saAbbrevMonthGenitiveNames = NormalizeMonthArray(GetCalendarInfoNative(localeName, calendarId, CalendarDataType.AbbrevMonthGenitiveNames).Split("||"), calendarId, ref leapHebrewMonthName);
|
||||
EnumMonthNames(localeName, calendarId, CalendarDataType.AbbrevMonthNames, out this.saAbbrevMonthNames!, ref leapHebrewMonthName);
|
||||
EnumMonthNames(localeName, calendarId, CalendarDataType.MonthGenitiveNames, out this.saMonthGenitiveNames!, ref leapHebrewMonthName);
|
||||
EnumMonthNames(localeName, calendarId, CalendarDataType.AbbrevMonthGenitiveNames, out this.saAbbrevMonthGenitiveNames!, ref leapHebrewMonthName);
|
||||
|
||||
saEraNames = NormalizeEraNames(calendarId, GetCalendarInfoNative(localeName, calendarId, CalendarDataType.EraNames).Split("||"));
|
||||
saAbbrevEraNames = Array.Empty<string>();
|
||||
EnumEraNames(localeName, calendarId, CalendarDataType.EraNames, out this.saEraNames!);
|
||||
EnumEraNames(localeName, calendarId, CalendarDataType.AbbrevEraNames, out this.saAbbrevEraNames!);
|
||||
|
||||
return sNativeName != null && saShortDates != null && saLongDates != null && saYearMonths != null &&
|
||||
saDayNames != null && saAbbrevDayNames != null && saSuperShortDayNames != null && saMonthNames != null &&
|
||||
|
@ -64,49 +55,6 @@ namespace System.Globalization
|
|||
saEraNames != null && saAbbrevEraNames != null;
|
||||
}
|
||||
|
||||
private static string[] NormalizeEraNames(CalendarId calendarId, string[]? eraNames)
|
||||
{
|
||||
// .NET expects that only the Japanese calendars have more than 1 era.
|
||||
// So for other calendars, only return the latest era.
|
||||
if (calendarId != CalendarId.JAPAN && calendarId != CalendarId.JAPANESELUNISOLAR && eraNames?.Length > 0)
|
||||
return new string[] { eraNames![eraNames.Length - 1] };
|
||||
|
||||
return eraNames ?? Array.Empty<string>();
|
||||
}
|
||||
|
||||
private static string[] NormalizeMonthArray(string[] months, CalendarId calendarId, ref string? leapHebrewMonthName)
|
||||
{
|
||||
if (months.Length == 13)
|
||||
return months;
|
||||
|
||||
string[] normalizedMonths = new string[13];
|
||||
// the month-name arrays are expected to have 13 elements. If only returns 12, add an
|
||||
// extra empty string to fill the array.
|
||||
if (months.Length == 12)
|
||||
{
|
||||
normalizedMonths[12] = "";
|
||||
months.CopyTo(normalizedMonths, 0);
|
||||
return normalizedMonths;
|
||||
}
|
||||
|
||||
if (months.Length > 13)
|
||||
{
|
||||
Debug.Assert(calendarId == CalendarId.HEBREW && months.Length == 14);
|
||||
|
||||
if (calendarId == CalendarId.HEBREW)
|
||||
{
|
||||
leapHebrewMonthName = months[13];
|
||||
}
|
||||
for (int i = 0; i < 13; i++)
|
||||
{
|
||||
normalizedMonths[i] = months[i];
|
||||
}
|
||||
return normalizedMonths;
|
||||
}
|
||||
|
||||
throw new Exception("CalendarData.GetCalendarInfoNative() returned an unexpected number of month names.");
|
||||
}
|
||||
|
||||
private static string GetCalendarInfoNative(string localeName, CalendarId calendarId, CalendarDataType calendarDataType)
|
||||
{
|
||||
Debug.Assert(localeName != null);
|
||||
|
|
|
@ -28,6 +28,12 @@ namespace System.Globalization.Tests
|
|||
yield return new object[] { new string[] { "", "", "", "", "", "", "" } };
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> AbbreviatedDayNames_Get_TestData_ICU()
|
||||
{
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("en-US").DateTimeFormat, new string[] { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" } };
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("fr-FR").DateTimeFormat, new string[] { "dim.", "lun.", "mar.", "mer.", "jeu.", "ven.", "sam." } };
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> AbbreviatedDayNames_Get_TestData_HybridGlobalization()
|
||||
{
|
||||
// see the comments on the right to check the non-Hybrid result, if it differs
|
||||
|
@ -86,6 +92,13 @@ namespace System.Globalization.Tests
|
|||
yield return new object[] { "zh-CN", new string[] { "周日", "周一", "周二", "周三", "周四", "周五", "周六" } };
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalization))]
|
||||
[MemberData(nameof(AbbreviatedDayNames_Get_TestData_ICU))]
|
||||
public void AbbreviatedDayNames_Get_ReturnsExpected_ICU(DateTimeFormatInfo format, string[] expected)
|
||||
{
|
||||
Assert.Equal(expected, format.AbbreviatedDayNames);
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnBrowser))]
|
||||
[MemberData(nameof(AbbreviatedDayNames_Get_TestData_HybridGlobalization))]
|
||||
public void AbbreviatedDayNames_Get_ReturnsExpected_HybridGlobalization(string cultureName, string[] expected)
|
||||
|
|
|
@ -8,6 +8,11 @@ namespace System.Globalization.Tests
|
|||
{
|
||||
public class DateTimeFormatInfoAbbreviatedMonthGenitiveNames
|
||||
{
|
||||
public static IEnumerable<object[]> AbbreviatedMonthGenitiveNames_Get_TestData_ICU()
|
||||
{
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("en-US").DateTimeFormat, new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "" } };
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("fr-FR").DateTimeFormat, new string[] { "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc.", "" } };
|
||||
}
|
||||
public static IEnumerable<object[]> AbbreviatedMonthGenitiveNames_Get_TestData_HybridGlobalization()
|
||||
{
|
||||
// see the comments on the right to check the non-Hybrid result, if it differs
|
||||
|
@ -209,6 +214,13 @@ namespace System.Globalization.Tests
|
|||
yield return new object[] { "zh-TW", new string[] { "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月", "" } };
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalization))]
|
||||
[MemberData(nameof(AbbreviatedMonthGenitiveNames_Get_TestData_ICU))]
|
||||
public void AbbreviatedMonthGenitiveNames_Get_ReturnsExpected_ICU(DateTimeFormatInfo format, string[] expected)
|
||||
{
|
||||
Assert.Equal(expected, format.AbbreviatedMonthGenitiveNames);
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnBrowser))]
|
||||
[MemberData(nameof(AbbreviatedMonthGenitiveNames_Get_TestData_HybridGlobalization))]
|
||||
public void AbbreviatedMonthGenitiveNames_Get_ReturnsExpected_HybridGlobalization(string cultureName, string[] expected)
|
||||
|
|
|
@ -28,6 +28,13 @@ namespace System.Globalization.Tests
|
|||
yield return new object[] { new string[] { "", "", "", "", "", "", "", "", "", "", "", "", "" } };
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> AbbreviatedMonthNames_Get_TestData_ICU()
|
||||
{
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("en-US").DateTimeFormat, new string[] { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "" } };
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("fr-FR").DateTimeFormat, new string[] { "janv.", "févr.", "mars", "avr.", "mai", "juin", "juil.", "août", "sept.", "oct.", "nov.", "déc.", "" } };
|
||||
}
|
||||
|
||||
|
||||
public static IEnumerable<object[]> AbbreviatedMonthNames_Get_TestData_HybridGlobalization()
|
||||
{
|
||||
// see the comments on the right to check the non-Hybrid result, if it differs
|
||||
|
@ -232,6 +239,13 @@ namespace System.Globalization.Tests
|
|||
yield return new object[] { "zh-TW", new string[] { "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月", "" } };
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalization))]
|
||||
[MemberData(nameof(AbbreviatedMonthNames_Get_TestData_ICU))]
|
||||
public void AbbreviatedMonthNames_Get_ReturnsExpected_ICU(DateTimeFormatInfo format, string[] expected)
|
||||
{
|
||||
Assert.Equal(expected, format.AbbreviatedMonthNames);
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnBrowser))]
|
||||
[MemberData(nameof(AbbreviatedMonthNames_Get_TestData_HybridGlobalization))]
|
||||
public void AbbreviatedMonthNames_Get_ReturnsExpected_HybridGlobalization(string cultureName, string[] expected)
|
||||
|
|
|
@ -28,6 +28,12 @@ namespace System.Globalization.Tests
|
|||
yield return new object[] { new string[] { "", "", "", "", "", "", "" } };
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> DayNames_Get_TestData_ICU()
|
||||
{
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("en-US").DateTimeFormat, new string[] { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" } };
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("fr-FR").DateTimeFormat, new string[] { "dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi" } };
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> DayNames_Get_TestData_HybridGlobalization()
|
||||
{
|
||||
yield return new object[] { "ar-SA", new string[] { "الأحد", "الاثنين", "الثلاثاء", "الأربعاء", "الخميس", "الجمعة", "السبت" } };
|
||||
|
@ -78,6 +84,13 @@ namespace System.Globalization.Tests
|
|||
yield return new object[] { "zh-TW", new string[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" } };
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalization))]
|
||||
[MemberData(nameof(DayNames_Get_TestData_ICU))]
|
||||
public void DayNames_Get_ReturnsExpected_ICU(DateTimeFormatInfo format, string[] expected)
|
||||
{
|
||||
Assert.Equal(expected, format.DayNames);
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnBrowser))]
|
||||
[MemberData(nameof(DayNames_Get_TestData_HybridGlobalization))]
|
||||
public void DayNames_Get_ReturnsExpected_HybridGlobalization(string cultureName, string[] expected)
|
||||
|
|
|
@ -25,6 +25,12 @@ namespace System.Globalization.Tests
|
|||
yield return new object[] { "dddd, dd MMMM yyyy" };
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> LongDatePattern_Get_TestData_ICU()
|
||||
{
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("en-US").DateTimeFormat, "dddd, MMMM d, yyyy" };
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("fr-FR").DateTimeFormat, "dddd d MMMM yyyy" };
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> LongDatePattern_Get_TestData_HybridGlobalization()
|
||||
{
|
||||
// see the comments on the right to check the non-Hybrid result, if it differs
|
||||
|
@ -218,6 +224,13 @@ namespace System.Globalization.Tests
|
|||
yield return new object[] {"zh-TW", "yyyy年M月d日 dddd" };
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalization))]
|
||||
[MemberData(nameof(LongDatePattern_Get_TestData_ICU))]
|
||||
public void LongDatePattern_Get_ReturnsExpected_ICU(DateTimeFormatInfo format, string expected)
|
||||
{
|
||||
Assert.Equal(expected, format.LongDatePattern);
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnBrowser))]
|
||||
[MemberData(nameof(LongDatePattern_Get_TestData_HybridGlobalization))]
|
||||
public void LongDatePattern_Get_ReturnsExpected_HybridGlobalization(string cultureName, string expected)
|
||||
|
|
|
@ -26,6 +26,12 @@ namespace System.Globalization.Tests
|
|||
yield return new object[] { "m" };
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> MonthDayPattern_Get_TestData_ICU()
|
||||
{
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("en-US").DateTimeFormat, "MMMM d" };
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("fr-FR").DateTimeFormat, "d MMMM" };
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> MonthDayPattern_Get_TestData_HybridGlobalization()
|
||||
{
|
||||
// see the comments on the right to check the non-Hybrid result, if it differs
|
||||
|
@ -149,7 +155,6 @@ namespace System.Globalization.Tests
|
|||
yield return new object[] { new CultureInfo("en-ZA").DateTimeFormat, "d MMMM" };
|
||||
yield return new object[] { new CultureInfo("en-ZM").DateTimeFormat, "d MMMM" };
|
||||
yield return new object[] { new CultureInfo("en-ZW").DateTimeFormat, "d MMMM" };
|
||||
yield return new object[] { new CultureInfo("en-US").DateTimeFormat, "MMMM d" };
|
||||
yield return new object[] { new CultureInfo("es-419").DateTimeFormat, "d de MMMM" }; // d 'de' MMMM
|
||||
yield return new object[] { new CultureInfo("es-ES").DateTimeFormat, "d de MMMM" }; // d 'de' MMMM
|
||||
yield return new object[] { new CultureInfo("es-MX").DateTimeFormat, "d de MMMM" }; // d 'de' MMMM
|
||||
|
@ -216,6 +221,13 @@ namespace System.Globalization.Tests
|
|||
yield return new object[] { new CultureInfo("zh-HK").DateTimeFormat, "M月d日" };
|
||||
yield return new object[] { new CultureInfo("zh-TW").DateTimeFormat, "M月d日" };
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalization))]
|
||||
[MemberData(nameof(MonthDayPattern_Get_TestData_ICU))]
|
||||
public void MonthDayPattern_Get_ReturnsExpected_ICU(DateTimeFormatInfo format, string expected)
|
||||
{
|
||||
Assert.Equal(expected, format.MonthDayPattern);
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnBrowser))]
|
||||
[MemberData(nameof(MonthDayPattern_Get_TestData_HybridGlobalization))]
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace System.Globalization.Tests
|
|||
yield return new object[] { DateTimeFormatInfo.InvariantInfo, new string[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "" } };
|
||||
yield return new object[]
|
||||
{
|
||||
new CultureInfo("ru-RU").DateTimeFormat,
|
||||
CultureInfo.GetCultureInfo("ru-RU").DateTimeFormat,
|
||||
new string[]
|
||||
{
|
||||
"\u044F\u043D\u0432\u0430\u0440\u044F",
|
||||
|
@ -31,6 +31,11 @@ namespace System.Globalization.Tests
|
|||
""
|
||||
}
|
||||
};
|
||||
if (PlatformDetection.IsIcuGlobalization)
|
||||
{
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("en-US").DateTimeFormat, new string[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "" } };
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("fr-FR").DateTimeFormat, new string[] { "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre", "" } };
|
||||
}
|
||||
if (PlatformDetection.IsHybridGlobalizationOnBrowser)
|
||||
{
|
||||
// see the comments on the right to check the non-Hybrid result, if it differs
|
||||
|
|
|
@ -28,6 +28,12 @@ namespace System.Globalization.Tests
|
|||
yield return new object[] { new string[] { "", "", "", "", "", "", "", "", "", "", "", "", "" } };
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> MonthNames_Get_TestData_ICU()
|
||||
{
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("en-US").DateTimeFormat, new string[] { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", "" } };
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("fr-FR").DateTimeFormat, new string[] { "janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre", "" } };
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> MonthNames_Get_TestData_HybridGlobalization()
|
||||
{
|
||||
// see the comments on the right to check the non-Hybrid result, if it differs
|
||||
|
@ -227,6 +233,13 @@ namespace System.Globalization.Tests
|
|||
yield return new object[] { new CultureInfo("zh-TW").DateTimeFormat, new string[] { "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月", "" } };
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalization))]
|
||||
[MemberData(nameof(MonthNames_Get_TestData_ICU))]
|
||||
public void MonthNames_Get_ReturnsExpected_ICU(DateTimeFormatInfo format, string[] expected)
|
||||
{
|
||||
Assert.Equal(expected, format.MonthNames);
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnBrowser))]
|
||||
[MemberData(nameof(MonthNames_Get_TestData_HybridGlobalization))]
|
||||
public void MonthNames_Get_ReturnsExpected(DateTimeFormatInfo format, string[] expected)
|
||||
|
|
|
@ -8,12 +8,12 @@ namespace System.Globalization.Tests
|
|||
{
|
||||
public class DateTimeFormatInfoShortDatePattern
|
||||
{
|
||||
public static IEnumerable<object[]> ShortDatePattern_Get_TestData()
|
||||
public static IEnumerable<object[]> ShortDatePattern_Get_TestData_ICU()
|
||||
{
|
||||
yield return new object[] { DateTimeFormatInfo.InvariantInfo, "MM/dd/yyyy", "invariant" };
|
||||
yield return new object[] { new CultureInfo("en-US").DateTimeFormat, "M/d/yyyy", "en-US" };
|
||||
yield return new object[] { new CultureInfo("fr-FR").DateTimeFormat, "dd/MM/yyyy", "fr-FR" };
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("en-US").DateTimeFormat, "M/d/yyyy" };
|
||||
yield return new object[] { CultureInfo.GetCultureInfo("fr-FR").DateTimeFormat, "dd/MM/yyyy" };
|
||||
}
|
||||
|
||||
public static IEnumerable<object[]> ShortDatePattern_Get_TestData_HybridGlobalization()
|
||||
{
|
||||
// see the comments on the right to check the non-Hybrid result, if it differs
|
||||
|
@ -205,11 +205,11 @@ namespace System.Globalization.Tests
|
|||
yield return new object[] { "zh-TW", "yyyy/M/d" };
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnApplePlatform))]
|
||||
[MemberData(nameof(ShortDatePattern_Get_TestData))]
|
||||
public void ShortDatePattern_Get_ReturnsExpected(DateTimeFormatInfo format, string expected, string cultureName)
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsIcuGlobalization))]
|
||||
[MemberData(nameof(ShortDatePattern_Get_TestData_ICU))]
|
||||
public void ShortDatePattern_Get_ReturnsExpected_ICU(DateTimeFormatInfo format, string expected)
|
||||
{
|
||||
Assert.True(expected == format.ShortDatePattern, $"Failed for culture: {cultureName}. Expected: {expected}, Actual: {format.ShortDatePattern}");
|
||||
Assert.Equal(expected, format.ShortDatePattern);
|
||||
}
|
||||
|
||||
[ConditionalTheory(typeof(PlatformDetection), nameof(PlatformDetection.IsHybridGlobalizationOnBrowser))]
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>$(NetCoreAppCurrent)-ios;$(NetCoreAppCurrent)-tvos;$(NetCoreAppCurrent)-maccatalyst</TargetFrameworks>
|
||||
<TestRuntime>true</TestRuntime>
|
||||
<HybridGlobalization>true</HybridGlobalization>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<IncludeRemoteExecutor>true</IncludeRemoteExecutor>
|
||||
<UnicodeUcdVersion>15.0</UnicodeUcdVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<RdXmlFile Include="..\default.rd.xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\AssemblyInfo.cs" />
|
||||
<Compile Include="..\IcuTests.cs" />
|
||||
<Compile Include="..\DateTimeFormatInfo\DateTimeFormatInfoLongDatePattern.cs" />
|
||||
<Compile Include="..\DateTimeFormatInfo\DateTimeFormatInfoShortDatePattern.cs" />
|
||||
<Compile Include="..\DateTimeFormatInfo\DateTimeFormatInfoMonthDayPattern.cs" />
|
||||
<!-- Helpers -->
|
||||
<Compile Include="$(CommonTestPath)System\RandomDataGenerator.cs"
|
||||
Link="..\Common\System\RandomDataGenerator.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="System.Private.Runtime.UnicodeData" Version="$(SystemPrivateRuntimeUnicodeDataVersion)" ExcludeAssets="contentFiles" GeneratePathProperty="true" />
|
||||
<EmbeddedResource Include="$(PkgSystem_Private_Runtime_UnicodeData)\contentFiles\any\any\$(UnicodeUcdVersion).0\ucd\UnicodeData.txt">
|
||||
<Link>CharUnicodeInfo\UnicodeData.$(UnicodeUcdVersion).txt</Link>
|
||||
<LogicalName>UnicodeData.txt</LogicalName>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="$(PkgSystem_Private_Runtime_UnicodeData)\contentFiles\any\any\$(UnicodeUcdVersion).0\ucd\auxiliary\GraphemeBreakTest.txt">
|
||||
<Link>CharUnicodeInfo\GraphemeBreakTest-$(UnicodeUcdVersion).0.txt</Link>
|
||||
<LogicalName>GraphemeBreakTest.txt</LogicalName>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="$(CommonTestPath)TestUtilities.Unicode\TestUtilities.Unicode.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -130,7 +130,7 @@ const char* GlobalizationNative_GetCalendarInfoNative(const char* localeName, Ca
|
|||
NSString *longFormatString = [dateFormat dateFormat];
|
||||
[dateFormat setDateStyle:NSDateFormatterFullStyle];
|
||||
NSString *fullFormatString = [dateFormat dateFormat];
|
||||
result = @[longFormatString, fullFormatString];
|
||||
result = @[fullFormatString, longFormatString];
|
||||
break;
|
||||
}
|
||||
case CalendarData_DayNames:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue