FileDocCategorySizeDatePackage
TestFuncPtg.javaAPI DocApache Poi 3.0.12500Mon Jan 01 12:39:46 GMT 2007org.apache.poi.hssf.record.formula

TestFuncPtg

public class TestFuncPtg extends TestCase
Make sure the FuncPtg performs as expected
author
Danny Mui (dmui at apache dot org)

Fields Summary
Constructors Summary
public TestFuncPtg(String name)

        super( name );
    
Methods Summary
public static voidmain(java.lang.String[] args)

        junit.textui.TestRunner.run( TestFuncPtg.class );
    
public voidtestLeftOvers()
Make sure the left overs are re-serialized on excel file reads to avoid the "Warning: Data may have been lost" prompt in excel.

This ptg represents a LEN function extracted from excel

        byte[] fakeData = new byte[4];

        //fakeData[0] = (byte) 0x41;
        fakeData[0] = (byte) 0x20;  //function index
        fakeData[1] = (byte) 0;
        fakeData[2] = (byte) 8;

        FuncPtg ptg = new FuncPtg( new TestcaseRecordInputStream((short)0, (short)fakeData.length, fakeData) );
        assertEquals( "Len formula index is not 32(20H)", (int) 0x20, ptg.getFunctionIndex() );
        assertEquals( "Number of operands in the len formula", 1, ptg.getNumberOfOperands() );
        assertEquals( "Function Name", "LEN", ptg.getName() );
        assertEquals( "Ptg Size", 3, ptg.getSize() );
        //assertEquals("first leftover byte is not 0", (byte)0, ptg.leftOvers[0]);
        //assertEquals("second leftover byte is not 8", (byte)8, ptg.leftOvers[1]);