diff options
Diffstat (limited to 'csharp/ProtocolBuffers.Test/TestUtil.cs')
-rw-r--r-- | csharp/ProtocolBuffers.Test/TestUtil.cs | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/csharp/ProtocolBuffers.Test/TestUtil.cs b/csharp/ProtocolBuffers.Test/TestUtil.cs index 6e3b9f18..c0cbd1b6 100644 --- a/csharp/ProtocolBuffers.Test/TestUtil.cs +++ b/csharp/ProtocolBuffers.Test/TestUtil.cs @@ -129,6 +129,9 @@ namespace Google.ProtocolBuffers { registry.Add(UnitTestProtoFile.DefaultCordExtension); } + internal static string ReadTextFromFile(string filePath) { + return ReadBytesFromFile(filePath).ToStringUtf8(); + } internal static ByteString ReadBytesFromFile(String filename) { byte[] data = File.ReadAllBytes(Path.Combine(TestDataDirectory, filename)); @@ -1334,5 +1337,16 @@ namespace Google.ProtocolBuffers { Assert.AreEqual("abc", message.GetExtension(UnitTestProtoFile.DefaultStringPieceExtension)); Assert.AreEqual("123", message.GetExtension(UnitTestProtoFile.DefaultCordExtension)); } + + /// <summary> + /// Helper to construct a byte array from a bunch of bytes. + /// </summary> + internal static byte[] Bytes(params byte[] bytesAsInts) { + byte[] bytes = new byte[bytesAsInts.Length]; + for (int i = 0; i < bytesAsInts.Length; i++) { + bytes[i] = (byte)bytesAsInts[i]; + } + return bytes; + } } } |