コード例 #1
0
        public void TestNegativeEnumArray()
        {
            int arraySize = 1 + 1 + (11 * 5);
            int msgSize   = arraySize;

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

            output.WriteEnumArray(8, "", new int[] { 0, -1, -2, -3, -4, -5 });

            Assert.AreEqual(0, output.SpaceLeft);

            CodedInputStream input = CodedInputStream.CreateInstance(bytes);
            uint             tag;
            string           name;

            Assert.IsTrue(input.ReadTag(out tag, out name));

            List <int> values = new List <int>();

            input.ReadInt32Array(tag, name, values);

            Assert.AreEqual(6, values.Count);
            for (int i = 0; i > -6; i--)
            {
                Assert.AreEqual(i, values[Math.Abs(i)]);
            }
        }