You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RowTest testSimple fails on my Windows PC because it tries to compare "5,0" (comma) from row.toString() and "5.0" (dot) here:
assertTrue(row.toString().contains("5.0"));
testSimple(edu.stanford.futuredata.macrobase.datamodel.RowTest) Time elapsed: 0.001 sec <<< FAILURE!
java.lang.AssertionError
at org.junit.Assert.fail(Assert.java:86)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.junit.Assert.assertTrue(Assert.java:52)
at edu.stanford.futuredata.macrobase.datamodel.RowTest.testSimple(RowTest.java:16)
............
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
It happens because Row uses DecimalFormat("#.0#####") to convert doubles to string, which uses the current locale. (By the way, seems like it just takes default format for locale ignoring additional Windows format settings: I have ru-RU locale on this PC but decimal separator is specified as dot in additional settings)
So I think either DecimalFormat in Row should use some fixed locale with dot decimal separator (such as en-US):
--- a/lib/src/main/java/edu/stanford/futuredata/macrobase/datamodel/Row.java+++ b/lib/src/main/java/edu/stanford/futuredata/macrobase/datamodel/Row.java@@ -5,8 +5,11 @@ import static java.util.stream.Collectors.toList;
import com.google.common.base.Joiner;
import java.io.PrintStream;
import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
import java.util.Collections;
import java.util.List;
+import java.util.Locale;+
import org.apache.commons.lang3.StringUtils;
/**
@@ -15,7 +18,7 @@ import org.apache.commons.lang3.StringUtils;
public class Row {
// Formatter for printing out doubles; print at least 1 and no more than 6 decimal places
- private static final DecimalFormat DOUBLE_FORMAT = new DecimalFormat("#.0#####");+ private static final DecimalFormat DOUBLE_FORMAT = new DecimalFormat("#.0#####", new DecimalFormatSymbols(Locale.US));
private Schema schema; // not set by user
private List<Object> vals;
or the test should use the same format for current locale:
RowTest testSimple
fails on my Windows PC because it tries to compare "5,0" (comma) fromrow.toString()
and "5.0" (dot) here:It happens because
Row
usesDecimalFormat("#.0#####")
to convert doubles to string, which uses the current locale. (By the way, seems like it just takes default format for locale ignoring additional Windows format settings: I haveru-RU
locale on this PC but decimal separator is specified as dot in additional settings)So I think either
DecimalFormat
inRow
should use some fixed locale with dot decimal separator (such asen-US
):or the test should use the same format for current locale:
The text was updated successfully, but these errors were encountered: