Esempio n. 1
0
        public void TestError()
        {
            byte[] data = HexRead.ReadFromString(
                "00 00 00 00 0F 00 " + // row, col, xfIndex
                "07 01 "               // #DIV/0!, isError
                );

            RecordInputStream in1 = TestcaseRecordInputStream.Create(BoolErrRecord.sid, data);
            BoolErrRecord     ber = new BoolErrRecord(in1);

            Assert.IsTrue(ber.IsError);
            Assert.AreEqual(7, ber.ErrorValue);

            TestcaseRecordInputStream.ConfirmRecordEncoding(BoolErrRecord.sid, data, ber.Serialize());
        }
Esempio n. 2
0
        public void TestOooBadFormat_bug47479()
        {
            byte[] data = HexRead.ReadFromString(
                "05 02 09 00 " +       // sid, size
                "00 00 00 00 0F 00 " + // row, col, xfIndex
                "01 00 00 "            // extra 00 byte here
                );

            RecordInputStream in1 = TestcaseRecordInputStream.Create(data);
            BoolErrRecord     ber = new BoolErrRecord(in1);
            bool hasMore;

            try
            {
                hasMore = in1.HasNextRecord;
            }
            catch (LeftoverDataException e)
            {
                if ("Initialisation of record 0x205 left 1 bytes remaining still to be Read.".Equals(e.Message))
                {
                    throw new AssertFailedException("Identified bug 47479");
                }
                throw e;
            }
            Assert.IsFalse(hasMore);
            Assert.IsTrue(ber.IsBoolean);
            Assert.AreEqual(true, ber.BooleanValue);

            // Check that the record re-Serializes correctly
            byte[] outData = ber.Serialize();
            byte[] expData = HexRead.ReadFromString(
                "05 02 08 00 " +
                "00 00 00 00 0F 00 " +
                "01 00 "     // normal number of data bytes
                );
            Assert.IsTrue(Arrays.Equals(expData, outData));
        }