update tests

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1895703 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2021-12-08 18:28:14 +00:00
parent b174eb5770
commit 548dfb37f5
2 changed files with 47 additions and 1 deletions

View File

@ -204,7 +204,7 @@ public class DataFormatter {
private final Map<String,Format> formats = new HashMap<>();
/** whether CSV friendly adjustments should be made to the formatted text **/
private final boolean emulateCSV;
private boolean emulateCSV = false;
/** whether years in dates should be displayed with 4 digits even if the formatString specifies only 2 **/
private boolean use4DigitYearsInAllDateFormats = false;
@ -275,6 +275,22 @@ public class DataFormatter {
this.emulateCSV = emulateCSV;
}
/**
* @param emulateCSV whether to emulate CSV output (default false).
* @since POI 5.2.0
*/
public void setEmulateCSV(boolean emulateCSV) {
this.emulateCSV = emulateCSV;
}
/**
* @return whether to emulate CSV output (default false).
* @since POI 5.2.0
*/
public boolean isEmulateCSV() {
return emulateCSV;
}
/**
* @param useCachedValuesForFormulaCells if set to true, when you do not provide a {@link FormulaEvaluator},
* for cells with formulas, we will return the cached value for the cell (if available),

View File

@ -83,6 +83,36 @@ class TestDataFormatter {
+ "Having: " + System.getProperty("user.language") + "/" + System.getProperty("user.country"));
}
@Test
void setEmulateCSV() {
DataFormatter dataFormatter = new DataFormatter();
assertFalse(dataFormatter.isEmulateCSV());
dataFormatter.setEmulateCSV(true);
assertTrue(dataFormatter.isEmulateCSV());
dataFormatter.setEmulateCSV(false);
assertFalse(dataFormatter.isEmulateCSV());
}
@Test
void setUse4DigitYearsInAllDateFormats() {
DataFormatter dataFormatter = new DataFormatter();
assertFalse(dataFormatter.use4DigitYearsInAllDateFormats());
dataFormatter.setUse4DigitYearsInAllDateFormats(true);
assertTrue(dataFormatter.use4DigitYearsInAllDateFormats());
dataFormatter.setUse4DigitYearsInAllDateFormats(false);
assertFalse(dataFormatter.use4DigitYearsInAllDateFormats());
}
@Test
void useCachedValuesForFormulaCells() {
DataFormatter dataFormatter = new DataFormatter();
assertFalse(dataFormatter.useCachedValuesForFormulaCells());
dataFormatter.setUseCachedValuesForFormulaCells(true);
assertTrue(dataFormatter.useCachedValuesForFormulaCells());
dataFormatter.setUseCachedValuesForFormulaCells(false);
assertFalse(dataFormatter.useCachedValuesForFormulaCells());
}
/**
* Test that we use the specified locale when deciding
* how to format normal numbers