Beispiel #1
0
        public void TestRead()
        {
            // This function index represents the LEN() function
            byte[] fakeData = { 0x20, 0x00, };

            FuncPtg ptg = FuncPtg.Create(TestcaseRecordInputStream.CreateLittleEndian(fakeData));

            Assert.AreEqual(0x20, ptg.FunctionIndex, "Len formula index is 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");
        }
Beispiel #2
0
        public void TestReadWrite_tRefN_bug45091()
        {
            ILittleEndianInput in1 = TestcaseRecordInputStream.CreateLittleEndian(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 AssertionException("Identified bug 45091");
            }
            Assert.IsTrue(Arrays.Equals(tRefN_data, outData));
        }
Beispiel #3
0
        public void TestDecode()
        {
            ILittleEndianInput in1 = TestcaseRecordInputStream.CreateLittleEndian(SAMPLE_ENCODING);

            object[] values = ConstantValueParser.Parse(in1, 4);
            for (int i = 0; i < values.Length; i++)
            {
                if (!IsEqual(SAMPLE_VALUES[i], values[i]))
                {
                    Assert.Fail("Decoded result differs");
                }
            }
        }
Beispiel #4
0
        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);

            ILittleEndianInput in1 = TestcaseRecordInputStream.CreateLittleEndian(fullData);

            Ptg[] ptgs = Ptg.ReadTokens(ENCODED_PTG_DATA.Length, in1);
            Assert.AreEqual(1, ptgs.Length);
            ArrayPtg aPtg = (ArrayPtg)ptgs[0];

            Assert.AreEqual(operandClass, aPtg.PtgClass);
        }
Beispiel #5
0
        public void TestReSerializeAttrChoose()
        {
            byte[]             data = HexRead.ReadFromString("19, 04, 03, 00, 08, 00, 11, 00, 1A, 00, 23, 00");
            ILittleEndianInput in1  = TestcaseRecordInputStream.CreateLittleEndian(data);

            Ptg[]  ptgs  = Ptg.ReadTokens(data.Length, in1);
            byte[] data2 = new byte[data.Length];
            try
            {
                Ptg.SerializePtgs(ptgs, data2, 0);
            }
            catch (IndexOutOfRangeException)
            {
                throw new AssertionException("incorrect re-serialization of tAttrChoose");
            }
            Assert.IsTrue(Arrays.Equals(data, data2));
        }
Beispiel #6
0
 private static ArrayPtg Create(byte[] initialData, byte[] constantData)
 {
     ArrayPtg.Initial ptgInit = new ArrayPtg.Initial(TestcaseRecordInputStream.CreateLittleEndian(initialData));
     return(ptgInit.FinishReading(TestcaseRecordInputStream.CreateLittleEndian(constantData)));
 }