aboutsummaryrefslogtreecommitdiffhomepage
path: root/csharp/src/Google.Protobuf.Test/IssuesTest.cs
diff options
context:
space:
mode:
authorGravatar Jon Skeet <jonskeet@google.com>2017-10-24 14:14:15 +0100
committerGravatar Jon Skeet <skeet@pobox.com>2017-10-31 17:11:40 -0700
commitcbe250591fca9d2e776776be065a72c5550a5556 (patch)
treeb9b6b3de8fe8af9aaa9238b40611bf09f8f87b65 /csharp/src/Google.Protobuf.Test/IssuesTest.cs
parent6dd82243932e929331f3808742b191c85a353461 (diff)
Fix merging with message-valued oneof
If messages A and B have the same oneof case, which is a message type, and we merge B into A, those sub-messages should be merged. Fixes #3200. Note that I haven't regenerated all the code, as some of the protos have been changed, breaking generation.
Diffstat (limited to 'csharp/src/Google.Protobuf.Test/IssuesTest.cs')
-rw-r--r--csharp/src/Google.Protobuf.Test/IssuesTest.cs14
1 files changed, 13 insertions, 1 deletions
diff --git a/csharp/src/Google.Protobuf.Test/IssuesTest.cs b/csharp/src/Google.Protobuf.Test/IssuesTest.cs
index a38d6b08..2caf80a9 100644
--- a/csharp/src/Google.Protobuf.Test/IssuesTest.cs
+++ b/csharp/src/Google.Protobuf.Test/IssuesTest.cs
@@ -33,7 +33,7 @@
using Google.Protobuf.Reflection;
using UnitTest.Issues.TestProtos;
using NUnit.Framework;
-
+using static UnitTest.Issues.TestProtos.OneofMerging.Types;
namespace Google.Protobuf
{
@@ -78,5 +78,17 @@ namespace Google.Protobuf
Assert.AreEqual("{ \"name\": \"test\", \"desc\": \"test2\", \"exid\": \"test3\" }",
JsonFormatter.Default.Format(message));
}
+
+ [Test]
+ public void OneofMerging()
+ {
+ var message1 = new OneofMerging { Nested = new Nested { X = 10 } };
+ var message2 = new OneofMerging { Nested = new Nested { Y = 20 } };
+ var expected = new OneofMerging { Nested = new Nested { X = 10, Y = 20 } };
+
+ var merged = message1.Clone();
+ merged.MergeFrom(message2);
+ Assert.AreEqual(expected, merged);
+ }
}
}