aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp
diff options
context:
space:
mode:
authorGravatar Jon Skeet <skeet@pobox.com>2008-08-14 20:35:27 +0100
committerGravatar Jon Skeet <skeet@pobox.com>2008-08-14 20:35:27 +0100
commita80a37ccd5c1d52efede7eaf3c4cc5b69bea15d7 (patch)
tree86fa2dbc45504618445ea38c92a10633f514b3cb /csharp
parentf26f8dce0279b3cd0ee9708bfca322be5c19d4f7 (diff)
Tidying up, and a couple of extra tests.
Diffstat (limited to 'csharp')
-rw-r--r--csharp/ProtocolBuffers.Test/CodedInputStreamTest.cs52
-rw-r--r--csharp/ProtocolBuffers.Test/ReflectionTester.cs1
-rw-r--r--csharp/ProtocolBuffers/CodedInputStream.cs2
-rw-r--r--csharp/ProtocolBuffers/DynamicMessage.cs1
-rw-r--r--csharp/ProtocolBuffers/ExtendableBuilder.cs6
5 files changed, 28 insertions, 34 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) {
diff --git a/csharp/ProtocolBuffers/CodedInputStream.cs b/csharp/ProtocolBuffers/CodedInputStream.cs
index d9dbc217..fd6f1de7 100644
--- a/csharp/ProtocolBuffers/CodedInputStream.cs
+++ b/csharp/ProtocolBuffers/CodedInputStream.cs
@@ -102,7 +102,7 @@ namespace Google.ProtocolBuffers {
}
#endregion
- #region Uncategorised (TODO: Fix this!)
+ #region Validation
/// <summary>
/// Verifies that the last call to ReadTag() returned the given tag value.
/// This is used to verify that a nested group ended with the correct
diff --git a/csharp/ProtocolBuffers/DynamicMessage.cs b/csharp/ProtocolBuffers/DynamicMessage.cs
index 9690981e..f0f4cde1 100644
--- a/csharp/ProtocolBuffers/DynamicMessage.cs
+++ b/csharp/ProtocolBuffers/DynamicMessage.cs
@@ -8,7 +8,6 @@ namespace Google.ProtocolBuffers {
/// <summary>
/// An implementation of IMessage that can represent arbitrary types, given a MessageaDescriptor.
- /// TODO: Implement appropriate generics.
/// </summary>
public class DynamicMessage : AbstractMessage<DynamicMessage, DynamicMessage.Builder> {
diff --git a/csharp/ProtocolBuffers/ExtendableBuilder.cs b/csharp/ProtocolBuffers/ExtendableBuilder.cs
index b55d4b99..3cc43944 100644
--- a/csharp/ProtocolBuffers/ExtendableBuilder.cs
+++ b/csharp/ProtocolBuffers/ExtendableBuilder.cs
@@ -95,8 +95,7 @@ namespace Google.ProtocolBuffers {
set {
if (field.IsExtension) {
ExtendableMessage<TMessage, TBuilder> message = MessageBeingBuilt;
- // TODO(jonskeet): Figure out how to call this!
- // message.VerifyExtensionContainingType(field);
+ message.VerifyContainingType(field);
message.Extensions[field, index] = value;
} else {
base[field, index] = value;
@@ -109,8 +108,7 @@ namespace Google.ProtocolBuffers {
set {
if (field.IsExtension) {
ExtendableMessage<TMessage, TBuilder> message = MessageBeingBuilt;
- // TODO(jonskeet): Figure out how to call this!
- // message.VerifyExtensionContainingType(field);
+ message.VerifyContainingType(field);
message.Extensions[field] = value;
} else {
base[field] = value;