Skip to content
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

Some unit tests fail when run on a Windows machine set to a culture that doesn't use dot as the decimal separator #2193

Open
monoman opened this issue May 16, 2023 · 1 comment

Comments

@monoman
Copy link

monoman commented May 16, 2023

Those tests (in command-line-api\src\System.CommandLine.Tests\Binding\TypeConversionTests.cs) fail as is assumed that dot ('.') is always the decimal separator what is not true for pt-BR, or perhaps the parsing should use invariant culture to standardize the decimal separator

       [Fact]
        public void Values_can_be_correctly_converted_to_decimal_without_the_parser_specifying_a_custom_converter()
            => GetValue(new CliOption<decimal>("-x"), "-x 123.456").Should().Be(123.456m);

        [Fact]
        public void Values_can_be_correctly_converted_to_nullable_decimal_without_the_parser_specifying_a_custom_converter()
            => GetValue(new CliOption<decimal?>("-x"), "-x 123.456").Should().Be(123.456m);

        [Fact]
        public void Values_can_be_correctly_converted_to_double_without_the_parser_specifying_a_custom_converter()
            => GetValue(new CliOption<double>("-x"), "-x 123.456").Should().Be(123.456d);

        [Fact]
        public void Values_can_be_correctly_converted_to_nullable_double_without_the_parser_specifying_a_custom_converter()
            => GetValue(new CliOption<double?>("-x"), "-x 123.456").Should().Be(123.456d);

        [Fact]
        public void Values_can_be_correctly_converted_to_float_without_the_parser_specifying_a_custom_converter()
            => GetValue(new CliOption<float>("-x"), "-x 123.456").Should().Be(123.456f);

@KalleOlaviNiemitalo
Copy link

Pretty much a duplicate of #1799. Also related to #1733 and #951.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants