Search in sources :

Example 1 with RefNPtg

use of org.apache.poi.ss.formula.ptg.RefNPtg in project poi by apache.

the class TestCFRuleRecord method testReserializeRefNTokens.

/**
     * tRefN and tAreaN tokens must be preserved when re-serializing conditional format formulas
     */
@Test
public void testReserializeRefNTokens() {
    RecordInputStream is = TestcaseRecordInputStream.create(CFRuleRecord.sid, DATA_REFN);
    CFRuleRecord rr = new CFRuleRecord(is);
    Ptg[] ptgs = rr.getParsedExpression1();
    assertEquals(3, ptgs.length);
    if (ptgs[0] instanceof RefPtg) {
        throw new AssertionFailedError("Identified bug 45234");
    }
    assertEquals(RefNPtg.class, ptgs[0].getClass());
    RefNPtg refNPtg = (RefNPtg) ptgs[0];
    assertTrue(refNPtg.isColRelative());
    assertTrue(refNPtg.isRowRelative());
    byte[] data = rr.serialize();
    TestcaseRecordInputStream.confirmRecordEncoding(CFRuleRecord.sid, DATA_REFN, data);
}
Also used : Ptg(org.apache.poi.ss.formula.ptg.Ptg) RefPtg(org.apache.poi.ss.formula.ptg.RefPtg) RefNPtg(org.apache.poi.ss.formula.ptg.RefNPtg) RefNPtg(org.apache.poi.ss.formula.ptg.RefNPtg) RefPtg(org.apache.poi.ss.formula.ptg.RefPtg) AssertionFailedError(junit.framework.AssertionFailedError) Test(org.junit.Test)

Aggregations

AssertionFailedError (junit.framework.AssertionFailedError)1 Ptg (org.apache.poi.ss.formula.ptg.Ptg)1 RefNPtg (org.apache.poi.ss.formula.ptg.RefNPtg)1 RefPtg (org.apache.poi.ss.formula.ptg.RefPtg)1 Test (org.junit.Test)1