StartsWith more edge cases (dotnet/corefx#41350)
authorAdam Sitnik <adam.sitnik@gmail.com>
Thu, 26 Sep 2019 13:40:44 +0000 (15:40 +0200)
committerStephen Toub <stoub@microsoft.com>
Thu, 26 Sep 2019 13:40:44 +0000 (06:40 -0700)
* add test case for ICU-20832

* add ""o\u0000\u0308".StartsWith("o") test case

Commit migrated from https://github.com/dotnet/corefx/commit/933f5ddb717307ea75c939058c23c16e3849176e

src/libraries/System.Globalization/tests/CompareInfo/CompareInfoTests.IsPrefix.cs

index 117bc6c..b886e8c 100644 (file)
@@ -54,6 +54,7 @@ namespace System.Globalization.Tests
             yield return new object[] { s_invariantCompare, "FooBA\u0300R", "FooB\u00C0R", CompareOptions.IgnoreNonSpace, true };
             yield return new object[] { s_invariantCompare, "o\u0308", "o", CompareOptions.None, false };
             yield return new object[] { s_invariantCompare, "o\u0308", "o", CompareOptions.Ordinal, true };
+            yield return new object[] { s_invariantCompare, "o\u0000\u0308", "o", CompareOptions.None, true };
 
             // Surrogates
             yield return new object[] { s_invariantCompare, "\uD800\uDC00", "\uD800\uDC00", CompareOptions.None, true };
@@ -75,6 +76,13 @@ namespace System.Globalization.Tests
             yield return new object[] { s_frenchCompare, "\u0153", "oe", CompareOptions.None, PlatformDetection.IsWindows ? true : false };
             yield return new object[] { s_invariantCompare, "\uD800\uDC00", "\uD800", CompareOptions.None, PlatformDetection.IsWindows ? true : false };
             yield return new object[] { s_invariantCompare, "\uD800\uDC00", "\uD800", CompareOptions.IgnoreCase, PlatformDetection.IsWindows ? true : false };
+
+            // ICU bugs
+            // UInt16 overflow: https://unicode-org.atlassian.net/browse/ICU-20832 fixed in https://github.com/unicode-org/icu/pull/840 (ICU 65)
+            if (PlatformDetection.IsWindows || PlatformDetection.ICUVersion.Major >= 65)
+            {
+                yield return new object[] { s_frenchCompare, "b", new string('a', UInt16.MaxValue + 1), CompareOptions.None, false };
+            }
         }
 
         [Theory]