acoliver    02/04/30 18:41:51

  Modified:    src/testcases/org/apache/poi/hssf/usermodel
                        TestFormulas.java
  Log:
  wow... I thought I was doing test first....but um...it turns out it already works.  
Avik ROCKS!!!
  
  Revision  Changes    Path
  1.12      +89 -0     
jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java
  
  Index: TestFormulas.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-poi/src/testcases/org/apache/poi/hssf/usermodel/TestFormulas.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- TestFormulas.java 1 May 2002 01:19:28 -0000       1.11
  +++ TestFormulas.java 1 May 2002 01:41:51 -0000       1.12
  @@ -291,6 +291,16 @@
           areaFunctionTest("AVERAGE");
       }
       
  +    public void testRefArraySum() 
  +    throws Exception {
  +        refArrayFunctionTest("SUM");
  +    }
  +    
  +    public void testAreaArraySum() 
  +    throws Exception {
  +        refAreaArrayFunctionTest("SUM");
  +    }
  +
       
       
       private void operationRefTest(String operator) 
  @@ -608,6 +618,85 @@
                         );
               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) {
  
  
  


Reply via email to