KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > poi > hssf > record > formula > TestFuncPtg


1         
2 /* ====================================================================
3    Copyright 2003-2004 Apache Software Foundation
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16 ==================================================================== */

17
18 package org.apache.poi.hssf.record.formula;
19
20 import junit.framework.TestCase;
21
22 /**
23  * Make sure the FuncPtg performs as expected
24  *
25  * @author Danny Mui (dmui at apache dot org)
26  */

27
28 public class TestFuncPtg extends TestCase
29 {
30
31     public TestFuncPtg( String JavaDoc name )
32     {
33         super( name );
34     }
35
36
37     public static void main( java.lang.String JavaDoc[] args )
38     {
39         junit.textui.TestRunner.run( TestFuncPtg.class );
40     }
41
42     /**
43      * Make sure the left overs are re-serialized on excel file reads to avoid
44      * the "Warning: Data may have been lost" prompt in excel.
45      * <p/>
46      * This ptg represents a LEN function extracted from excel
47      */

48
49     public void testLeftOvers()
50     {
51         byte[] fakeData = new byte[4];
52
53         fakeData[0] = (byte) 0x41;
54         fakeData[1] = (byte) 0x20; //function index
55
fakeData[2] = (byte) 0;
56         fakeData[3] = (byte) 8;
57
58         FuncPtg ptg = new FuncPtg( fakeData, 0 );
59         assertEquals( "Len formula index is not 32(20H)", (int) 0x20, ptg.getFunctionIndex() );
60         assertEquals( "Number of operands in the len formula", 1, ptg.getNumberOfOperands() );
61         assertEquals( "Function Name", "LEN", ptg.getName() );
62         assertEquals( "Ptg Size", 3, ptg.getSize() );
63         //assertEquals("first leftover byte is not 0", (byte)0, ptg.leftOvers[0]);
64
//assertEquals("second leftover byte is not 8", (byte)8, ptg.leftOvers[1]);
65

66     }
67 }
68
69
70
Popular Tags