예제 #1
0
        public void TestReadWriteTokenValueBytes()
        {
            ArrayPtg ptg = new ArrayPtg(TestcaseRecordInputStream.CreateWithFakeSid(ENCODED_PTG_DATA));

            ptg.ReadTokenValues(TestcaseRecordInputStream.CreateWithFakeSid(ENCODED_CONSTANT_DATA));
            Assert.AreEqual(3, ptg.ColumnCount);
            Assert.AreEqual(2, ptg.RowCount);
            object[] values = ptg.GetTokenArrayValues();
            Assert.AreEqual(6, values.Length);


            Assert.AreEqual(true, values[0]);
            Assert.AreEqual("ABCD", values[1]);
            Assert.AreEqual(0, Convert.ToInt32(values[3]));
            Assert.AreEqual(false, values[4]);
            Assert.AreEqual("FG", values[5]);

            byte[] outBuf = new byte[ENCODED_CONSTANT_DATA.Length];
            ptg.WriteTokenValueBytes(new LittleEndianByteArrayOutputStream(outBuf, 0));

            if (outBuf[0] == 4)
            {
                throw new AssertFailedException("Identified bug 42564b");
            }
            Assert.IsTrue(NPOI.Util.Arrays.Equals(ENCODED_CONSTANT_DATA, outBuf));
        }
예제 #2
0
        public void TestReadWrite_tRefN_bug45091()
        {
            RecordInputStream in1 = TestcaseRecordInputStream.CreateWithFakeSid(tRefN_data);

            Ptg[]  ptgs    = Ptg.ReadTokens(tRefN_data.Length, in1);
            byte[] outData = new byte[5];
            Ptg.SerializePtgs(ptgs, outData, 0);
            if (outData[0] == 0x24)
            {
                throw new AssertFailedException("Identified bug 45091");
            }
            Assert.IsTrue(NPOI.Util.Arrays.Equals(tRefN_data, outData));
        }
예제 #3
0
        public void TestDecode()
        {
            RecordInputStream inStream = TestcaseRecordInputStream.CreateWithFakeSid(SAMPLE_ENCODING);

            object[] values = ConstantValueParser.Parse(inStream, 4);
            for (int i = 0; i < values.Length; i++)
            {
                if (!IsEqual(SAMPLE_VALUES[i], values[i]))
                {
                    Assert.Fail("Decoded result differs");
                }
            }
        }
예제 #4
0
        public void TestElementOrdering()
        {
            ArrayPtg ptg = new ArrayPtg(TestcaseRecordInputStream.CreateWithFakeSid(ENCODED_PTG_DATA));

            ptg.ReadTokenValues(TestcaseRecordInputStream.CreateWithFakeSid(ENCODED_CONSTANT_DATA));
            Assert.AreEqual(3, ptg.ColumnCount);
            Assert.AreEqual(2, ptg.RowCount);

            Assert.AreEqual(0, ptg.GetValueIndex(0, 0));
            Assert.AreEqual(2, ptg.GetValueIndex(1, 0));
            Assert.AreEqual(4, ptg.GetValueIndex(2, 0));
            Assert.AreEqual(1, ptg.GetValueIndex(0, 1));
            Assert.AreEqual(3, ptg.GetValueIndex(1, 1));
            Assert.AreEqual(5, ptg.GetValueIndex(2, 1));
        }
예제 #5
0
        public void TestRead()
        {
            // This ptg represents a LEN function extracted from excel
            byte[] fakeData =
            {
                0x20, //function index
                0,
            };

            FuncPtg ptg = new FuncPtg(TestcaseRecordInputStream.CreateWithFakeSid(fakeData));

            Assert.AreEqual(0x20, ptg.GetFunctionIndex(), "Len formula index is1 not 32(20H)");
            Assert.AreEqual(1, ptg.NumberOfOperands, "Number of operands in the len formula");
            Assert.AreEqual("LEN", ptg.Name, "Function Name");
            Assert.AreEqual(3, ptg.Size, "Ptg Size");
        }