public void TestReadLenDelimited() { var messages = new Test.Mess[3]; messages[0] = TestHelper.CreateTestMess(); messages[0].DoubleVal = 1; messages[1] = TestHelper.CreateTestMess(); messages[1].FloatVal = 1.1F; messages[2] = TestHelper.CreateTestMess(); messages[2].Int32Arr.Add(int.MinValue); var descr = TestHelper.CreateMessDescriptor(); var buff = descr.WriteLenDelimitedStream(messages); var buffers = BasicDeserializer.ReadLenDelimited(buff).ToArray(); var messages1 = buffers.Select(x => descr.Read(x)).ToArray(); var eq1 = messages[0].Equals(messages1[0]); var eq2 = messages[1].Equals(messages1[1]); var eq3 = messages[2].Equals(messages1[2]); Assert.IsTrue(eq1 && eq2 && eq3); }
public static Test.Mess CreateTestMess() { Test.Mess t = new Test.Mess() { DoubleVal = 1.234e56, FloatVal = 2.345F, Int32Val = -123, Int64Val = -123456789000L, UInt32Val = 321, UInt64Val = 123456789000L, SInt32Val = -100, SInt64Val = -923456789000L, Fixed32Val = 200, Fixed64Val = 223456789000L, SFixed32Val = -523456789, SFixed64Val = -523456789000L, BoolVal = true, StringVal = "qwe 123 !@# йцу", BytesVal = ByteString.CopyFrom(new byte[] { 1, 2, 100, 255, 3 }) }; t.DoubleArr.Add(-1.234e56); t.DoubleArr.Add(1.2); t.DoubleArr.Add(3); t.FloatArr.Add(-5.5F); t.FloatArr.Add(1.2F); t.FloatArr.Add(3F); t.Int32Arr.Add(1); t.Int32Arr.Add(-2); t.Int32Arr.Add(int.MaxValue); t.Int64Arr.Add(-1); t.Int64Arr.Add(2); t.Int64Arr.Add(long.MaxValue); t.UInt32Arr.Add(1); t.UInt32Arr.Add(0); t.UInt32Arr.Add(uint.MaxValue); t.UInt64Arr.Add(10000); t.UInt64Arr.Add(ulong.MaxValue); t.UInt64Arr.Add(2); t.SInt32Arr.Add(10000); t.SInt32Arr.Add(int.MinValue); t.SInt32Arr.Add(3); t.SInt64Arr.Add(-1234567890123); t.SInt64Arr.Add(long.MinValue); t.SInt64Arr.Add(0); t.Fixed32Arr.Add(123456); t.Fixed32Arr.Add(int.MaxValue); t.Fixed32Arr.Add(0); t.Fixed64Arr.Add(1234567890123); t.Fixed64Arr.Add(0); t.Fixed64Arr.Add(long.MaxValue); t.SFixed32Arr.Add(-123456); t.SFixed32Arr.Add(int.MaxValue); t.SFixed32Arr.Add(int.MinValue); t.SFixed64Arr.Add(-123456); t.SFixed64Arr.Add(long.MaxValue); t.SFixed64Arr.Add(long.MinValue); t.BoolArr.Add(true); t.BoolArr.Add(true); t.BoolArr.Add(false); t.StringArr.Add(""); t.StringArr.Add("qwe 123 !@# йцу"); t.StringArr.Add("qwerty"); t.BytesArr.Add(ByteString.CopyFrom(new byte[] { 1, 2, 3 })); t.BytesArr.Add(ByteString.CopyFrom(new byte[] { 1, 2, 100, 255, 3 })); t.BytesArr.Add(ByteString.CopyFrom(new byte[] { 0, 0, 0 })); t.DoublePacked.Add(-1.234e56); t.DoublePacked.Add(double.MinValue); t.DoublePacked.Add(double.MaxValue); t.FloatPacked.Add(-5.5F); t.FloatPacked.Add(1.2F); t.FloatPacked.Add(3F); t.Int32Packed.Add(1); t.Int32Packed.Add(-2); t.Int32Packed.Add(int.MinValue); t.Int64Packed.Add(-1); t.Int64Packed.Add(2); t.Int64Packed.Add(long.MaxValue); t.UInt32Packed.Add(10); t.UInt32Packed.Add(0); t.UInt32Packed.Add(uint.MaxValue); t.UInt64Packed.Add(0); t.UInt64Packed.Add(ulong.MaxValue); t.UInt64Packed.Add(2); t.SInt32Packed.Add(10000); t.SInt32Packed.Add(int.MaxValue); t.SInt32Packed.Add(0); t.SInt64Packed.Add(-1234567890123); t.SInt64Packed.Add(long.MinValue); t.SInt64Packed.Add(0); t.Fixed32Packed.Add(123456); t.Fixed32Packed.Add(int.MaxValue); t.Fixed32Packed.Add(0); t.Fixed64Packed.Add(1234567890123); t.Fixed64Packed.Add(0); t.Fixed64Packed.Add(long.MaxValue); t.SFixed32Packed.Add(-123456); t.SFixed32Packed.Add(0); t.SFixed32Packed.Add(int.MinValue); t.SFixed64Packed.Add(-123456); t.SFixed64Packed.Add(long.MaxValue); t.SFixed64Packed.Add(0); t.BoolPacked.Add(false); t.BoolPacked.Add(true); t.BoolPacked.Add(true); return(t); }
public static Test.Mess CreateTestMess() { Test.Mess t = new Test.Mess() { DoubleVal = 1.234e56, FloatVal = 2.345F, Int32Val = -123, Int64Val = -123456789000L, UInt32Val = 321, UInt64Val = 123456789000L, SInt32Val = -100, SInt64Val = -923456789000L, Fixed32Val = 200, Fixed64Val = 223456789000L, SFixed32Val = -523456789, SFixed64Val = -523456789000L, BoolVal = true, StringVal = "qwe 123 !@# йцу", BytesVal = ByteString.CopyFrom(new byte[] { 1, 2, 100, 255, 3 }) }; t.DoubleArr.Add(-1.234e56); t.DoubleArr.Add(1.2); t.DoubleArr.Add(3); t.FloatArr.Add(-5.5F); t.FloatArr.Add(1.2F); t.FloatArr.Add(3F); t.Int32Arr.Add(1); t.Int32Arr.Add(-2); t.Int32Arr.Add(int.MaxValue); t.Int64Arr.Add(-1); t.Int64Arr.Add(2); t.Int64Arr.Add(long.MaxValue); t.UInt32Arr.Add(1); t.UInt32Arr.Add(0); t.UInt32Arr.Add(uint.MaxValue); t.UInt64Arr.Add(10000); t.UInt64Arr.Add(ulong.MaxValue); t.UInt64Arr.Add(2); t.SInt32Arr.Add(10000); t.SInt32Arr.Add(int.MinValue); t.SInt32Arr.Add(3); t.SInt64Arr.Add(-1234567890123); t.SInt64Arr.Add(long.MinValue); t.SInt64Arr.Add(0); t.Fixed32Arr.Add(123456); t.Fixed32Arr.Add(int.MaxValue); t.Fixed32Arr.Add(0); t.Fixed64Arr.Add(1234567890123); t.Fixed64Arr.Add(0); t.Fixed64Arr.Add(long.MaxValue); t.SFixed32Arr.Add(-123456); t.SFixed32Arr.Add(int.MaxValue); t.SFixed32Arr.Add(int.MinValue); t.SFixed64Arr.Add(-123456); t.SFixed64Arr.Add(long.MaxValue); t.SFixed64Arr.Add(long.MinValue); t.BoolArr.Add(true); t.BoolArr.Add(true); t.BoolArr.Add(false); t.StringArr.Add(""); t.StringArr.Add("qwe 123 !@# йцу"); t.StringArr.Add("qwerty"); t.BytesArr.Add(ByteString.CopyFrom(new byte[] { 1, 2, 3 })); t.BytesArr.Add(ByteString.CopyFrom(new byte[] { 1, 2, 100, 255, 3 })); t.BytesArr.Add(ByteString.CopyFrom(new byte[] { 0, 0, 0 })); t.DoublePacked.Add(-1.234e56); t.DoublePacked.Add(double.MinValue); t.DoublePacked.Add(double.MaxValue); t.FloatPacked.Add(-5.5F); t.FloatPacked.Add(1.2F); t.FloatPacked.Add(3F); t.Int32Packed.Add(1); t.Int32Packed.Add(-2); t.Int32Packed.Add(int.MinValue); t.Int64Packed.Add(-1); t.Int64Packed.Add(2); t.Int64Packed.Add(long.MaxValue); t.UInt32Packed.Add(10); t.UInt32Packed.Add(0); t.UInt32Packed.Add(uint.MaxValue); t.UInt64Packed.Add(0); t.UInt64Packed.Add(ulong.MaxValue); t.UInt64Packed.Add(2); t.SInt32Packed.Add(10000); t.SInt32Packed.Add(int.MaxValue); t.SInt32Packed.Add(0); t.SInt64Packed.Add(-1234567890123); t.SInt64Packed.Add(long.MinValue); t.SInt64Packed.Add(0); t.Fixed32Packed.Add(123456); t.Fixed32Packed.Add(int.MaxValue); t.Fixed32Packed.Add(0); t.Fixed64Packed.Add(1234567890123); t.Fixed64Packed.Add(0); t.Fixed64Packed.Add(long.MaxValue); t.SFixed32Packed.Add(-123456); t.SFixed32Packed.Add(0); t.SFixed32Packed.Add(int.MinValue); t.SFixed64Packed.Add(-123456); t.SFixed64Packed.Add(long.MaxValue); t.SFixed64Packed.Add(0); t.BoolPacked.Add(false); t.BoolPacked.Add(true); t.BoolPacked.Add(true); return t; }