Repository: dotnet/runtime
File: src/libraries/System.Runtime.Numerics/tests/BigInteger/parse.cs (C#)

Code before:
                number.Reverse();
                actual = new string(number.ToArray());
            }
            Assert.Equal(expected, actual);
        }

        [Fact]
        public static void ParseUkrainianCultureWithTrailingSpaces()
        {
            using (new ThreadCultureChange(new CultureInfo("uk-UA")))
            {
                // Test string parsing with trailing spaces
                // Ukrainian culture may use NBSP (0xA0) as NumberGroupSeparator
                // When AllowTrailingWhite is set, trailing spaces should be accepted
                string testNumber = "123 ";

                // String parsing (char/UTF-16) should work
                BigInteger result = BigInteger.Parse(testNumber, NumberStyles.AllowTrailingWhite);
                Assert.Equal(BigInteger.Parse("123"), result);
            }
        }

        [Fact]
        public static void ParseUkrainianCultureWithSpaceAsGroupSeparator()
        {
            using (new ThreadCultureChange(new CultureInfo("uk-UA")))
            {
                // This test validates the bidirectional space equivalence fix
                // If Ukrainian culture uses NBSP as NumberGroupSeparator, parsing
                // with regular spaces should work due to the equivalence logic

                // Only test if Ukrainian culture actually uses NBSP as separator
                if (CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator == "\u00A0")
                {
                    // Test with regular space - should work due to space equivalence
                    string testWithSpace = "1234567";  // Simple number without separators
                    BigInteger result = BigInteger.Parse(testWithSpace, NumberStyles.AllowThousands);
                    Assert.Equal(BigInteger.Parse("1234567"), result);
                }
            }
        }
    }

    [Collection(nameof(DisableParallelization))]
    public class parseTestThreshold
    {
        public static IEnumerable<object[]> Cultures => parseTest.Cultures;

        [Theory]
        [MemberData(nameof(Cultures))]
        [OuterLoop]

Review comment (suggestion):
@copilot you can improve the test by not using `uk-UA` at all. Instead, do something like:

CultureInfo ci = new CultureInfo("en-US");
ci.NumberFormat.NumberGroupSeparator = "\u00A0";

Then pass ci as IFormatProvider to the BigInteger.Parse

Code after:
                number.Reverse();
                actual = new string(number.ToArray());
            }
            Assert.Equal(expected, actual);
        }

        [Fact]
        public static void ParseWithNBSPAsGroupSeparator()
        {
            // Culture has NBSP as group separator; input has regular spaces.
            // Exercises MatchChars path: cp=='\u0020' && IsSpaceReplacingChar(val=='\u00A0')
            CultureInfo nbspCulture = new CultureInfo("en-US");
            nbspCulture.NumberFormat.NumberGroupSeparator = "\u00A0";

            BigInteger result = BigInteger.Parse("1 234 567", NumberStyles.AllowThousands, nbspCulture);
            Assert.Equal((BigInteger)1234567, result);

            // Culture has regular space as group separator; input has NBSP.
            // Exercises MatchChars path: val=='\u0020' && IsSpaceReplacingChar(cp=='\u00A0')
            CultureInfo spaceCulture = new CultureInfo("en-US");
            spaceCulture.NumberFormat.NumberGroupSeparator = " ";

            result = BigInteger.Parse("1\u00A0234\u00A0567", NumberStyles.AllowThousands, spaceCulture);
            Assert.Equal((BigInteger)1234567, result);

            // Culture has regular space as group separator; input has narrow NBSP (U+202F).
            // Exercises IsSpaceReplacingChar matching U+202F against U+0020
            result = BigInteger.Parse("1\u202F234\u202F567", NumberStyles.AllowThousands, spaceCulture);
            Assert.Equal((BigInteger)1234567, result);
        }
    }

    [Collection(nameof(DisableParallelization))]
    public class parseTestThreshold
    {
        public static IEnumerable<object[]> Cultures => parseTest.Cultures;

        [Theory]
        [MemberData(nameof(Cultures))]
        [OuterLoop]
        public static void RunParseToStringTests(CultureInfo culture)
        {
            BigIntTools.Utils.RunWithFakeThreshold(Number.BigIntegerParseNaiveThreshold, 0, () =>
            BigIntTools.Utils.RunWithFakeThreshold(Number.BigIntegerParseNaiveThresholdInRecursive, 10, () =>
            {
                parseTest.RunParseToStringTests(culture);
            }));
        }

        public static IEnumerable<object[]> Parse_Subspan_Success_TestData() => parseTest.Parse_Subspan_Success_TestData();