View | Details | Raw Unified | Return to bug 13078
Collapse All | Expand All

(-)TestFormulaParser.java.~1.1.~ (-3 / +28 lines)
Lines 3-8 Link Here
3
import junit.framework.TestCase;
3
import junit.framework.TestCase;
4
4
5
import org.apache.poi.hssf.record.formula.*;
5
import org.apache.poi.hssf.record.formula.*;
6
import org.apache.poi.hssf.util.SheetReferences;
6
7
7
/**
8
/**
8
 * Test the low level formula parser functionality. High level tests are to 
9
 * Test the low level formula parser functionality. High level tests are to 
Lines 65-76 Link Here
65
        assertTrue("three token expected, got " + ptgs.length, ptgs.length == 3);
66
        assertTrue("three token expected, got " + ptgs.length, ptgs.length == 3);
66
    }
67
    }
67
68
69
    public void testTRUE() throws Exception {
70
        FormulaParser fp = new FormulaParser("TRUE", null);
71
        fp.parse();
72
        Ptg[] asts = fp.getRPNPtg();
73
        assertEquals(1, asts.length);
74
        BoolPtg flag  = (BoolPtg) asts[0];
75
        assertEquals(true, flag.getValue());
76
    }
77
78
    public void testYN() throws Exception {
79
        final String yn = "IF(TRUE,\"Y\",\"N\")";
80
        FormulaParser fp = new FormulaParser(yn, null);
81
        fp.parse();
82
        Ptg[] asts = fp.getRPNPtg();
83
        assertEquals(4, asts.length);
84
85
        BoolPtg flag  = (BoolPtg) asts[0];
86
        StringPtg y = (StringPtg) asts[1];
87
        StringPtg n = (StringPtg) asts[2];
88
        AttrPtg funif = (AttrPtg) asts[3];
89
90
        assertEquals(true, flag.getValue());
91
        assertEquals("Y", y.getValue());
92
        assertEquals("N", n.getValue());
93
        assertEquals("IF", funif.toFormulaString(new SheetReferences()));
94
    }
95
68
    
96
    
69
     public static void main(String [] args) {
97
     public static void main(String [] args) {
70
        System.out.println("Testing org.apache.poi.hssf.record.formula.FormulaParser");
98
        System.out.println("Testing org.apache.poi.hssf.record.formula.FormulaParser");
71
        junit.textui.TestRunner.run(TestFormulaParser.class);
99
        junit.textui.TestRunner.run(TestFormulaParser.class);
72
    }
100
    }
73
}
101
}
74
75
76

Return to bug 13078