ComputeInt32Size() public static method

Compute the number of bytes that would be needed to encode an int32 field, including the tag.
public static ComputeInt32Size ( int fieldNumber, int value ) : int
fieldNumber int
value int
return int
Exemplo n.º 1
0
        public void TestNegativeEnumWithTag()
        {
            Assert.AreEqual(11, CodedOutputStream.ComputeInt32Size(8, -2));
            Assert.AreEqual(11, CodedOutputStream.ComputeEnumSize(8, -2));

            byte[]            bytes  = new byte[11];
            CodedOutputStream output = CodedOutputStream.CreateInstance(bytes);

            output.WriteEnum(8, "", -2, -2);

            Assert.AreEqual(0, output.SpaceLeft);
            //fyi, 0x40 == 0x08 << 3 + 0, field num + wire format shift
            Assert.AreEqual("40-FE-FF-FF-FF-FF-FF-FF-FF-FF-01", BitConverter.ToString(bytes));
        }