"($#)", "-$#", "$-#", "$#-",
"(#$)", "-#$", "#-$", "#$-",
"-# $", "-$ #", "# $-", "$ #-",
- "$ -#", "#- $", "($ #)", "(# $)"
+ "$ -#", "#- $", "($ #)", "(# $)",
+ "$- #"
};
private static readonly string[] s_posPercentFormats =
#define UCHAR_PERCENT ((UChar)0x0025) // '%'
#define UCHAR_OPENPAREN ((UChar)0x0028) // '('
#define UCHAR_CLOSEPAREN ((UChar)0x0029) // ')'
+#define UCHAR_ZERO ((UChar)0x0030) // '0'
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
switch (ch)
{
case UCHAR_DIGIT:
+ case UCHAR_ZERO:
if (!digitAdded)
{
digitAdded = TRUE;
spaceAdded = TRUE;
destPattern[index++] = ' ';
}
- else
- {
- assert(FALSE);
- }
break;
case UCHAR_MINUS:
}
}
- // TODO: https://github.com/dotnet/runtime/issues/946
- // assert(FALSE); // should have found a valid pattern
+ assert(FALSE); // should have found a valid pattern
free(normalizedPattern);
return INVALID_FORMAT;
"C -n",
"n- C",
"(C n)",
- "(n C)"};
+ "(n C)",
+ "C- n" };
UErrorCode status = U_ZERO_ERROR;
UNumberFormat* pFormat = unum_open(UNUM_CURRENCY, NULL, 0, locale, NULL, &status);
Assert.Equal(newDigits, nfi.NativeDigits);
}
+ [Fact]
+ public void TestNFIFormatLimits()
+ {
+ foreach (CultureInfo ci in CultureInfo.GetCultures(CultureTypes.AllCultures))
+ {
+ NumberFormatInfo nfi = ci.NumberFormat;
+ Assert.InRange(nfi.CurrencyNegativePattern, 0, 16);
+ Assert.InRange(nfi.CurrencyPositivePattern, 0, 3);
+ Assert.InRange(nfi.PercentNegativePattern, 0, 11);
+ Assert.InRange(nfi.PercentPositivePattern, 0, 3);
+ Assert.InRange(nfi.NumberNegativePattern, 0, 4);
+ }
+ }
+
[Theory]
[MemberData(nameof(DigitSubstitution_TestData))]
public void DigitSubstitutionListTest(string cultureName, DigitShapes shape)
"($#)", "-$#", "$-#", "$#-",
"(#$)", "-#$", "#-$", "#$-",
"-# $", "-$ #", "# $-", "$ #-",
- "$ -#", "#- $", "($ #)", "(# $)"
+ "$ -#", "#- $", "($ #)", "(# $)",
+ "$- #"
};
private static readonly string[] s_posPercentFormats =
{
if (groupDigits != null)
{
- Debug.Assert(sGroup != null, "Must be nulll when groupDigits != null");
+ Debug.Assert(sGroup != null, "Must be null when groupDigits != null");
int groupSizeIndex = 0; // Index into the groupDigits array.
int bufferSize = digPos; // The length of the result buffer string.
int groupSize = 0; // The current group size.