You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2015/07/22 22:30:24 UTC
svn commit: r1692326 -
/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
Author: centic
Date: Wed Jul 22 20:30:24 2015
New Revision: 1692326
URL: http://svn.apache.org/r1692326
Log:
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
Modified:
poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
Modified: poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java?rev=1692326&r1=1692325&r2=1692326&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java Wed Jul 22 20:30:24 2015
@@ -37,6 +37,7 @@ import org.apache.poi.ss.ITestDataProvid
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 BaseTestBugzillaIs
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 BaseTestBugzillaIs
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());
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org