aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org/apache
diff options
context:
space:
mode:
authorNick Burch <nick@apache.org>2014-10-18 20:10:31 +0000
committerNick Burch <nick@apache.org>2014-10-18 20:10:31 +0000
commit1cd3797dda4ffed3ce8d4a161f0558ce759d6603 (patch)
tree9751bf0245abefccad1924a9725b007d771698f8 /src/testcases/org/apache
parent7832ad993c31e8455b9fbed741a95f72eb9b3b12 (diff)
downloadpoi-1cd3797dda4ffed3ce8d4a161f0558ce759d6603.tar.gz
poi-1cd3797dda4ffed3ce8d4a161f0558ce759d6603.zip
Move non-HSSF specific bug tests into BaseTestBugzillaIssues from HSSF TestBugs, so they can be tested automatically on XSSF too
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1632837 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/testcases/org/apache')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java118
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java127
2 files changed, 127 insertions, 118 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
index f0cc68101e..706ff5e50d 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
@@ -65,7 +65,6 @@ import org.apache.poi.ss.formula.ptg.Ptg;
import org.apache.poi.ss.usermodel.BaseTestBugzillaIssues;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
-import org.apache.poi.ss.usermodel.DataFormat;
import org.apache.poi.ss.usermodel.DataFormatter;
import org.apache.poi.ss.usermodel.FormulaEvaluator;
import org.apache.poi.ss.usermodel.Name;
@@ -143,21 +142,6 @@ public final class TestBugs extends BaseTestBugzillaIssues {
writeOutAndReadBack(wb);
}
- /** test hyperlinks
- * open resulting file in excel, and check that there is a link to Google
- */
- @Test
- public void bug15353() {
- HSSFWorkbook wb = new HSSFWorkbook();
- HSSFSheet sheet = wb.createSheet("My sheet");
-
- HSSFRow row = sheet.createRow( 0 );
- HSSFCell cell = row.createCell( 0 );
- cell.setCellFormula("HYPERLINK(\"http://google.com\",\"Google\")");
-
- writeOutAndReadBack(wb);
- }
-
/** test reading of a formula with a name and a cell ref in one
**/
@Test
@@ -2220,44 +2204,6 @@ public final class TestBugs extends BaseTestBugzillaIssues {
}
/**
- * HLookup and VLookup with optional arguments
- */
- @Test
- public void bug51024() throws Exception {
- HSSFWorkbook wb = new HSSFWorkbook();
- HSSFSheet s = wb.createSheet();
- HSSFRow r1 = s.createRow(0);
- HSSFRow r2 = s.createRow(1);
-
- r1.createCell(0).setCellValue("v A1");
- r2.createCell(0).setCellValue("v A2");
- r1.createCell(1).setCellValue("v B1");
-
- HSSFCell c = r1.createCell(4);
-
- HSSFFormulaEvaluator eval = new HSSFFormulaEvaluator(wb);
-
- c.setCellFormula("VLOOKUP(\"v A1\", A1:B2, 1)");
- assertEquals("v A1", eval.evaluate(c).getStringValue());
-
- c.setCellFormula("VLOOKUP(\"v A1\", A1:B2, 1, 1)");
- assertEquals("v A1", eval.evaluate(c).getStringValue());
-
- c.setCellFormula("VLOOKUP(\"v A1\", A1:B2, 1, )");
- assertEquals("v A1", eval.evaluate(c).getStringValue());
-
-
- c.setCellFormula("HLOOKUP(\"v A1\", A1:B2, 1)");
- assertEquals("v A1", eval.evaluate(c).getStringValue());
-
- c.setCellFormula("HLOOKUP(\"v A1\", A1:B2, 1, 1)");
- assertEquals("v A1", eval.evaluate(c).getStringValue());
-
- c.setCellFormula("HLOOKUP(\"v A1\", A1:B2, 1, )");
- assertEquals("v A1", eval.evaluate(c).getStringValue());
- }
-
- /**
* Mixture of Ascii and Unicode strings in a
* NameComment record
*/
@@ -2517,70 +2463,6 @@ public final class TestBugs extends BaseTestBugzillaIssues {
}
@Test
- public void stackoverflow23114397() throws Exception {
- Workbook wb = new HSSFWorkbook();
- DataFormat format = wb.getCreationHelper().createDataFormat();
-
- // How close the sizing should be, given that not all
- // systems will have quite the same fonts on them
- float fontAccuracy = 0.22f;
-
- // x%
- CellStyle iPercent = wb.createCellStyle();
- iPercent.setDataFormat(format.getFormat("0%"));
- // x.x%
- CellStyle d1Percent = wb.createCellStyle();
- d1Percent.setDataFormat(format.getFormat("0.0%"));
- // x.xx%
- CellStyle d2Percent = wb.createCellStyle();
- d2Percent.setDataFormat(format.getFormat("0.00%"));
-
- Sheet s = wb.createSheet();
- Row r1 = s.createRow(0);
-
- for (int i=0; i<3; i++) {
- r1.createCell(i, Cell.CELL_TYPE_NUMERIC).setCellValue(0);
- }
- for (int i=3; i<6; i++) {
- r1.createCell(i, Cell.CELL_TYPE_NUMERIC).setCellValue(1);
- }
- for (int i=6; i<9; i++) {
- r1.createCell(i, Cell.CELL_TYPE_NUMERIC).setCellValue(0.12345);
- }
- for (int i=9; i<12; i++) {
- r1.createCell(i, Cell.CELL_TYPE_NUMERIC).setCellValue(1.2345);
- }
- for (int i=0; i<12; i+=3) {
- r1.getCell(i+0).setCellStyle(iPercent);
- r1.getCell(i+1).setCellStyle(d1Percent);
- r1.getCell(i+2).setCellStyle(d2Percent);
- }
- for (int i=0; i<12; i++) {
- s.autoSizeColumn(i);
- }
-
- // Check the 0(.00)% ones
- assertAlmostEquals(980, s.getColumnWidth(0), fontAccuracy);
- assertAlmostEquals(1400, s.getColumnWidth(1), fontAccuracy);
- assertAlmostEquals(1700, s.getColumnWidth(2), fontAccuracy);
-
- // Check the 100(.00)% ones
- assertAlmostEquals(1500, s.getColumnWidth(3), fontAccuracy);
- assertAlmostEquals(1950, s.getColumnWidth(4), fontAccuracy);
- assertAlmostEquals(2225, s.getColumnWidth(5), fontAccuracy);
-
- // Check the 12(.34)% ones
- assertAlmostEquals(1225, s.getColumnWidth(6), fontAccuracy);
- assertAlmostEquals(1650, s.getColumnWidth(7), fontAccuracy);
- assertAlmostEquals(1950, s.getColumnWidth(8), fontAccuracy);
-
- // Check the 123(.45)% ones
- assertAlmostEquals(1500, s.getColumnWidth(9), fontAccuracy);
- assertAlmostEquals(1950, s.getColumnWidth(10), fontAccuracy);
- assertAlmostEquals(2225, s.getColumnWidth(11), fontAccuracy);
- }
-
- @Test
public void bug56450() {
HSSFWorkbook wb = openSample("56450.xls");
HSSFSheet sheet = wb.getSheetAt(0);
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
index bc80b64fa9..5e044886c3 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestBugzillaIssues.java
@@ -400,4 +400,131 @@ public abstract class BaseTestBugzillaIssues {
assertEquals(0, paneInfo.getHorizontalSplitTopRow());
}
+ /**
+ * Test hyperlinks
+ * open resulting file in excel, and check that there is a link to Google
+ */
+ @Test
+ public void bug15353() {
+ String hyperlinkF = "HYPERLINK(\"http://google.com\",\"Google\")";
+
+ Workbook wb = _testDataProvider.createWorkbook();
+ Sheet sheet = wb.createSheet("My sheet");
+
+ Row row = sheet.createRow( 0 );
+ Cell cell = row.createCell( 0 );
+ cell.setCellFormula(hyperlinkF);
+
+ assertEquals(hyperlinkF, cell.getCellFormula());
+
+ wb = _testDataProvider.writeOutAndReadBack(wb);
+ sheet = wb.getSheet("My Sheet");
+ row = sheet.getRow( 0 );
+ cell = row.getCell( 0 );
+
+ assertEquals(hyperlinkF, cell.getCellFormula());
+ }
+
+ /**
+ * HLookup and VLookup with optional arguments
+ */
+ @Test
+ public void bug51024() throws Exception {
+ Workbook wb = _testDataProvider.createWorkbook();
+ Sheet s = wb.createSheet();
+ Row r1 = s.createRow(0);
+ Row r2 = s.createRow(1);
+
+ r1.createCell(0).setCellValue("v A1");
+ r2.createCell(0).setCellValue("v A2");
+ r1.createCell(1).setCellValue("v B1");
+
+ Cell c = r1.createCell(4);
+
+ FormulaEvaluator eval = wb.getCreationHelper().createFormulaEvaluator();
+
+ c.setCellFormula("VLOOKUP(\"v A1\", A1:B2, 1)");
+ assertEquals("v A1", eval.evaluate(c).getStringValue());
+
+ c.setCellFormula("VLOOKUP(\"v A1\", A1:B2, 1, 1)");
+ assertEquals("v A1", eval.evaluate(c).getStringValue());
+
+ c.setCellFormula("VLOOKUP(\"v A1\", A1:B2, 1, )");
+ assertEquals("v A1", eval.evaluate(c).getStringValue());
+
+
+ c.setCellFormula("HLOOKUP(\"v A1\", A1:B2, 1)");
+ assertEquals("v A1", eval.evaluate(c).getStringValue());
+
+ c.setCellFormula("HLOOKUP(\"v A1\", A1:B2, 1, 1)");
+ assertEquals("v A1", eval.evaluate(c).getStringValue());
+
+ c.setCellFormula("HLOOKUP(\"v A1\", A1:B2, 1, )");
+ assertEquals("v A1", eval.evaluate(c).getStringValue());
+ }
+
+ @Test
+ public void stackoverflow23114397() throws Exception {
+ Workbook wb = _testDataProvider.createWorkbook();
+ DataFormat format = wb.getCreationHelper().createDataFormat();
+
+ // How close the sizing should be, given that not all
+ // systems will have quite the same fonts on them
+ float fontAccuracy = 0.22f;
+
+ // x%
+ CellStyle iPercent = wb.createCellStyle();
+ iPercent.setDataFormat(format.getFormat("0%"));
+ // x.x%
+ CellStyle d1Percent = wb.createCellStyle();
+ d1Percent.setDataFormat(format.getFormat("0.0%"));
+ // x.xx%
+ CellStyle d2Percent = wb.createCellStyle();
+ d2Percent.setDataFormat(format.getFormat("0.00%"));
+
+ Sheet s = wb.createSheet();
+ Row r1 = s.createRow(0);
+
+ for (int i=0; i<3; i++) {
+ r1.createCell(i, Cell.CELL_TYPE_NUMERIC).setCellValue(0);
+ }
+ for (int i=3; i<6; i++) {
+ r1.createCell(i, Cell.CELL_TYPE_NUMERIC).setCellValue(1);
+ }
+ for (int i=6; i<9; i++) {
+ r1.createCell(i, Cell.CELL_TYPE_NUMERIC).setCellValue(0.12345);
+ }
+ for (int i=9; i<12; i++) {
+ r1.createCell(i, Cell.CELL_TYPE_NUMERIC).setCellValue(1.2345);
+ }
+ for (int i=0; i<12; i+=3) {
+ r1.getCell(i+0).setCellStyle(iPercent);
+ r1.getCell(i+1).setCellStyle(d1Percent);
+ r1.getCell(i+2).setCellStyle(d2Percent);
+ }
+ for (int i=0; i<12; i++) {
+ s.autoSizeColumn(i);
+ }
+
+ // Check the 0(.00)% ones
+ assertAlmostEquals(980, s.getColumnWidth(0), fontAccuracy);
+ assertAlmostEquals(1400, s.getColumnWidth(1), fontAccuracy);
+ assertAlmostEquals(1700, s.getColumnWidth(2), fontAccuracy);
+
+ // Check the 100(.00)% ones
+ assertAlmostEquals(1500, s.getColumnWidth(3), fontAccuracy);
+ assertAlmostEquals(1950, s.getColumnWidth(4), fontAccuracy);
+ assertAlmostEquals(2225, s.getColumnWidth(5), fontAccuracy);
+
+ // Check the 12(.34)% ones
+ assertAlmostEquals(1225, s.getColumnWidth(6), fontAccuracy);
+ assertAlmostEquals(1650, s.getColumnWidth(7), fontAccuracy);
+ assertAlmostEquals(1950, s.getColumnWidth(8), fontAccuracy);
+
+ // Check the 123(.45)% ones
+ assertAlmostEquals(1500, s.getColumnWidth(9), fontAccuracy);
+ assertAlmostEquals(1950, s.getColumnWidth(10), fontAccuracy);
+ assertAlmostEquals(2225, s.getColumnWidth(11), fontAccuracy);
+ }
+
}