1 #region Copyright notice and license 2 // Protocol Buffers - Google's data interchange format 3 // Copyright 2008 Google Inc. All rights reserved. 4 // 5 // Use of this source code is governed by a BSD-style 6 // license that can be found in the LICENSE file or at 7 // https://developers.google.com/open-source/licenses/bsd 8 #endregion 9 10 using UnitTest.Issues.TestProtos; 11 using NUnit.Framework; 12 13 namespace Google.Protobuf 14 { 15 public class TestCornerCases 16 { 17 [Test] TestRoundTripNegativeEnums()18 public void TestRoundTripNegativeEnums() 19 { 20 NegativeEnumMessage msg = new NegativeEnumMessage 21 { 22 Value = NegativeEnum.MinusOne, 23 Values = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow }, 24 PackedValues = { NegativeEnum.Zero, NegativeEnum.MinusOne, NegativeEnum.FiveBelow } 25 }; 26 27 Assert.AreEqual(58, msg.CalculateSize()); 28 29 byte[] bytes = new byte[58]; 30 CodedOutputStream output = new CodedOutputStream(bytes); 31 32 msg.WriteTo(output); 33 Assert.AreEqual(0, output.SpaceLeft); 34 35 NegativeEnumMessage copy = NegativeEnumMessage.Parser.ParseFrom(bytes); 36 Assert.AreEqual(msg, copy); 37 } 38 } 39 } 40