wow... I thought I was doing test first....but um...it turns out it already works. Avik ROCKS!!!

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352575 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Andrew C. Oliver 2002-05-01 01:41:51 +00:00
parent fb5a020060
commit 46e32166e4
1 changed files with 89 additions and 0 deletions

View File

@ -291,6 +291,16 @@ extends TestCase {
areaFunctionTest("AVERAGE");
}
public void testRefArraySum()
throws Exception {
refArrayFunctionTest("SUM");
}
public void testAreaArraySum()
throws Exception {
refAreaArrayFunctionTest("SUM");
}
private void operationRefTest(String operator)
@ -609,6 +619,85 @@ extends TestCase {
in.close();
}
/**
* Writes a function then tests to see if its correct
*
*/
public void refArrayFunctionTest(String function)
throws Exception {
short rownum = 0;
File file = File.createTempFile("testFormulaArrayFunction"+function,".xls");
FileOutputStream out = new FileOutputStream(file);
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet();
HSSFRow r = null;
HSSFCell c = null;
r = s.createRow((short) 0);
c = r.createCell((short) 0);
c.setCellFormula(function+"(A2,A3)");
wb.write(out);
out.close();
assertTrue("file exists",file.exists());
FileInputStream in = new FileInputStream(file);
wb = new HSSFWorkbook(in);
s = wb.getSheetAt(0);
r = s.getRow(0);
c = r.getCell((short)0);
assertTrue("function ="+function+"(A2,A3)",
( (function+"(A2,A3)").equals((function+"(A2,A3)")) )
);
in.close();
}
/**
* Writes a function then tests to see if its correct
*
*/
public void refAreaArrayFunctionTest(String function)
throws Exception {
short rownum = 0;
File file = File.createTempFile("testFormulaAreaArrayFunction"+function,".xls");
FileOutputStream out = new FileOutputStream(file);
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet s = wb.createSheet();
HSSFRow r = null;
HSSFCell c = null;
r = s.createRow((short) 0);
c = r.createCell((short) 0);
c.setCellFormula(function+"(A2:A4,B2:B4)");
wb.write(out);
out.close();
assertTrue("file exists",file.exists());
FileInputStream in = new FileInputStream(file);
wb = new HSSFWorkbook(in);
s = wb.getSheetAt(0);
r = s.getRow(0);
c = r.getCell((short)0);
assertTrue("function ="+function+"(A2:A4,B2:B4)",
( (function+"(A2:A4,B2:B4)").equals((function+"(A2:A4,B2:B4)")) )
);
in.close();
}
public static void main(String [] args) {
System.out