diff --git a/src/libraries/System.Globalization/tests/System/Globalization/CharUnicodeInfoTestData.cs b/src/libraries/System.Globalization/tests/System/Globalization/CharUnicodeInfoTestData.cs index a9b4ec0989649..e61b46506a8d6 100644 --- a/src/libraries/System.Globalization/tests/System/Globalization/CharUnicodeInfoTestData.cs +++ b/src/libraries/System.Globalization/tests/System/Globalization/CharUnicodeInfoTestData.cs @@ -44,9 +44,11 @@ private static void Parse(List testCases, string line) string charName = data[1]; string charCategoryString = data[2]; string numericValueString = data[8]; + StrongBidiCategory bidiCategory = data[4] == "L" ? StrongBidiCategory.StrongLeftToRight : + data[4] == "R" || data[4] == "AL" ? StrongBidiCategory.StrongRightToLeft : StrongBidiCategory.Other; int codePoint = int.Parse(charValueString, NumberStyles.HexNumber); - Parse(testCases, codePoint, charCategoryString, numericValueString); + Parse(testCases, codePoint, charCategoryString, numericValueString, bidiCategory); if (charName.EndsWith("First>")) { @@ -59,7 +61,7 @@ private static void Parse(List testCases, string line) { // Assumes that all code points in the range have the same numeric value // and general category - Parse(testCases, rangeCodePoint, charCategoryString, numericValueString); + Parse(testCases, rangeCodePoint, charCategoryString, numericValueString, bidiCategory); } } } @@ -99,7 +101,7 @@ private static void Parse(List testCases, string line) ["Lu"] = UnicodeCategory.UppercaseLetter }; - private static void Parse(List testCases, int codePoint, string charCategoryString, string numericValueString) + private static void Parse(List testCases, int codePoint, string charCategoryString, string numericValueString, StrongBidiCategory bidiCategory) { string codeValueRepresentation = codePoint > char.MaxValue ? char.ConvertFromUtf32(codePoint) : ((char)codePoint).ToString(); double numericValue = ParseNumericValueString(numericValueString); @@ -110,7 +112,8 @@ private static void Parse(List testCases, int codePoint Utf32CodeValue = codeValueRepresentation, GeneralCategory = generalCategory, NumericValue = numericValue, - CodePoint = codePoint + CodePoint = codePoint, + BidiCategory = bidiCategory }); } @@ -141,11 +144,19 @@ private static double ParseNumericValueString(string numericValueString) } } + public enum StrongBidiCategory + { + Other = 0x00, + StrongLeftToRight = 0x20, + StrongRightToLeft = 0x40, + } + public class CharUnicodeInfoTestCase { public string Utf32CodeValue { get; set; } public int CodePoint { get; set; } public UnicodeCategory GeneralCategory { get; set; } public double NumericValue { get; set; } + public StrongBidiCategory BidiCategory { get; set; } } } diff --git a/src/libraries/System.Globalization/tests/System/Globalization/CharUnicodeInfoTests.cs b/src/libraries/System.Globalization/tests/System/Globalization/CharUnicodeInfoTests.cs index 9ea884f780226..1ec1a36f811aa 100644 --- a/src/libraries/System.Globalization/tests/System/Globalization/CharUnicodeInfoTests.cs +++ b/src/libraries/System.Globalization/tests/System/Globalization/CharUnicodeInfoTests.cs @@ -2,6 +2,7 @@ // The .NET Foundation licenses this file to you under the MIT license. using Xunit; +using System.Reflection; namespace System.Globalization.Tests { @@ -12,6 +13,9 @@ public partial class CharUnicodeInfoTests [Fact] public void GetUnicodeCategory() { + MethodInfo GetBidiCategory = Type.GetType("System.Globalization.CharUnicodeInfo").GetMethod("GetBidiCategoryNoBoundsChecks", BindingFlags.NonPublic | BindingFlags.Static | BindingFlags.Instance | BindingFlags.InvokeMethod); + object [] parameters = new object [] { 0 }; + foreach (CharUnicodeInfoTestCase testCase in CharUnicodeInfoTestData.TestCases) { if (testCase.Utf32CodeValue.Length == 1) @@ -22,6 +26,9 @@ public void GetUnicodeCategory() // Test the string overload for a surrogate pair or a single char GetUnicodeCategoryTest_String(testCase.Utf32CodeValue, new UnicodeCategory[] { testCase.GeneralCategory }); Assert.Equal(testCase.GeneralCategory, CharUnicodeInfo.GetUnicodeCategory(testCase.CodePoint)); + + parameters[0] = (uint)testCase.CodePoint; + Assert.Equal(testCase.BidiCategory, (StrongBidiCategory)GetBidiCategory.Invoke(null, parameters)); } } diff --git a/src/libraries/System.Private.CoreLib/src/System/Globalization/StrongBidiCategory.cs b/src/libraries/System.Private.CoreLib/src/System/Globalization/StrongBidiCategory.cs index b9f04470c9414..b1da801c73113 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Globalization/StrongBidiCategory.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Globalization/StrongBidiCategory.cs @@ -10,7 +10,7 @@ namespace System.Globalization internal enum StrongBidiCategory { Other = 0x00, - StrongLeftToRight = 0x10, - StrongRightToLeft = 0x20, + StrongLeftToRight = 0x20, + StrongRightToLeft = 0x40, } }