Skip to content

Commit 4aafb84

Browse files
committed
Make the TimingTest more permissive to hopefully avoid errors on Windows as well as Linux
1 parent fa89d7c commit 4aafb84

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/src/edu/stanford/nlp/util/TimingTest.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,17 @@ public void testTiming() {
3333
sleepTen();
3434
long val = t.report();
3535
// System.err.println(val);
36-
assertEquals("Wrong sleep", 20, val, 20);
36+
assertEquals("Wrong sleep", 25, val, 25);
3737
// On Linux, 6 loops is ~80ms which gets rounded up to 100 by the DecimalFormat.
3838
// On Windows, 6 loops is ~130ms which gets rounded down to 100
3939
for (int i = 0; i < 6; i++) {
4040
sleepTen();
4141
}
4242
long val3 = t.report();
43-
assertEquals("Wrong formatted time", new DecimalFormat("0.0", DecimalFormatSymbols.getInstance(Locale.ROOT)).format(0.1), Timing.toSecondsString(val3));
43+
String timingString = Timing.toSecondsString(val3);
44+
String exp1 = new DecimalFormat("0.0", DecimalFormatSymbols.getInstance(Locale.ROOT)).format(0.1);
45+
String exp2 = new DecimalFormat("0.0", DecimalFormatSymbols.getInstance(Locale.ROOT)).format(0.2);
46+
assertTrue("Wrong formatted time", exp1.equals(timingString) || exp2.equals(timingString));
4447
}
4548

4649
private static void sleepTen() {

0 commit comments

Comments
 (0)