aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew C. Oliver <acoliver@apache.org>2002-04-28 00:45:10 +0000
committerAndrew C. Oliver <acoliver@apache.org>2002-04-28 00:45:10 +0000
commita4fe94263bbed344d1590dec39c5c6f62d235b75 (patch)
tree5251b71183c94cafa10d4a0dabeb4ed6c21175a1 /src
parent6f0fd19520e436354f14dbe8aa0defb120cc6795 (diff)
downloadpoi-a4fe94263bbed344d1590dec39c5c6f62d235b75.tar.gz
poi-a4fe94263bbed344d1590dec39c5c6f62d235b75.zip
new test for formulas
PR: Obtained from: Submitted by: Reviewed by: git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352509 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java86
1 files changed, 49 insertions, 37 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java
index 4ac2778841..44d867e546 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java
@@ -77,21 +77,44 @@ import java.util.GregorianCalendar;
*/
public class TestFormulas
- extends TestCase
-{
- public TestFormulas(String s)
- {
+extends TestCase {
+ public TestFormulas(String s) {
super(s);
}
-
+
+ /**
+ * Add 1+1 -- WHoohoo!
+ */
+
+ public void testBasicAddIntegers()
+ throws Exception {
+ //System.out.println("Converted Text form is : "+fp.toFormulaString(fp.getRPNPtg()));
+
+ short rownum = 0;
+ File file = File.createTempFile("testFormula",".xls");
+ FileOutputStream out = new FileOutputStream(file);
+ HSSFWorkbook wb = new HSSFWorkbook();
+ HSSFSheet s = wb.createSheet();
+ HSSFRow r = null;
+ HSSFCell c = null;
+
+ //get our minimum values
+ r = s.createRow((short)1);
+ c = r.createCell((short)1);
+ c.setCellFormula(1 + "+" + 1);
+
+
+ wb.write(out);
+ out.close();
+
+ }
+
/**
* Add various integers
*/
-
+
public void testAddIntegers()
- throws Exception
- {
- //System.out.println("Converted Text form is : "+fp.toFormulaString(fp.getRPNPtg()));
+ throws Exception {
short rownum = 0;
File file = File.createTempFile("testFormula",".xls");
@@ -101,51 +124,40 @@ public class TestFormulas
HSSFRow r = null;
HSSFCell c = null;
- for (short x = 2; x < Short.MAX_VALUE && x > 0; x=(short)(x*2)) {
+ //get our minimum values
+ r = s.createRow((short)1);
+ c = r.createCell((short)1);
+ c.setCellFormula(1 + "+" + 1);
+
+ for (short x = 1; x < Short.MAX_VALUE && x > 0; x=(short)(x*2)) {
r = s.createRow((short) x);
- System.out.println("x="+x);
- for (short y = 2; y < Short.MAX_VALUE && y > 0; y=(short)(y*2)) {
- System.out.println("y="+y);
+ //System.out.println("x="+x);
+ for (short y = 1; y < 200 && y > 0; y++) {
+ //System.out.println("y="+y);
c = r.createCell((short) y);
c.setCellFormula("" + x + "+" + y);
-
+
}
}
//make sure we do the maximum value of the Int operator
- /* if (s.getLastRowNum() < Short.MAX_VALUE) {
- r = s.createRow(Short.MAX_VALUE);
- c = r.createCell(Short.MAX_VALUE);
+ if (s.getLastRowNum() < Short.MAX_VALUE) {
+ r = s.createRow((short)0);
+ c = r.createCell((short)0);
c.setCellFormula("" + Short.MAX_VALUE + "+" + Short.MAX_VALUE);
- }*/
+ }
wb.write(out);
out.close();
- /*
- FileInputStream stream = new FileInputStream(file);
- wb = new HSSFWorkbook(stream);
- s = wb.getSheetAt(0);
-
- for (short x = 0; x < Short.MAX_VALUE; x++) {
- r = s.createRow((short) 0);
-
- for (short y = 0; y < Short.MAX_VALUE; y++) {
-
- c = r.createCell((short) 0);
- c.getCellFormula("" + x + "+" + y);
- }
- }
- */
-
}
- public static void main(String [] args)
- {
+
+ public static void main(String [] args) {
System.out
- .println("Testing org.apache.poi.hssf.usermodel.TestFormulas");
+ .println("Testing org.apache.poi.hssf.usermodel.TestFormulas");
junit.textui.TestRunner.run(TestFormulas.class);
}