encoding/jsonpb,textpb: fix handling of duplicate oneof fields

Unmarshaling should fail if multiple fields in the same oneof exists in
the input.

Change-Id: I76efd88681a50c18f3eaf770c9eb48727efb412b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/170517
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
diff --git a/encoding/jsonpb/decode_test.go b/encoding/jsonpb/decode_test.go
index 587b2b4..9d50ac1 100644
--- a/encoding/jsonpb/decode_test.go
+++ b/encoding/jsonpb/decode_test.go
@@ -678,6 +678,26 @@
 			},
 		},
 	}, {
+		desc:         "oneof set to more than one field",
+		inputMessage: &pb3.Oneofs{},
+		inputText: `{
+  "oneofEnum": "ZERO",
+  "oneofString": "hello"
+}`,
+		wantErr: true,
+	}, {
+		desc:         "oneof set to null and value",
+		inputMessage: &pb3.Oneofs{},
+		inputText: `{
+  "oneofEnum": "ZERO",
+  "oneofString": null
+}`,
+		wantMessage: &pb3.Oneofs{
+			Union: &pb3.Oneofs_OneofEnum{
+				OneofEnum: pb3.Enum_ZERO,
+			},
+		},
+	}, {
 		desc:         "repeated null fields",
 		inputMessage: &pb2.Repeats{},
 		inputText: `{