java-progressbar icon indicating copy to clipboard operation
java-progressbar copied to clipboard

testPercentageReplacer fails

Open oliverskawronek opened this issue 7 years ago • 2 comments

The PercentageReplacer executes

return String.format("%6.2f", progress.getPercentage() * 100);

I'am using german locale on my machine, and in german we use a comma instead of a point as decimal separator (unfortunately this is a common issue). The test against " 0.00" (with dot) fails due to the actual string is " 0,00" (with comma).

You can fix this by passing a explicit locale that is using a dot as decimal separator:

return String.format(Locale.US, "%6.2f", progress.getPercentage() * 100);

For more details please have a look on SO: https://stackoverflow.com/questions/5236056/force-point-as-decimal-separator-in-java

oliverskawronek avatar May 17 '18 13:05 oliverskawronek

Great catch, thanks for reporting

raszi avatar May 26 '18 22:05 raszi

Probably it would be better to fix the test instead of hardcoding the locale in the codebase. What do you think?

raszi avatar Feb 04 '21 23:02 raszi