public void TestRoundTripRaw() { var stream = new MemoryStream(); var codedOutput = CodedOutputStream.CreateInstance(stream); codec.ValueWriter(codedOutput, sampleValue); codedOutput.Flush(); stream.Position = 0; var codedInput = CodedInputStream.CreateInstance(stream); Assert.AreEqual(sampleValue, codec.ValueReader(codedInput)); Assert.IsTrue(codedInput.IsAtEnd); }
public void WriteTo(ref WriteContext ctx) { ctx.WriteTag(codec.Tag); codec.ValueWriter(ref ctx, field); if (codec.EndTag != 0) { ctx.WriteTag(codec.EndTag); } }
public void WriteTo(CodedOutputStream output) { output.WriteTag(codec.Tag); codec.ValueWriter(output, field); if (codec.EndTag != 0) { output.WriteTag(codec.EndTag); } }
public void TestRoundTripRaw() { var stream = new MemoryStream(); var codedOutput = new CodedOutputStream(stream); WriteContext.Initialize(codedOutput, out WriteContext ctx); try { // only write the value using the codec codec.ValueWriter(ref ctx, sampleValue); } finally { ctx.CopyStateTo(codedOutput); } codedOutput.Flush(); stream.Position = 0; var codedInput = new CodedInputStream(stream); Assert.AreEqual(sampleValue, codec.Read(codedInput)); Assert.IsTrue(codedInput.IsAtEnd); }