-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS][non-icu] HybridGlobalization support IgnoreKanaType #96002
Changes from 5 commits
8256d1c
7eba54f
8a770e3
2a7baa6
67229f6
4995e3f
33bc383
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,28 +45,24 @@ public static IEnumerable<object[]> Compare_TestData() | |
CompareOptions validIgnoreKanaTypeOption = PlatformDetection.IsHybridGlobalizationOnBrowser ? | ||
CompareOptions.IgnoreKanaType | CompareOptions.IgnoreCase : | ||
CompareOptions.IgnoreKanaType; | ||
// In HybridGlobalization, IgnoreKanaType is not supported on OSX | ||
if (!PlatformDetection.IsHybridGlobalizationOnOSX) | ||
yield return new object[] { s_invariantCompare, "\u3042", "\u30A2", validIgnoreKanaTypeOption, 0 }; | ||
yield return new object[] { s_invariantCompare, "\u304D\u3083", "\u30AD\u30E3", validIgnoreKanaTypeOption, 0 }; | ||
yield return new object[] { s_invariantCompare, "\u304D\u3083", "\u30AD\u3083", validIgnoreKanaTypeOption, 0 }; | ||
yield return new object[] { s_invariantCompare, "\u304D \u3083", "\u30AD\u3083", validIgnoreKanaTypeOption, -1 }; | ||
yield return new object[] { s_invariantCompare, "\u3044", "I", validIgnoreKanaTypeOption, 1 }; | ||
yield return new object[] { s_invariantCompare, "\u3070\u3073\u3076\u3079\u307C", "\u30D0\u30D3\u30D6\u30D9\u30DC", validIgnoreKanaTypeOption, 0 }; | ||
yield return new object[] { s_invariantCompare, "\u3070\u3073\u3076\u3079\u307C", "\u30D0\u30D3\u3076\u30D9\u30DC", validIgnoreKanaTypeOption, 0 }; | ||
yield return new object[] { s_invariantCompare, "\u3060", "\u305F", validIgnoreKanaTypeOption, 1 }; | ||
yield return new object[] { s_invariantCompare, "\u3060", "\u30C0", validIgnoreKanaTypeOption, 0 }; | ||
yield return new object[] { s_invariantCompare, "\u68EE\u9D0E\u5916", "\u68EE\u9DD7\u5916", validIgnoreKanaTypeOption, -1 }; | ||
yield return new object[] { s_invariantCompare, "\u2019", "'", validIgnoreKanaTypeOption, 1 }; | ||
yield return new object[] { s_invariantCompare, "", "'", validIgnoreKanaTypeOption, -1 }; | ||
yield return new object[] { s_invariantCompare, "\u30FC", "\uFF70", CompareOptions.IgnoreKanaType | CompareOptions.IgnoreCase, 0 }; | ||
// PlatformDetection.IsHybridGlobalizationOnBrowser does not support IgnoreWidth | ||
if (!PlatformDetection.IsHybridGlobalizationOnBrowser) | ||
{ | ||
yield return new object[] { s_invariantCompare, "\u3042", "\u30A2", validIgnoreKanaTypeOption, 0 }; | ||
yield return new object[] { s_invariantCompare, "\u304D\u3083", "\u30AD\u30E3", validIgnoreKanaTypeOption, 0 }; | ||
yield return new object[] { s_invariantCompare, "\u304D\u3083", "\u30AD\u3083", validIgnoreKanaTypeOption, 0 }; | ||
yield return new object[] { s_invariantCompare, "\u304D \u3083", "\u30AD\u3083", validIgnoreKanaTypeOption, -1 }; | ||
yield return new object[] { s_invariantCompare, "\u3044", "I", validIgnoreKanaTypeOption, 1 }; | ||
yield return new object[] { s_invariantCompare, "\u3070\u3073\u3076\u3079\u307C", "\u30D0\u30D3\u30D6\u30D9\u30DC", validIgnoreKanaTypeOption, 0 }; | ||
yield return new object[] { s_invariantCompare, "\u3070\u3073\u3076\u3079\u307C", "\u30D0\u30D3\u3076\u30D9\u30DC", validIgnoreKanaTypeOption, 0 }; | ||
yield return new object[] { s_invariantCompare, "\u3060", "\u305F", validIgnoreKanaTypeOption, 1 }; | ||
yield return new object[] { s_invariantCompare, "\u3060", "\u30C0", validIgnoreKanaTypeOption, 0 }; | ||
yield return new object[] { s_invariantCompare, "\u68EE\u9D0E\u5916", "\u68EE\u9DD7\u5916", validIgnoreKanaTypeOption, -1 }; | ||
yield return new object[] { s_invariantCompare, "\u2019", "'", validIgnoreKanaTypeOption, 1 }; | ||
yield return new object[] { s_invariantCompare, "", "'", validIgnoreKanaTypeOption, -1 }; | ||
yield return new object[] { s_invariantCompare, "\u30FC", "\uFF70", CompareOptions.IgnoreKanaType | CompareOptions.IgnoreCase, 0 }; | ||
// PlatformDetection.IsHybridGlobalizationOnBrowser does not support IgnoreWidth | ||
if (!PlatformDetection.IsHybridGlobalizationOnBrowser) | ||
{ | ||
yield return new object[] { s_invariantCompare, "\u3042", "\uFF71", CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase, 0 }; | ||
yield return new object[] { s_invariantCompare, "'\u3000'", "' '", CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase, 0 }; | ||
} | ||
yield return new object[] { s_invariantCompare, "\u3042", "\uFF71", CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase, 0 }; | ||
yield return new object[] { s_invariantCompare, "'\u3000'", "' '", CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase, PlatformDetection.IsHybridGlobalizationOnOSX ? 1 : 0 }; | ||
} | ||
|
||
yield return new object[] { s_invariantCompare, "\u6FA4", "\u6CA2", CompareOptions.None, 1 }; | ||
|
@@ -264,12 +260,8 @@ public static IEnumerable<object[]> Compare_TestData() | |
// in HybridGlobalization on Browser IgnoreKanaType is supported only for "ja" | ||
var kanaComparison = PlatformDetection.IsHybridGlobalizationOnBrowser ? s_japaneseCompare : s_invariantCompare; | ||
|
||
// In HybridGlobalization mode on OSX IgnoreKanaType is not supported | ||
if (!PlatformDetection.IsHybridGlobalizationOnOSX) | ||
{ | ||
yield return new object[] { kanaComparison, "\u3060", "\u30C0", CompareOptions.IgnoreKanaType, 0 }; | ||
yield return new object[] { kanaComparison, "c", "C", CompareOptions.IgnoreKanaType, -1 }; | ||
} | ||
yield return new object[] { kanaComparison, "\u3060", "\u30C0", CompareOptions.IgnoreKanaType, 0 }; | ||
yield return new object[] { kanaComparison, "c", "C", CompareOptions.IgnoreKanaType, -1 }; | ||
|
||
yield return new object[] { s_invariantCompare, "\u3060", "\u30C0", CompareOptions.IgnoreCase, PlatformDetection.IsHybridGlobalizationOnOSX ? 1 : s_expectedHiraganaToKatakanaCompare }; | ||
|
||
|
@@ -293,15 +285,12 @@ public static IEnumerable<object[]> Compare_TestData() | |
// Misc differences between platforms | ||
bool useNls = PlatformDetection.IsNlsGlobalization; | ||
|
||
if (!PlatformDetection.IsHybridGlobalizationOnOSX) | ||
{ | ||
var japaneseCmp = PlatformDetection.IsHybridGlobalizationOnBrowser ? | ||
CompareOptions.IgnoreKanaType | CompareOptions.IgnoreCase : | ||
CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase; | ||
var japaneseCmp = PlatformDetection.IsHybridGlobalizationOnBrowser ? | ||
CompareOptions.IgnoreKanaType | CompareOptions.IgnoreCase : | ||
CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase; | ||
|
||
yield return new object[] { s_invariantCompare, "\u3042", "\u30A1", japaneseCmp, useNls ? 1: 0 }; | ||
yield return new object[] { s_invariantCompare, "'\u3000'", "''", japaneseCmp, useNls ? 1 : -1 }; | ||
} | ||
yield return new object[] { s_invariantCompare, "\u3042", "\u30A1", japaneseCmp, useNls || PlatformDetection.IsHybridGlobalizationOnOSX ? 1: 0 }; | ||
yield return new object[] { s_invariantCompare, "'\u3000'", "''", japaneseCmp, useNls ? 1 : -1 }; | ||
|
||
yield return new object[] { s_invariantCompare, "\u30BF", "\uFF80", CompareOptions.None, useNls ? 1 : -1 }; | ||
yield return new object[] { s_invariantCompare, "'\u3000'", "''", CompareOptions.None, useNls ? 1 : -1 }; | ||
|
@@ -339,7 +328,6 @@ public void CompareWithUnassignedChars() | |
} | ||
|
||
[ConditionalTheory(nameof(IsNotWindowsKanaRegressedVersion))] | ||
[SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS | TestPlatforms.OSX, "Not supported on Browser, iOS, MacCatalyst, or tvOS.")] | ||
[MemberData(nameof(Compare_Kana_TestData))] | ||
public void CompareWithKana(CompareInfo compareInfo, string string1, string string2, CompareOptions options, int expected) | ||
{ | ||
|
@@ -525,7 +513,6 @@ public void Compare_Invalid() | |
} | ||
|
||
[Fact] | ||
[SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS | TestPlatforms.OSX, "Not supported on Browser, iOS, MacCatalyst, or tvOS.")] | ||
public void TestIgnoreKanaAndWidthCases() | ||
{ | ||
for (char c = '\uFF41'; c <= '\uFF5A'; c++) | ||
|
@@ -536,15 +523,15 @@ public void TestIgnoreKanaAndWidthCases() | |
|
||
// Edge case of the Ignore Width. | ||
Assert.False(string.Compare("\u3162\u3163", "\uFFDB\uFFDC", CultureInfo.InvariantCulture, CompareOptions.None) == 0, $"Expect '0x3162 0x3163' != '0xFFDB 0xFFDC'"); | ||
if (!PlatformDetection.IsHybridGlobalizationOnBrowser) | ||
if (!PlatformDetection.IsHybridGlobalizationOnBrowser && !PlatformDetection.IsHybridGlobalizationOnOSX) | ||
Assert.True(string.Compare("\u3162\u3163", "\uFFDB\uFFDC", CultureInfo.InvariantCulture, CompareOptions.IgnoreWidth) == 0, "Expect '0x3162 0x3163' == '0xFFDB 0xFFDC'"); | ||
|
||
const char hiraganaStart = '\u3041'; | ||
const char hiraganaEnd = '\u3096'; | ||
const int hiraganaToKatakanaOffset = 0x30a1 - 0x3041; | ||
|
||
// in HybridGlobalization on Browser IgnoreKanaType is supported only for "ja-JP" | ||
CultureInfo ignoreKanaTypeTestedCulture = PlatformDetection.IsHybridGlobalizationOnBrowser ? new CultureInfo("ja-JP") : CultureInfo.InvariantCulture; | ||
CultureInfo ignoreKanaTypeTestedCulture = PlatformDetection.IsHybridGlobalization ? new CultureInfo("ja-JP") : CultureInfo.InvariantCulture; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. is this change required? according to the comment we only need to use ja-JP on browser There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is, as this test case fails when using |
||
|
||
for (Char hiraganaChar = hiraganaStart; hiraganaChar <= hiraganaEnd; hiraganaChar++) | ||
{ | ||
|
@@ -572,6 +559,24 @@ public static IEnumerable<object[]> Compare_HiraganaAndKatakana_TestData() | |
CompareOptions.IgnoreKanaType | CompareOptions.IgnoreSymbols | CompareOptions.IgnoreNonSpace | CompareOptions.IgnoreCase, | ||
CompareOptions.Ordinal, | ||
CompareOptions.OrdinalIgnoreCase, | ||
} : PlatformDetection.IsHybridGlobalizationOnOSX ? | ||
new[] { | ||
CompareOptions.None, | ||
CompareOptions.IgnoreCase, | ||
CompareOptions.IgnoreNonSpace, | ||
CompareOptions.IgnoreKanaType, | ||
CompareOptions.IgnoreWidth, | ||
CompareOptions.Ordinal, | ||
CompareOptions.OrdinalIgnoreCase, | ||
CompareOptions.IgnoreKanaType | CompareOptions.IgnoreCase, | ||
CompareOptions.IgnoreKanaType | CompareOptions.IgnoreNonSpace, | ||
CompareOptions.IgnoreKanaType | CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace, | ||
CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase, | ||
CompareOptions.IgnoreWidth | CompareOptions.IgnoreNonSpace, | ||
CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace, | ||
CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase, | ||
CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreNonSpace, | ||
CompareOptions.IgnoreKanaType | CompareOptions.IgnoreWidth | CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace, | ||
} : | ||
new[] { | ||
CompareOptions.None, | ||
|
@@ -621,7 +626,6 @@ public static IEnumerable<object[]> Compare_HiraganaAndKatakana_TestData() | |
} | ||
|
||
[Theory] | ||
[SkipOnPlatform(TestPlatforms.iOS | TestPlatforms.MacCatalyst | TestPlatforms.tvOS | TestPlatforms.OSX, "Not supported on Browser, iOS, MacCatalyst, or tvOS.")] | ||
[MemberData(nameof(Compare_HiraganaAndKatakana_TestData))] | ||
public void TestHiraganaAndKatakana(CompareOptions[] optionsPositive, CompareOptions[] optionsNegative) | ||
{ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could probably simplify this if to
IsHybridGlobalization
right?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, thanks.