Search in sources :

Example 6 with LittleEndianInput

use of org.apache.poi.util.LittleEndianInput in project poi by apache.

the class TestArrayPtg method confirmOperandClassDecoding.

private static void confirmOperandClassDecoding(byte operandClass) {
    byte[] fullData = concat(ENCODED_PTG_DATA, ENCODED_CONSTANT_DATA);
    // Force encoded operand class for tArray
    fullData[0] = (byte) (ArrayPtg.sid + operandClass);
    LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(fullData);
    Ptg[] ptgs = Ptg.readTokens(ENCODED_PTG_DATA.length, in);
    assertEquals(1, ptgs.length);
    ArrayPtg aPtg = (ArrayPtg) ptgs[0];
    assertEquals(operandClass, aPtg.getPtgClass());
}
Also used : LittleEndianInput(org.apache.poi.util.LittleEndianInput)

Example 7 with LittleEndianInput

use of org.apache.poi.util.LittleEndianInput in project poi by apache.

the class TestAttrPtg method testReserializeAttrChoose.

/**
	 * Fix for bug visible around svn r706772.
	 */
public void testReserializeAttrChoose() {
    byte[] data = HexRead.readFromString("19, 04, 03, 00, 08, 00, 11, 00, 1A, 00, 23, 00");
    LittleEndianInput in = TestcaseRecordInputStream.createLittleEndian(data);
    Ptg[] ptgs = Ptg.readTokens(data.length, in);
    byte[] data2 = new byte[data.length];
    try {
        Ptg.serializePtgs(ptgs, data2, 0);
    } catch (ArrayIndexOutOfBoundsException e) {
        throw new AssertionFailedError("incorrect re-serialization of tAttrChoose");
    }
    assertArrayEquals(data, data2);
}
Also used : LittleEndianInput(org.apache.poi.util.LittleEndianInput) AssertionFailedError(junit.framework.AssertionFailedError)

Aggregations

LittleEndianInput (org.apache.poi.util.LittleEndianInput)7 AssertionFailedError (junit.framework.AssertionFailedError)3 RefPtg (org.apache.poi.ss.formula.ptg.RefPtg)2 Test (org.junit.Test)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ExtRst (org.apache.poi.hssf.record.common.UnicodeString.ExtRst)1 SharedFormula (org.apache.poi.ss.formula.SharedFormula)1 Area3DPtg (org.apache.poi.ss.formula.ptg.Area3DPtg)1 AreaPtg (org.apache.poi.ss.formula.ptg.AreaPtg)1 Ptg (org.apache.poi.ss.formula.ptg.Ptg)1 Ref3DPtg (org.apache.poi.ss.formula.ptg.Ref3DPtg)1 LittleEndianByteArrayInputStream (org.apache.poi.util.LittleEndianByteArrayInputStream)1 LittleEndianByteArrayOutputStream (org.apache.poi.util.LittleEndianByteArrayOutputStream)1 LittleEndianInputStream (org.apache.poi.util.LittleEndianInputStream)1