Print out information that current locale might be wrong if a specific test fails

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1891345 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2021-07-07 10:04:16 +00:00
parent 5a1cb0ad90
commit 454baca538
2 changed files with 14 additions and 4 deletions

View File

@ -20,6 +20,7 @@ package org.apache.poi.ss.formula.eval;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.fail;
import java.util.LinkedHashMap;
import java.util.Map;
@ -81,7 +82,14 @@ final class TestOperandResolver {
values.put("18-Jan-2019", 43483.);
for (String str : values.keySet()) {
assertEquals(OperandResolver.coerceValueToDouble(new StringEval(str)), values.get(str), 0.00001);
try {
assertEquals(OperandResolver.coerceValueToDouble(new StringEval(str)), values.get(str), 0.00001);
} catch (EvaluationException e) {
fail("While handling: " + str + ". "
+ "This failure can indicate that the wrong locale is used during test-execution, "
+ "ensure you run with english/US via -Duser.language=en -Duser.country=US. "
+ "Having: " + System.getProperty("user.language") + "/" + System.getProperty("user.country"), e);
}
}
}

View File

@ -69,7 +69,7 @@ class TestDataFormatter {
assertTrue(Locale.ROOT.equals(ul) || Locale.getDefault().equals(ul));
final String textValue = NumberToTextConverter.toText(1234.56);
assertEquals(-1, textValue.indexOf('E'));
Object cellValueO = Double.valueOf(1234.56);
Object cellValueO = 1234.56;
/*CellFormat cellFormat = new CellFormat("_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-");
CellFormatResult result = cellFormat.apply(cellValueO);
@ -78,7 +78,9 @@ class TestDataFormatter {
CellFormat cfmt = CellFormat.getInstance("_-* #,##0.00_-;-* #,##0.00_-;_-* \"-\"??_-;_-@_-");
CellFormatResult result = cfmt.apply(cellValueO);
assertEquals(" 1,234.56 ", result.text,
"This failure can indicate that the wrong locale is used during test-execution, ensure you run with english/US via -Duser.language=en -Duser.country=US");
"This failure can indicate that the wrong locale is used during test-execution, "
+ "ensure you run with english/US via -Duser.language=en -Duser.country=US. "
+ "Having: " + System.getProperty("user.language") + "/" + System.getProperty("user.country"));
}
/**
@ -975,7 +977,7 @@ class TestDataFormatter {
* A numeric format string like 0E+0 should be E+
*/
@Test
void testWithEinFormat() throws Exception {
void testWithEinFormat() {
DataFormatter formatter = new DataFormatter();
// Format string literals with an E in them shouldn't be