aboutsummaryrefslogtreecommitdiff
path: root/csharp/ProtocolBuffers.Test
diff options
context:
space:
mode:
authorJon Skeet <skeet@pobox.com>2008-08-14 20:35:27 +0100
committerJon Skeet <skeet@pobox.com>2008-08-14 20:35:27 +0100
commita80a37ccd5c1d52efede7eaf3c4cc5b69bea15d7 (patch)
tree86fa2dbc45504618445ea38c92a10633f514b3cb /csharp/ProtocolBuffers.Test
parentf26f8dce0279b3cd0ee9708bfca322be5c19d4f7 (diff)
downloadprotobuf-a80a37ccd5c1d52efede7eaf3c4cc5b69bea15d7.tar.gz
protobuf-a80a37ccd5c1d52efede7eaf3c4cc5b69bea15d7.tar.bz2
protobuf-a80a37ccd5c1d52efede7eaf3c4cc5b69bea15d7.zip
Tidying up, and a couple of extra tests.
Diffstat (limited to 'csharp/ProtocolBuffers.Test')
-rw-r--r--csharp/ProtocolBuffers.Test/CodedInputStreamTest.cs52
-rw-r--r--csharp/ProtocolBuffers.Test/ReflectionTester.cs1
2 files changed, 25 insertions, 28 deletions
diff --git a/csharp/ProtocolBuffers.Test/CodedInputStreamTest.cs b/csharp/ProtocolBuffers.Test/CodedInputStreamTest.cs
index 46d0f05b..24b3a732 100644
--- a/csharp/ProtocolBuffers.Test/CodedInputStreamTest.cs
+++ b/csharp/ProtocolBuffers.Test/CodedInputStreamTest.cs
@@ -201,56 +201,54 @@ namespace Google.ProtocolBuffers {
}
}
- /* TODO(jonskeet): Reinstate this when protoc is ready
- public void testSkipWholeMessage() throws Exception {
- TestAllTypes message = TestUtil.getAllSet();
- byte[] rawBytes = message.toByteArray();
+ [Test]
+ public void SkipWholeMessage() {
+ TestAllTypes message = TestUtil.GetAllSet();
+ byte[] rawBytes = message.ToByteArray();
// Create two parallel inputs. Parse one as unknown fields while using
// skipField() to skip each field on the other. Expect the same tags.
- CodedInputStream input1 = CodedInputStream.newInstance(rawBytes);
- CodedInputStream input2 = CodedInputStream.newInstance(rawBytes);
- UnknownFieldSet.Builder unknownFields = UnknownFieldSet.newBuilder();
+ CodedInputStream input1 = CodedInputStream.CreateInstance(rawBytes);
+ CodedInputStream input2 = CodedInputStream.CreateInstance(rawBytes);
+ UnknownFieldSet.Builder unknownFields = UnknownFieldSet.CreateBuilder();
while (true) {
- int tag = input1.readTag();
- assertEquals(tag, input2.readTag());
+ uint tag = input1.ReadTag();
+ Assert.AreEqual(tag, input2.ReadTag());
if (tag == 0) {
break;
}
- unknownFields.mergeFieldFrom(tag, input1);
- input2.skipField(tag);
+ unknownFields.MergeFieldFrom(tag, input1);
+ input2.SkipField(tag);
}
- }*/
+ }
- /* TODO(jonskeet): Reinstate this when protoc is ready
- public void testReadHugeBlob() throws Exception {
+ public void ReadHugeBlob() {
// Allocate and initialize a 1MB blob.
byte[] blob = new byte[1 << 20];
- for (int i = 0; i < blob.length; i++) {
+ for (int i = 0; i < blob.Length; i++) {
blob[i] = (byte)i;
}
// Make a message containing it.
- TestAllTypes.Builder builder = TestAllTypes.newBuilder();
- TestUtil.setAllFields(builder);
- builder.setOptionalBytes(ByteString.copyFrom(blob));
- TestAllTypes message = builder.build();
+ TestAllTypes.Builder builder = TestAllTypes.CreateBuilder();
+ TestUtil.SetAllFields(builder);
+ builder.SetOptionalBytes(ByteString.CopyFrom(blob));
+ TestAllTypes message = builder.Build();
// Serialize and parse it. Make sure to parse from an InputStream, not
// directly from a ByteString, so that CodedInputStream uses buffered
// reading.
- TestAllTypes message2 =
- TestAllTypes.parseFrom(message.toByteString().newInput());
+ TestAllTypes message2 = TestAllTypes.ParseFrom(message.ToByteString().CreateCodedInput());
- assertEquals(message.getOptionalBytes(), message2.getOptionalBytes());
+ Assert.AreEqual(message.OptionalBytes, message2.OptionalBytes);
// Make sure all the other fields were parsed correctly.
- TestAllTypes message3 = TestAllTypes.newBuilder(message2)
- .setOptionalBytes(TestUtil.getAllSet().getOptionalBytes())
- .build();
- TestUtil.assertAllFieldsSet(message3);
- }*/
+ TestAllTypes message3 = TestAllTypes.CreateBuilder(message2)
+ .SetOptionalBytes(TestUtil.GetAllSet().OptionalBytes)
+ .Build();
+ TestUtil.AssertAllFieldsSet(message3);
+ }
[Test]
public void ReadMaliciouslyLargeBlob() {
diff --git a/csharp/ProtocolBuffers.Test/ReflectionTester.cs b/csharp/ProtocolBuffers.Test/ReflectionTester.cs
index 67c26106..c0e4af39 100644
--- a/csharp/ProtocolBuffers.Test/ReflectionTester.cs
+++ b/csharp/ProtocolBuffers.Test/ReflectionTester.cs
@@ -51,7 +51,6 @@ namespace Google.ProtocolBuffers {
/// then baseDescriptor should be for TestAllExtensions instead, and instead of
/// reading and writing normal fields, the tester will read and write extensions.
/// All of the TestAllExtensions extensions must be registered in the registry.
- /// TODO(jonskeet): Enforce all of these with two factory methods.
/// </summary>
private ReflectionTester(MessageDescriptor baseDescriptor,
ExtensionRegistry extensionRegistry) {