aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache/poi/ss
diff options
context:
space:
mode:
authorDominik Stadler <centic@apache.org>2015-07-22 20:30:24 +0000
committerDominik Stadler <centic@apache.org>2015-07-22 20:30:24 +0000
commitbe08c4318098eb0f1763b250ec072689a98d425a (patch)
tree2ac4adb0d7e8087bfc5eeeacefdff887cec39ca4 /src/testcases/org/apache/poi/ss
parente512035ead3e2f2e01d4f7c168d3a5a0441be721 (diff)
downloadpoi-be08c4318098eb0f1763b250ec072689a98d425a.tar.gz
poi-be08c4318098eb0f1763b250ec072689a98d425a.zip
Yet another adjustment to the test as it seems that small values can be computed, only larger ones fail, let's find out at which point it fails
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1692326 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache/poi/ss')
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
index 40ef329ed2..19fa37a442 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
@@ -37,6 +37,7 @@ import org.apache.poi.ss.ITestDataProvider;
import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.ss.util.SheetUtil;
+import org.apache.poi.util.StringUtil;
import org.junit.Assume;
import org.junit.Ignore;
import org.junit.Test;
@@ -368,18 +369,24 @@ public abstract class BaseTestBugzillaIssues {
assertEquals("Expecting no rotation in this test",
0, cell0.getCellStyle().getRotation());
+ // check computing size up to a large size
+ StringBuilder b = new StringBuilder();
+ for(int i = 0;i < longValue.length()*5;i++) {
+ b.append("w");
+ assertTrue("Had zero length starting at length " + i, computeCellWidthFixed(font, b.toString()) > 0);
+ }
double widthManual = computeCellWidthManually(cell0, font);
double widthBeforeCell = SheetUtil.getCellWidth(cell0, 8, null, false);
double widthBeforeCol = SheetUtil.getColumnWidth(sheet, 0, false);
assertTrue("Expected to have cell width > 0 when computing manually, but had " + widthManual + "/" + widthBeforeCell + "/" + widthBeforeCol + "/" +
- SheetUtil.canComputeColumnWidht(font) + "/" + computeCellWidthFixed(cell0, font, "1") + "/" + computeCellWidthFixed(cell0, font, "0000") + "/" + computeCellWidthFixed(cell0, font, longValue),
+ SheetUtil.canComputeColumnWidht(font) + "/" + computeCellWidthFixed(font, "1") + "/" + computeCellWidthFixed(font, "0000") + "/" + computeCellWidthFixed(font, longValue),
widthManual > 0);
assertTrue("Expected to have cell width > 0 BEFORE auto-size, but had " + widthManual + "/" + widthBeforeCell + "/" + widthBeforeCol + "/" +
- SheetUtil.canComputeColumnWidht(font) + "/" + computeCellWidthFixed(cell0, font, "1") + "/" + computeCellWidthFixed(cell0, font, "0000") + "/" + computeCellWidthFixed(cell0, font, longValue),
+ SheetUtil.canComputeColumnWidht(font) + "/" + computeCellWidthFixed(font, "1") + "/" + computeCellWidthFixed(font, "0000") + "/" + computeCellWidthFixed(font, longValue),
widthBeforeCell > 0);
assertTrue("Expected to have column width > 0 BEFORE auto-size, but had " + widthManual + "/" + widthBeforeCell + "/" + widthBeforeCol + "/" +
- SheetUtil.canComputeColumnWidht(font) + "/" + computeCellWidthFixed(cell0, font, "1") + "/" + computeCellWidthFixed(cell0, font, "0000") + "/" + computeCellWidthFixed(cell0, font, longValue),
+ SheetUtil.canComputeColumnWidht(font) + "/" + computeCellWidthFixed(font, "1") + "/" + computeCellWidthFixed(font, "0000") + "/" + computeCellWidthFixed(font, longValue),
widthBeforeCol > 0);
sheet.autoSizeColumn(0);
@@ -411,7 +418,7 @@ public abstract class BaseTestBugzillaIssues {
return ((layout.getBounds().getWidth() / 1) / 8);
}
- private double computeCellWidthFixed(Cell cell0, Font font, String txt) {
+ private double computeCellWidthFixed(Font font, String txt) {
final FontRenderContext fontRenderContext = new FontRenderContext(null, true, true);
AttributedString str = new AttributedString(txt);
copyAttributes(font, str, 0, txt.length());