blob: 6cacd805837080434657926abc95ba2929d0bcb7 [file] [log] [blame]
Jon Skeetf34d37a2015-06-30 13:16:20 +01001#region Copyright notice and license
2// Protocol Buffers - Google's data interchange format
3// Copyright 2015 Google Inc. All rights reserved.
Jon Skeetf34d37a2015-06-30 13:16:20 +01004//
Joshua Haberman8c05a642023-09-08 17:13:18 -07005// 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
Jon Skeetf34d37a2015-06-30 13:16:20 +01008#endregion
9
10using NUnit.Framework;
11
12namespace Google.Protobuf
13{
14 internal static class CodedInputStreamExtensions
15 {
16 public static void AssertNextTag(this CodedInputStream input, uint expectedTag)
17 {
Jon Skeetff334a62015-08-05 11:23:38 +010018 uint tag = input.ReadTag();
Jon Skeetf34d37a2015-06-30 13:16:20 +010019 Assert.AreEqual(expectedTag, tag);
20 }
21
22 public static T ReadMessage<T>(this CodedInputStream stream, MessageParser<T> parser)
23 where T : IMessage<T>
24 {
25 var message = parser.CreateTemplate();
26 stream.ReadMessage(message);
27 return message;
28 }
29 }
30}