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)); }
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)); }