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

Make junit tests results locale independent #536

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/test/java/org/numenta/nupic/BitHistoryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import static org.junit.Assert.assertEquals;

import java.lang.reflect.Method;
import java.text.DecimalFormat;

import org.junit.Test;
import org.numenta.nupic.algorithms.BitHistory;
Expand All @@ -19,7 +20,8 @@ public void testPFormatArray() {
m.setAccessible(true);
double[] da = { 2.0, 4.0 };
String output = (String)m.invoke(history, da);
assertEquals("[ 2.00 4.00 ]", output);
char decimalSeparator = new DecimalFormat().getDecimalFormatSymbols().getDecimalSeparator();
assertEquals("[ 2"+decimalSeparator+"00 4"+decimalSeparator+"00 ]", output);
}catch(Exception e) {
e.printStackTrace();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import static org.junit.Assert.assertTrue;

import java.text.DecimalFormat;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.junit.Assert;
import org.junit.Test;
import org.numenta.nupic.Parameters;
import org.numenta.nupic.Parameters.KEY;
Expand All @@ -24,6 +26,7 @@ public void test_mmPrettyPrintConnections() {
MonitoredTemporalMemory mtm = new MonitoredTemporalMemory(new TemporalMemory(), new Connections());
prepConstructs((TemporalMemory)mtm.getMonitor(), mtm.getConnections());

char decimalSeparator = new DecimalFormat().getDecimalFormatSymbols().getDecimalSeparator();
String expected =
"Segments: (format => (#) [(source cell=permanence ...), ...]\n" +
"------------------------------------\n" +
Expand All @@ -32,14 +35,14 @@ public void test_mmPrettyPrintConnections() {
"Column 0 / Cell 2:\t(0) []\n" +
"Column 0 / Cell 3:\t(0) []\n\n" +

"Column 1 / Cell 4:\t(1) [( 0=0.60 1=0.60 2=0.60 3=0.60)]\n" +
"Column 1 / Cell 4:\t(1) [( 0=0"+decimalSeparator+"60 1=0"+decimalSeparator+"60 2=0"+decimalSeparator+"60 3=0"+decimalSeparator+"60)]\n" +
"Column 1 / Cell 5:\t(0) []\n" +
"Column 1 / Cell 6:\t(0) []\n" +
"Column 1 / Cell 7:\t(0) []\n" +
"------------------------------------";

String s = mtm.mmPrettyPrintConnections().trim();
assertTrue(expected.equals(s));
Assert.assertEquals(expected, s);
}

public void prepConstructs(TemporalMemory tm, Connections cn) {
Expand Down