aboutsummaryrefslogtreecommitdiff
path: root/src/ProtocolBuffers.Test/WireFormatTest.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/ProtocolBuffers.Test/WireFormatTest.cs')
-rw-r--r--src/ProtocolBuffers.Test/WireFormatTest.cs40
1 files changed, 36 insertions, 4 deletions
diff --git a/src/ProtocolBuffers.Test/WireFormatTest.cs b/src/ProtocolBuffers.Test/WireFormatTest.cs
index 891cf357..b519d7a7 100644
--- a/src/ProtocolBuffers.Test/WireFormatTest.cs
+++ b/src/ProtocolBuffers.Test/WireFormatTest.cs
@@ -63,11 +63,19 @@ namespace Google.ProtocolBuffers {
}
[Test]
+ public void SerializationPacked() {
+ TestPackedTypes message = TestUtil.GetPackedSet();
+ ByteString rawBytes = message.ToByteString();
+ Assert.AreEqual(rawBytes.Length, message.SerializedSize);
+ TestPackedTypes message2 = TestPackedTypes.ParseFrom(rawBytes);
+ TestUtil.AssertPackedFieldsSet(message2);
+ }
+
+ [Test]
public void SerializeExtensions() {
// TestAllTypes and TestAllExtensions should have compatible wire formats,
- // so if we serealize a TestAllExtensions then parse it as TestAllTypes
+ // so if we serialize a TestAllExtensions then parse it as TestAllTypes
// it should work.
-
TestAllExtensions message = TestUtil.GetAllExtensionsSet();
ByteString rawBytes = message.ToByteString();
Assert.AreEqual(rawBytes.Length, message.SerializedSize);
@@ -78,6 +86,19 @@ namespace Google.ProtocolBuffers {
}
[Test]
+ public void SerializePackedExtensions() {
+ // TestPackedTypes and TestPackedExtensions should have compatible wire
+ // formats; check that they serialize to the same string.
+ TestPackedExtensions message = TestUtil.GetPackedExtensionsSet();
+ ByteString rawBytes = message.ToByteString();
+
+ TestPackedTypes message2 = TestUtil.GetPackedSet();
+ ByteString rawBytes2 = message2.ToByteString();
+
+ Assert.AreEqual(rawBytes, rawBytes2);
+ }
+
+ [Test]
public void ParseExtensions() {
// TestAllTypes and TestAllExtensions should have compatible wire formats,
// so if we serealize a TestAllTypes then parse it as TestAllExtensions
@@ -90,13 +111,24 @@ namespace Google.ProtocolBuffers {
TestUtil.RegisterAllExtensions(registry);
registry = registry.AsReadOnly();
- TestAllExtensions message2 =
- TestAllExtensions.ParseFrom(rawBytes, registry);
+ TestAllExtensions message2 = TestAllExtensions.ParseFrom(rawBytes, registry);
TestUtil.AssertAllExtensionsSet(message2);
}
[Test]
+ public void ParsePackedExtensions() {
+ // Ensure that packed extensions can be properly parsed.
+ TestPackedExtensions message = TestUtil.GetPackedExtensionsSet();
+ ByteString rawBytes = message.ToByteString();
+
+ ExtensionRegistry registry = TestUtil.CreateExtensionRegistry();
+
+ TestPackedExtensions message2 = TestPackedExtensions.ParseFrom(rawBytes, registry);
+ TestUtil.AssertPackedExtensionsSet(message2);
+ }
+
+ [Test]
public void ExtensionsSerializedSize() {
Assert.AreEqual(TestUtil.GetAllSet().SerializedSize, TestUtil.GetAllExtensionsSet().SerializedSize);
}