Jon Skeet | f34d37a | 2015-06-30 13:16:20 +0100 | [diff] [blame] | 1 | #region Copyright notice and license |
| 2 | // Protocol Buffers - Google's data interchange format |
| 3 | // Copyright 2015 Google Inc. All rights reserved. |
Jon Skeet | f34d37a | 2015-06-30 13:16:20 +0100 | [diff] [blame] | 4 | // |
Joshua Haberman | 8c05a64 | 2023-09-08 17:13:18 -0700 | [diff] [blame] | 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 |
Jon Skeet | f34d37a | 2015-06-30 13:16:20 +0100 | [diff] [blame] | 8 | #endregion |
| 9 | |
| 10 | using NUnit.Framework; |
| 11 | |
| 12 | namespace Google.Protobuf |
| 13 | { |
| 14 | internal static class CodedInputStreamExtensions |
| 15 | { |
| 16 | public static void AssertNextTag(this CodedInputStream input, uint expectedTag) |
| 17 | { |
Jon Skeet | ff334a6 | 2015-08-05 11:23:38 +0100 | [diff] [blame] | 18 | uint tag = input.ReadTag(); |
Jon Skeet | f34d37a | 2015-06-30 13:16:20 +0100 | [diff] [blame] | 19 | 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 | } |