Skip to content

NumericFormatter should be able to format double correctly. expected:<111[.]000000> but was:<111[,]000000> #337

Closed

Description

Tests run: 8, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.139 sec <<< FAILURE!
testToString(com.microsoft.java.debug.core.adapter.formatter.NumericFormatterTest)  Time elapsed: 0.01 sec  <<< FAILURE!
org.junit.ComparisonFailure: NumericFormatter should be able to format double correctly. expected:<111[.]000000> but was:<111[,]000000>
        at org.junit.Assert.assertEquals(Assert.java:115)
        at com.microsoft.java.debug.core.adapter.formatter.NumericFormatterTest.testToString(NumericFormatterTest.java:87)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
        at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
        at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
        at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
        at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
        at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
        at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
        at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
        at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
        at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)

Probably having something to do with my system not being en_US

Activity

  1. Urfoex commented on Jun 24, 2020

    @Urfoex
    Author

    $ LANG=C ./mvnw clean install
    Lets it run through without that problem.

  2. testforstephen commented on Jun 28, 2020

    @testforstephen
    Contributor

    The encoding is supposed to be UTF-8.

    Cannot reproduce it, i have no idea what's wrong in your environment. Could you debug it to see which part of code the error comes from?

  3. dodonut commented on Nov 23, 2021

    @dodonut

    I was having the same issue. I'm from Brazil, and we format the decimal places with a comma. Maybe the project is getting some locale options by default, idk (I'm not an experienced in java). Anyway, I could not find any option to set the locale inside the project, so I changed the test to a comma instead of the dot as the image shows, and it builded fine.
    image

  4. Asdas91 commented on Dec 12, 2021

    @Asdas91

    It's a locale issue. NumericFormatter is formatting double using the machines locale but the test expects the format to be in en_US locale. The problem appears on most European machines.
    So either the actual code is is wrong and should not take locale into account or the test is wrong. Either way there's a bug.

  5. lobophf commented on May 9, 2022

    @lobophf

    I was having the same issue. I'm from Brazil, and we format the decimal places with a comma. Maybe the project is getting some locale options by default, idk (I'm not an experienced in java). Anyway, I could not find any option to set the locale inside the project, so I changed the test to a comma instead of the dot as the image shows, and it builded fine. image

    I'm from Brazil too and had the same problem. To solve it, I put the iGnOrE (@ignore) annotation above the test testToString().

  6. siqueira-gustavo commented on Jul 22, 2022

    @siqueira-gustavo

    I was having the same issue. I'm from Brazil, and we format the decimal places with a comma. Maybe the project is getting some locale options by default, idk (I'm not an experienced in java). Anyway, I could not find any option to set the locale inside the project, so I changed the test to a comma instead of the dot as the image shows, and it builded fine. image

    I'm from Brazil too and had the same problem. To solve it, I put the iGnOrE (@ignore) annotation above the test testToString().

    Hi. Not sure if you had sucess with this, but here's what I did. I'm from Brazil too.
    First thing you will need to jump to NumericFormatterTest.java file which is in package com.microsoft.java.debug.core.adapter.formatter;
    Then you will simply set the default locale to US.

    Add this line in the setup() method:
    Locale.setDefault(Locale.US);

    Don't forget to import it from java.util
    import java.util.Locale;

    I had this problem while I was trying to setup Neovim to work with java projects. This made it work for me. Hope this helps you too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions