ComputeEnumSize() public static method

Compute the number of bytes that would be needed to encode a enum field, including the tag. The caller is responsible for converting the enum value to its numeric value.
public static ComputeEnumSize ( int fieldNumber, int value ) : int
fieldNumber int
value int
return int
        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));
        }