Commit a713b730 authored by Yilun Chong's avatar Yilun Chong Committed by GitHub

Merge pull request #3281 from BSBandme/ConformanceTestYilunChong

Proto2 test message support to conformance test
parents f15185d3 bceb830c
...@@ -134,6 +134,7 @@ conformance/Google/ ...@@ -134,6 +134,7 @@ conformance/Google/
conformance/Protobuf_test_messages/ conformance/Protobuf_test_messages/
conformance/conformance-php conformance/conformance-php
conformance/conformance-php-c conformance/conformance-php-c
conformance/*.class
# php test output # php test output
composer.lock composer.lock
......
This diff is collapsed.
...@@ -4,6 +4,11 @@ conformance_protoc_inputs = \ ...@@ -4,6 +4,11 @@ conformance_protoc_inputs = \
conformance.proto \ conformance.proto \
$(top_srcdir)/src/google/protobuf/test_messages_proto3.proto $(top_srcdir)/src/google/protobuf/test_messages_proto3.proto
# proto2 input files, should be separated with proto3, as we
# can't generate proto2 files for ruby, php and objc
conformance_proto2_protoc_inputs = \
$(top_srcdir)/src/google/protobuf/test_messages_proto2.proto
well_known_type_protoc_inputs = \ well_known_type_protoc_inputs = \
$(top_srcdir)/src/google/protobuf/any.proto \ $(top_srcdir)/src/google/protobuf/any.proto \
$(top_srcdir)/src/google/protobuf/duration.proto \ $(top_srcdir)/src/google/protobuf/duration.proto \
...@@ -64,6 +69,7 @@ other_language_protoc_outputs = \ ...@@ -64,6 +69,7 @@ other_language_protoc_outputs = \
com/google/protobuf/ValueOrBuilder.java \ com/google/protobuf/ValueOrBuilder.java \
com/google/protobuf/WrappersProto.java \ com/google/protobuf/WrappersProto.java \
com/google/protobuf_test_messages/proto3/TestMessagesProto3.java \ com/google/protobuf_test_messages/proto3/TestMessagesProto3.java \
com/google/protobuf_test_messages/proto2/TestMessagesProto2.java \
google/protobuf/any.pb.cc \ google/protobuf/any.pb.cc \
google/protobuf/any.pb.h \ google/protobuf/any.pb.h \
google/protobuf/any.rb \ google/protobuf/any.rb \
...@@ -84,8 +90,11 @@ other_language_protoc_outputs = \ ...@@ -84,8 +90,11 @@ other_language_protoc_outputs = \
google/protobuf/TestMessagesProto3.pbobjc.m \ google/protobuf/TestMessagesProto3.pbobjc.m \
google/protobuf/test_messages_proto3.pb.cc \ google/protobuf/test_messages_proto3.pb.cc \
google/protobuf/test_messages_proto3.pb.h \ google/protobuf/test_messages_proto3.pb.h \
google/protobuf/test_messages_proto2.pb.cc \
google/protobuf/test_messages_proto2.pb.h \
google/protobuf/test_messages_proto3_pb.rb \ google/protobuf/test_messages_proto3_pb.rb \
google/protobuf/test_messages_proto3_pb2.py \ google/protobuf/test_messages_proto3_pb2.py \
google/protobuf/test_messages_proto2_pb2.py \
google/protobuf/timestamp.pb.cc \ google/protobuf/timestamp.pb.cc \
google/protobuf/timestamp.pb.h \ google/protobuf/timestamp.pb.h \
google/protobuf/timestamp.rb \ google/protobuf/timestamp.rb \
...@@ -198,7 +207,7 @@ conformance_test_runner_SOURCES = conformance_test.h conformance_test.cc \ ...@@ -198,7 +207,7 @@ conformance_test_runner_SOURCES = conformance_test.h conformance_test.cc \
conformance_test_runner.cc \ conformance_test_runner.cc \
third_party/jsoncpp/json.h \ third_party/jsoncpp/json.h \
third_party/jsoncpp/jsoncpp.cpp third_party/jsoncpp/jsoncpp.cpp
nodist_conformance_test_runner_SOURCES = conformance.pb.cc google/protobuf/test_messages_proto3.pb.cc nodist_conformance_test_runner_SOURCES = conformance.pb.cc google/protobuf/test_messages_proto3.pb.cc google/protobuf/test_messages_proto2.pb.cc
conformance_test_runner_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir) conformance_test_runner_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir)
conformance_test_runner_CXXFLAGS = -std=c++11 conformance_test_runner_CXXFLAGS = -std=c++11
# Explicit deps beacuse BUILT_SOURCES are only done before a "make all/check" # Explicit deps beacuse BUILT_SOURCES are only done before a "make all/check"
...@@ -208,7 +217,7 @@ conformance_test_runner-conformance_test_runner.$(OBJEXT): conformance.pb.h ...@@ -208,7 +217,7 @@ conformance_test_runner-conformance_test_runner.$(OBJEXT): conformance.pb.h
conformance_cpp_LDADD = $(top_srcdir)/src/libprotobuf.la conformance_cpp_LDADD = $(top_srcdir)/src/libprotobuf.la
conformance_cpp_SOURCES = conformance_cpp.cc conformance_cpp_SOURCES = conformance_cpp.cc
nodist_conformance_cpp_SOURCES = conformance.pb.cc google/protobuf/test_messages_proto3.pb.cc nodist_conformance_cpp_SOURCES = conformance.pb.cc google/protobuf/test_messages_proto3.pb.cc google/protobuf/test_messages_proto2.pb.cc
conformance_cpp_CPPFLAGS = -I$(top_srcdir)/src conformance_cpp_CPPFLAGS = -I$(top_srcdir)/src
# Explicit dep beacuse BUILT_SOURCES are only done before a "make all/check" # Explicit dep beacuse BUILT_SOURCES are only done before a "make all/check"
# so a direct "make test_cpp" could fail if parallel enough. # so a direct "make test_cpp" could fail if parallel enough.
...@@ -242,8 +251,9 @@ google-protobuf: ...@@ -242,8 +251,9 @@ google-protobuf:
if USE_EXTERNAL_PROTOC if USE_EXTERNAL_PROTOC
# Some implementations include pre-generated versions of well-known types. # Some implementations include pre-generated versions of well-known types.
protoc_middleman: $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) google-protobuf protoc_middleman: $(conformance_protoc_inputs) $(conformance_proto2_protoc_inputs) $(well_known_type_protoc_inputs) google-protobuf
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --objc_out=. --python_out=. --php_out=. --js_out=import_style=commonjs,binary:. $(conformance_protoc_inputs) $(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --objc_out=. --python_out=. --php_out=. --js_out=import_style=commonjs,binary:. $(conformance_protoc_inputs)
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --python_out=. --js_out=import_style=commonjs,binary:. $(conformance_proto2_protoc_inputs)
$(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --python_out=. --php_out=. --js_out=import_style=commonjs,binary:google-protobuf $(well_known_type_protoc_inputs) $(PROTOC) -I$(srcdir) -I$(top_srcdir) --cpp_out=. --java_out=. --ruby_out=. --python_out=. --php_out=. --js_out=import_style=commonjs,binary:google-protobuf $(well_known_type_protoc_inputs)
## $(PROTOC) -I$(srcdir) -I$(top_srcdir) --java_out=lite:lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) ## $(PROTOC) -I$(srcdir) -I$(top_srcdir) --java_out=lite:lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs)
touch protoc_middleman touch protoc_middleman
...@@ -253,8 +263,9 @@ else ...@@ -253,8 +263,9 @@ else
# We have to cd to $(srcdir) before executing protoc because $(protoc_inputs) is # We have to cd to $(srcdir) before executing protoc because $(protoc_inputs) is
# relative to srcdir, which may not be the same as the current directory when # relative to srcdir, which may not be the same as the current directory when
# building out-of-tree. # building out-of-tree.
protoc_middleman: $(top_srcdir)/src/protoc$(EXEEXT) $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) google-protobuf protoc_middleman: $(top_srcdir)/src/protoc$(EXEEXT) $(conformance_protoc_inputs) $(conformance_proto2_protoc_inputs) $(well_known_type_protoc_inputs) google-protobuf
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --objc_out=$$oldpwd --python_out=$$oldpwd --php_out=$$oldpwd --js_out=import_style=commonjs,binary:$$oldpwd $(conformance_protoc_inputs) ) oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --objc_out=$$oldpwd --python_out=$$oldpwd --php_out=$$oldpwd --js_out=import_style=commonjs,binary:$$oldpwd $(conformance_protoc_inputs) )
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --python_out=$$oldpwd --js_out=import_style=commonjs,binary:$$oldpwd $(conformance_proto2_protoc_inputs) )
oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --python_out=$$oldpwd --php_out=$$oldpwd --js_out=import_style=commonjs,binary:$$oldpwd/google-protobuf $(well_known_type_protoc_inputs) ) oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --cpp_out=$$oldpwd --java_out=$$oldpwd --ruby_out=$$oldpwd --python_out=$$oldpwd --php_out=$$oldpwd --js_out=import_style=commonjs,binary:$$oldpwd/google-protobuf $(well_known_type_protoc_inputs) )
## @mkdir -p lite ## @mkdir -p lite
## oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --java_out=lite:$$oldpwd/lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) ) ## oldpwd=`pwd` && ( cd $(srcdir) && $$oldpwd/../src/protoc$(EXEEXT) -I. -I$(top_srcdir)/src --java_out=lite:$$oldpwd/lite $(conformance_protoc_inputs) $(well_known_type_protoc_inputs) )
...@@ -274,7 +285,7 @@ MAINTAINERCLEANFILES = \ ...@@ -274,7 +285,7 @@ MAINTAINERCLEANFILES = \
Makefile.in Makefile.in
javac_middleman: ConformanceJava.java protoc_middleman $(other_language_protoc_outputs) javac_middleman: ConformanceJava.java protoc_middleman $(other_language_protoc_outputs)
jar=`ls ../java/util/target/*jar-with-dependencies.jar` && javac -classpath ../java/target/classes:$$jar ConformanceJava.java com/google/protobuf/conformance/Conformance.java com/google/protobuf_test_messages/proto3/TestMessagesProto3.java jar=`ls ../java/util/target/*jar-with-dependencies.jar` && javac -classpath ../java/target/classes:$$jar ConformanceJava.java com/google/protobuf/conformance/Conformance.java com/google/protobuf_test_messages/proto3/TestMessagesProto3.java com/google/protobuf_test_messages/proto2/TestMessagesProto2.java
@touch javac_middleman @touch javac_middleman
conformance-java: javac_middleman conformance-java: javac_middleman
......
...@@ -77,6 +77,9 @@ message ConformanceRequest { ...@@ -77,6 +77,9 @@ message ConformanceRequest {
// Which format should the testee serialize its message to? // Which format should the testee serialize its message to?
WireFormat requested_output_format = 3; WireFormat requested_output_format = 3;
// should be set to either "proto2" or "proto3"
string message_type = 4;
} }
// Represents a single test case's output. // Represents a single test case's output.
......
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
#include "conformance.pb.h" #include "conformance.pb.h"
#include <google/protobuf/test_messages_proto3.pb.h> #include <google/protobuf/test_messages_proto3.pb.h>
#include <google/protobuf/test_messages_proto2.pb.h>
#include <google/protobuf/message.h>
#include <google/protobuf/util/json_util.h> #include <google/protobuf/util/json_util.h>
#include <google/protobuf/util/type_resolver_util.h> #include <google/protobuf/util/type_resolver_util.h>
...@@ -41,13 +43,15 @@ using conformance::ConformanceRequest; ...@@ -41,13 +43,15 @@ using conformance::ConformanceRequest;
using conformance::ConformanceResponse; using conformance::ConformanceResponse;
using google::protobuf::Descriptor; using google::protobuf::Descriptor;
using google::protobuf::DescriptorPool; using google::protobuf::DescriptorPool;
using google::protobuf::Message;
using google::protobuf::MessageFactory;
using google::protobuf::internal::scoped_ptr; using google::protobuf::internal::scoped_ptr;
using google::protobuf::util::BinaryToJsonString; using google::protobuf::util::BinaryToJsonString;
using google::protobuf::util::JsonToBinaryString; using google::protobuf::util::JsonToBinaryString;
using google::protobuf::util::NewTypeResolverForDescriptorPool; using google::protobuf::util::NewTypeResolverForDescriptorPool;
using google::protobuf::util::Status; using google::protobuf::util::Status;
using google::protobuf::util::TypeResolver; using google::protobuf::util::TypeResolver;
using protobuf_test_messages::proto3::TestAllTypes; using protobuf_test_messages::proto3::TestAllTypesProto3;
using std::string; using std::string;
static const char kTypeUrlPrefix[] = "type.googleapis.com"; static const char kTypeUrlPrefix[] = "type.googleapis.com";
...@@ -87,17 +91,24 @@ void CheckedWrite(int fd, const void *buf, size_t len) { ...@@ -87,17 +91,24 @@ void CheckedWrite(int fd, const void *buf, size_t len) {
} }
void DoTest(const ConformanceRequest& request, ConformanceResponse* response) { void DoTest(const ConformanceRequest& request, ConformanceResponse* response) {
TestAllTypes test_message; Message *test_message;
const Descriptor *descriptor = DescriptorPool::generated_pool()->FindMessageTypeByName(
request.message_type());
if (!descriptor) {
GOOGLE_LOG(FATAL) << "No such message type: " << request.message_type();
}
test_message = MessageFactory::generated_factory()->GetPrototype(descriptor)->New();
switch (request.payload_case()) { switch (request.payload_case()) {
case ConformanceRequest::kProtobufPayload: case ConformanceRequest::kProtobufPayload: {
if (!test_message.ParseFromString(request.protobuf_payload())) { if (!test_message->ParseFromString(request.protobuf_payload())) {
// Getting parse details would involve something like: // Getting parse details would involve something like:
// http://stackoverflow.com/questions/22121922/how-can-i-get-more-details-about-errors-generated-during-protobuf-parsing-c // http://stackoverflow.com/questions/22121922/how-can-i-get-more-details-about-errors-generated-during-protobuf-parsing-c
response->set_parse_error("Parse error (no more details available)."); response->set_parse_error("Parse error (no more details available).");
return; return;
} }
break; break;
}
case ConformanceRequest::kJsonPayload: { case ConformanceRequest::kJsonPayload: {
string proto_binary; string proto_binary;
...@@ -109,7 +120,7 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) { ...@@ -109,7 +120,7 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) {
return; return;
} }
if (!test_message.ParseFromString(proto_binary)) { if (!test_message->ParseFromString(proto_binary)) {
response->set_runtime_error( response->set_runtime_error(
"Parsing JSON generates invalid proto output."); "Parsing JSON generates invalid proto output.");
return; return;
...@@ -127,14 +138,14 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) { ...@@ -127,14 +138,14 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) {
GOOGLE_LOG(FATAL) << "Unspecified output format"; GOOGLE_LOG(FATAL) << "Unspecified output format";
break; break;
case conformance::PROTOBUF: case conformance::PROTOBUF: {
GOOGLE_CHECK( GOOGLE_CHECK(test_message->SerializeToString(response->mutable_protobuf_payload()));
test_message.SerializeToString(response->mutable_protobuf_payload()));
break; break;
}
case conformance::JSON: { case conformance::JSON: {
string proto_binary; string proto_binary;
GOOGLE_CHECK(test_message.SerializeToString(&proto_binary)); GOOGLE_CHECK(test_message->SerializeToString(&proto_binary));
Status status = BinaryToJsonString(type_resolver, *type_url, proto_binary, Status status = BinaryToJsonString(type_resolver, *type_url, proto_binary,
response->mutable_json_payload()); response->mutable_json_payload());
if (!status.ok()) { if (!status.ok()) {
...@@ -197,7 +208,7 @@ bool DoTestIo() { ...@@ -197,7 +208,7 @@ bool DoTestIo() {
int main() { int main() {
type_resolver = NewTypeResolverForDescriptorPool( type_resolver = NewTypeResolverForDescriptorPool(
kTypeUrlPrefix, DescriptorPool::generated_pool()); kTypeUrlPrefix, DescriptorPool::generated_pool());
type_url = new string(GetTypeUrl(TestAllTypes::descriptor())); type_url = new string(GetTypeUrl(TestAllTypesProto3::descriptor()));
while (1) { while (1) {
if (!DoTestIo()) { if (!DoTestIo()) {
fprintf(stderr, "conformance-cpp: received EOF from test runner " fprintf(stderr, "conformance-cpp: received EOF from test runner "
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
var conformance = require('conformance_pb'); var conformance = require('conformance_pb');
var test_messages_proto3 = require('google/protobuf/test_messages_proto3_pb'); var test_messages_proto3 = require('google/protobuf/test_messages_proto3_pb');
var test_messages_proto2 = require('google/protobuf/test_messages_proto2_pb');
var fs = require('fs'); var fs = require('fs');
var testCount = 0; var testCount = 0;
...@@ -49,14 +50,27 @@ function doTest(request) { ...@@ -49,14 +50,27 @@ function doTest(request) {
} }
switch (request.getPayloadCase()) { switch (request.getPayloadCase()) {
case conformance.ConformanceRequest.PayloadCase.PROTOBUF_PAYLOAD: case conformance.ConformanceRequest.PayloadCase.PROTOBUF_PAYLOAD: {
if (request.getMessageType() == "protobuf_test_messages.proto3.TestAllTypesProto3") {
try { try {
testMessage = test_messages_proto3.TestAllTypes.deserializeBinary( testMessage = test_messages_proto3.TestAllTypesProto3.deserializeBinary(
request.getProtobufPayload()); request.getProtobufPayload());
} catch (err) { } catch (err) {
response.setParseError(err.toString()); response.setParseError(err.toString());
return response; return response;
} }
} else if (request.getMessageType() == "protobuf_test_messages.proto2.TestAllTypesProto2"){
try {
testMessage = test_messages_proto2.TestAllTypesProto2.deserializeBinary(
request.getProtobufPayload());
} catch (err) {
response.setParseError(err.toString());
return response;
}
} else {
throw "Protobuf request doesn\'t have specific payload type";
}
}
case conformance.ConformanceRequest.PayloadCase.JSON_PAYLOAD: case conformance.ConformanceRequest.PayloadCase.JSON_PAYLOAD:
response.setSkipped("JSON not supported."); response.setSkipped("JSON not supported.");
......
...@@ -63,7 +63,7 @@ static NSData *CheckedReadDataOfLength(NSFileHandle *handle, NSUInteger numBytes ...@@ -63,7 +63,7 @@ static NSData *CheckedReadDataOfLength(NSFileHandle *handle, NSUInteger numBytes
static ConformanceResponse *DoTest(ConformanceRequest *request) { static ConformanceResponse *DoTest(ConformanceRequest *request) {
ConformanceResponse *response = [ConformanceResponse message]; ConformanceResponse *response = [ConformanceResponse message];
TestAllTypes *testMessage = nil; TestAllTypesProto3 *testMessage = nil;
switch (request.payloadOneOfCase) { switch (request.payloadOneOfCase) {
case ConformanceRequest_Payload_OneOfCase_GPBUnsetOneOfCase: case ConformanceRequest_Payload_OneOfCase_GPBUnsetOneOfCase:
...@@ -71,13 +71,21 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) { ...@@ -71,13 +71,21 @@ static ConformanceResponse *DoTest(ConformanceRequest *request) {
break; break;
case ConformanceRequest_Payload_OneOfCase_ProtobufPayload: { case ConformanceRequest_Payload_OneOfCase_ProtobufPayload: {
if ([request.messageType isEqualToString:@"protobuf_test_messages.proto3.TestAllTypesProto3"]) {
NSError *error = nil; NSError *error = nil;
testMessage = [TestAllTypes parseFromData:request.protobufPayload testMessage = [TestAllTypesProto3 parseFromData:request.protobufPayload
error:&error]; error:&error];
if (!testMessage) { if (!testMessage) {
response.parseError = response.parseError =
[NSString stringWithFormat:@"Parse error: %@", error]; [NSString stringWithFormat:@"Parse error: %@", error];
} }
} else if ([request.messageType isEqualToString:@"protobuf_test_messages.proto2.TestAllTypesProto2"]) {
response.skipped = @"ObjC doesn't support proto2";
break;
} else {
Die(@"Protobuf request doesn't have specific payload type");
break;
}
break; break;
} }
......
...@@ -23,9 +23,9 @@ require_once("Google/Protobuf/StringValue.php"); ...@@ -23,9 +23,9 @@ require_once("Google/Protobuf/StringValue.php");
require_once("Google/Protobuf/UInt64Value.php"); require_once("Google/Protobuf/UInt64Value.php");
require_once("Protobuf_test_messages/Proto3/ForeignMessage.php"); require_once("Protobuf_test_messages/Proto3/ForeignMessage.php");
require_once("Protobuf_test_messages/Proto3/ForeignEnum.php"); require_once("Protobuf_test_messages/Proto3/ForeignEnum.php");
require_once("Protobuf_test_messages/Proto3/TestAllTypes.php"); require_once("Protobuf_test_messages/Proto3/TestAllTypesProto3.php");
require_once("Protobuf_test_messages/Proto3/TestAllTypes_NestedMessage.php"); require_once("Protobuf_test_messages/Proto3/TestAllTypesProto3_NestedMessage.php");
require_once("Protobuf_test_messages/Proto3/TestAllTypes_NestedEnum.php"); require_once("Protobuf_test_messages/Proto3/TestAllTypesProto3_NestedEnum.php");
require_once("GPBMetadata/Conformance.php"); require_once("GPBMetadata/Conformance.php");
require_once("GPBMetadata/Google/Protobuf/Any.php"); require_once("GPBMetadata/Google/Protobuf/Any.php");
...@@ -42,15 +42,22 @@ $test_count = 0; ...@@ -42,15 +42,22 @@ $test_count = 0;
function doTest($request) function doTest($request)
{ {
$test_message = new \Protobuf_test_messages\Proto3\TestAllTypes(); $test_message = new \Protobuf_test_messages\Proto3\TestAllTypesProto3();
$response = new \Conformance\ConformanceResponse(); $response = new \Conformance\ConformanceResponse();
if ($request->getPayload() == "protobuf_payload") { if ($request->getPayload() == "protobuf_payload") {
if ($request->getMessageType() == "protobuf_test_messages.proto3.TestAllTypesProto3") {
try { try {
$test_message->mergeFromString($request->getProtobufPayload()); $test_message->mergeFromString($request->getProtobufPayload());
} catch (Exception $e) { } catch (Exception $e) {
$response->setParseError($e->getMessage()); $response->setParseError($e->getMessage());
return $response; return $response;
} }
} elseif ($request->getMessageType() == "protobuf_test_messages.proto2.TestAllTypesProto2") {
$response->setSkipped("PHP doesn't support proto2");
return $response;
} else {
trigger_error("Protobuf request doesn't have specific payload type", E_USER_ERROR);
}
} elseif ($request->getPayload() == "json_payload") { } elseif ($request->getPayload() == "json_payload") {
try { try {
$test_message->mergeFromJsonString($request->getJsonPayload()); $test_message->mergeFromJsonString($request->getJsonPayload());
......
...@@ -38,9 +38,12 @@ See conformance.proto for more information. ...@@ -38,9 +38,12 @@ See conformance.proto for more information.
import struct import struct
import sys import sys
import os import os
from google.protobuf import descriptor
from google.protobuf import descriptor_pool
from google.protobuf import json_format from google.protobuf import json_format
from google.protobuf import message from google.protobuf import message
from google.protobuf import test_messages_proto3_pb2 from google.protobuf import test_messages_proto3_pb2
from google.protobuf import test_messages_proto2_pb2
import conformance_pb2 import conformance_pb2
sys.stdout = os.fdopen(sys.stdout.fileno(), 'wb', 0) sys.stdout = os.fdopen(sys.stdout.fileno(), 'wb', 0)
...@@ -53,9 +56,17 @@ class ProtocolError(Exception): ...@@ -53,9 +56,17 @@ class ProtocolError(Exception):
pass pass
def do_test(request): def do_test(request):
test_message = test_messages_proto3_pb2.TestAllTypes() isProto3 = (request.message_type == "protobuf_test_messages.proto3.TestAllTypesProto3")
isJson = (request.WhichOneof('payload') == 'json_payload')
isProto2 = (request.message_type == "protobuf_test_messages.proto2.TestAllTypesProto2")
if (not isProto3) and (not isJson) and (not isProto2):
raise ProtocolError("Protobuf request doesn't have specific payload type")
test_message = test_messages_proto2_pb2.TestAllTypesProto2() if isProto2 else \
test_messages_proto3_pb2.TestAllTypesProto3()
response = conformance_pb2.ConformanceResponse() response = conformance_pb2.ConformanceResponse()
test_message = test_messages_proto3_pb2.TestAllTypes()
try: try:
if request.WhichOneof('payload') == 'protobuf_payload': if request.WhichOneof('payload') == 'protobuf_payload':
......
...@@ -37,23 +37,30 @@ $test_count = 0 ...@@ -37,23 +37,30 @@ $test_count = 0
$verbose = false $verbose = false
def do_test(request) def do_test(request)
test_message = ProtobufTestMessages::Proto3::TestAllTypes.new test_message = ProtobufTestMessages::Proto3::TestAllTypesProto3.new
response = Conformance::ConformanceResponse.new response = Conformance::ConformanceResponse.new
begin begin
case request.payload case request.payload
when :protobuf_payload when :protobuf_payload
if request.message_type.eql?('protobuf_test_messages.proto3.TestAllTypesProto3')
begin begin
test_message = ProtobufTestMessages::Proto3::TestAllTypes.decode( test_message = ProtobufTestMessages::Proto3::TestAllTypesProto3.decode(
request.protobuf_payload) request.protobuf_payload)
rescue Google::Protobuf::ParseError => err rescue Google::Protobuf::ParseError => err
response.parse_error = err.message.encode('utf-8') response.parse_error = err.message.encode('utf-8')
return response return response
end end
elsif request.message_type.eql?('protobuf_test_messages.proto2.TestAllTypesProto2')
response.skipped = "Ruby doesn't support proto2"
return response
else
fail "Protobuf request doesn't have specific payload type"
end
when :json_payload when :json_payload
begin begin
test_message = ProtobufTestMessages::Proto3::TestAllTypes.decode_json( test_message = ProtobufTestMessages::Proto3::TestAllTypesProto3.decode_json(
request.json_payload) request.json_payload)
rescue Google::Protobuf::ParseError => err rescue Google::Protobuf::ParseError => err
response.parse_error = err.message.encode('utf-8') response.parse_error = err.message.encode('utf-8')
......
This diff is collapsed.
...@@ -53,7 +53,7 @@ class ConformanceResponse; ...@@ -53,7 +53,7 @@ class ConformanceResponse;
namespace protobuf_test_messages { namespace protobuf_test_messages {
namespace proto3 { namespace proto3 {
class TestAllTypes; class TestAllTypesProto3;
} // namespace proto3 } // namespace proto3
} // namespace protobuf_test_messages } // namespace protobuf_test_messages
...@@ -165,7 +165,8 @@ class ConformanceTestSuite { ...@@ -165,7 +165,8 @@ class ConformanceTestSuite {
const string& input, const string& input,
conformance::WireFormat input_format, conformance::WireFormat input_format,
const string& equivalent_text_format, const string& equivalent_text_format,
conformance::WireFormat requested_output); conformance::WireFormat requested_output,
bool isProto3);
void RunValidJsonTest(const string& test_name, void RunValidJsonTest(const string& test_name,
ConformanceLevel level, ConformanceLevel level,
const string& input_json, const string& input_json,
...@@ -173,15 +174,17 @@ class ConformanceTestSuite { ...@@ -173,15 +174,17 @@ class ConformanceTestSuite {
void RunValidJsonTestWithProtobufInput( void RunValidJsonTestWithProtobufInput(
const string& test_name, const string& test_name,
ConformanceLevel level, ConformanceLevel level,
const protobuf_test_messages::proto3::TestAllTypes& input, const protobuf_test_messages::proto3::TestAllTypesProto3& input,
const string& equivalent_text_format); const string& equivalent_text_format);
void RunValidProtobufTest(const string& test_name, ConformanceLevel level, void RunValidProtobufTest(const string& test_name, ConformanceLevel level,
const string& input_protobuf, const string& input_protobuf,
const string& equivalent_text_format); const string& equivalent_text_format,
bool isProto3);
void RunValidProtobufTestWithMessage( void RunValidProtobufTestWithMessage(
const string& test_name, ConformanceLevel level, const string& test_name, ConformanceLevel level,
const protobuf_test_messages::proto3::TestAllTypes& input, const Message *input,
const string& equivalent_text_format); const string& equivalent_text_format,
bool isProto3);
typedef std::function<bool(const Json::Value&)> Validator; typedef std::function<bool(const Json::Value&)> Validator;
void RunValidJsonTestWithValidator(const string& test_name, void RunValidJsonTestWithValidator(const string& test_name,
...@@ -194,6 +197,10 @@ class ConformanceTestSuite { ...@@ -194,6 +197,10 @@ class ConformanceTestSuite {
void ExpectSerializeFailureForJson(const string& test_name, void ExpectSerializeFailureForJson(const string& test_name,
ConformanceLevel level, ConformanceLevel level,
const string& text_format); const string& text_format);
void ExpectParseFailureForProtoWithProtoVersion (const string& proto,
const string& test_name,
ConformanceLevel level,
bool isProto3);
void ExpectParseFailureForProto(const std::string& proto, void ExpectParseFailureForProto(const std::string& proto,
const std::string& test_name, const std::string& test_name,
ConformanceLevel level); ConformanceLevel level);
...@@ -202,6 +209,9 @@ class ConformanceTestSuite { ...@@ -202,6 +209,9 @@ class ConformanceTestSuite {
ConformanceLevel level); ConformanceLevel level);
void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type); void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type);
void TestIllegalTags(); void TestIllegalTags();
template <class MessageType>
void TestOneofMessage (MessageType &message,
bool isProto3);
void TestValidDataForType( void TestValidDataForType(
google::protobuf::FieldDescriptor::Type, google::protobuf::FieldDescriptor::Type,
std::vector<std::pair<std::string, std::string>> values); std::vector<std::pair<std::string, std::string>> values);
......
...@@ -10,35 +10,46 @@ ...@@ -10,35 +10,46 @@
Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput
Recommended.FieldMaskPathsDontRoundTrip.JsonOutput Recommended.FieldMaskPathsDontRoundTrip.JsonOutput
Recommended.FieldMaskTooManyUnderscore.JsonOutput Recommended.FieldMaskTooManyUnderscore.JsonOutput
Recommended.JsonInput.BoolFieldDoubleQuotedFalse Recommended.Proto3.JsonInput.BoolFieldDoubleQuotedFalse
Recommended.JsonInput.BoolFieldDoubleQuotedTrue Recommended.Proto3.JsonInput.BoolFieldDoubleQuotedTrue
Recommended.JsonInput.FieldMaskInvalidCharacter Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter
Recommended.JsonInput.FieldNameDuplicate Recommended.Proto3.JsonInput.FieldNameDuplicate
Recommended.JsonInput.FieldNameDuplicateDifferentCasing1 Recommended.Proto3.JsonInput.FieldNameDuplicateDifferentCasing1
Recommended.JsonInput.FieldNameDuplicateDifferentCasing2 Recommended.Proto3.JsonInput.FieldNameDuplicateDifferentCasing2
Recommended.JsonInput.FieldNameNotQuoted Recommended.Proto3.JsonInput.FieldNameNotQuoted
Recommended.JsonInput.MapFieldValueIsNull Recommended.Proto3.JsonInput.MapFieldValueIsNull
Recommended.JsonInput.RepeatedFieldMessageElementIsNull Recommended.Proto3.JsonInput.RepeatedFieldMessageElementIsNull
Recommended.JsonInput.RepeatedFieldPrimitiveElementIsNull Recommended.Proto3.JsonInput.RepeatedFieldPrimitiveElementIsNull
Recommended.JsonInput.RepeatedFieldTrailingComma Recommended.Proto3.JsonInput.RepeatedFieldTrailingComma
Recommended.JsonInput.RepeatedFieldTrailingCommaWithNewlines Recommended.Proto3.JsonInput.RepeatedFieldTrailingCommaWithNewlines
Recommended.JsonInput.RepeatedFieldTrailingCommaWithSpace Recommended.Proto3.JsonInput.RepeatedFieldTrailingCommaWithSpace
Recommended.JsonInput.RepeatedFieldTrailingCommaWithSpaceCommaSpace Recommended.Proto3.JsonInput.RepeatedFieldTrailingCommaWithSpaceCommaSpace
Recommended.JsonInput.StringFieldSingleQuoteBoth Recommended.Proto3.JsonInput.StringFieldSingleQuoteBoth
Recommended.JsonInput.StringFieldSingleQuoteKey Recommended.Proto3.JsonInput.StringFieldSingleQuoteKey
Recommended.JsonInput.StringFieldSingleQuoteValue Recommended.Proto3.JsonInput.StringFieldSingleQuoteValue
Recommended.JsonInput.StringFieldUppercaseEscapeLetter Recommended.Proto3.JsonInput.StringFieldUppercaseEscapeLetter
Recommended.JsonInput.TrailingCommaInAnObject Recommended.Proto3.JsonInput.TrailingCommaInAnObject
Recommended.JsonInput.TrailingCommaInAnObjectWithNewlines Recommended.Proto3.JsonInput.TrailingCommaInAnObjectWithNewlines
Recommended.JsonInput.TrailingCommaInAnObjectWithSpace Recommended.Proto3.JsonInput.TrailingCommaInAnObjectWithSpace
Recommended.JsonInput.TrailingCommaInAnObjectWithSpaceCommaSpace Recommended.Proto3.JsonInput.TrailingCommaInAnObjectWithSpaceCommaSpace
Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
Required.ProtobufInput.PrematureEofInPackedField.BOOL Required.Proto3.ProtobufInput.PrematureEofInPackedField.BOOL
Required.ProtobufInput.PrematureEofInPackedField.ENUM Required.Proto3.ProtobufInput.PrematureEofInPackedField.ENUM
Required.ProtobufInput.PrematureEofInPackedField.INT32 Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT32
Required.ProtobufInput.PrematureEofInPackedField.INT64 Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT64
Required.ProtobufInput.PrematureEofInPackedField.SINT32 Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT32
Required.ProtobufInput.PrematureEofInPackedField.SINT64 Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT64
Required.ProtobufInput.PrematureEofInPackedField.UINT32 Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT32
Required.ProtobufInput.PrematureEofInPackedField.UINT64 Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT64
Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
Required.Proto2.ProtobufInput.PrematureEofInPackedField.BOOL
Required.Proto2.ProtobufInput.PrematureEofInPackedField.ENUM
Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT32
Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT64
Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT32
Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT64
Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT32
Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT64
Required.ProtobufInput.IllegalZeroFieldNum_Case_0 Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_0
Required.ProtobufInput.IllegalZeroFieldNum_Case_1 Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_1
Required.ProtobufInput.IllegalZeroFieldNum_Case_2 Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_2
Required.ProtobufInput.IllegalZeroFieldNum_Case_3 Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_3
...@@ -7,39 +7,41 @@ ...@@ -7,39 +7,41 @@
Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput
Recommended.FieldMaskPathsDontRoundTrip.JsonOutput Recommended.FieldMaskPathsDontRoundTrip.JsonOutput
Recommended.FieldMaskTooManyUnderscore.JsonOutput Recommended.FieldMaskTooManyUnderscore.JsonOutput
Recommended.JsonInput.BoolFieldAllCapitalFalse Recommended.Proto3.JsonInput.BoolFieldAllCapitalFalse
Recommended.JsonInput.BoolFieldAllCapitalTrue Recommended.Proto3.JsonInput.BoolFieldAllCapitalTrue
Recommended.JsonInput.BoolFieldCamelCaseFalse Recommended.Proto3.JsonInput.BoolFieldCamelCaseFalse
Recommended.JsonInput.BoolFieldCamelCaseTrue Recommended.Proto3.JsonInput.BoolFieldCamelCaseTrue
Recommended.JsonInput.BoolFieldDoubleQuotedFalse Recommended.Proto3.JsonInput.BoolFieldDoubleQuotedFalse
Recommended.JsonInput.BoolFieldDoubleQuotedTrue Recommended.Proto3.JsonInput.BoolFieldDoubleQuotedTrue
Recommended.JsonInput.BoolMapFieldKeyNotQuoted Recommended.Proto3.JsonInput.BoolMapFieldKeyNotQuoted
Recommended.JsonInput.DoubleFieldInfinityNotQuoted Recommended.Proto3.JsonInput.DoubleFieldInfinityNotQuoted
Recommended.JsonInput.DoubleFieldNanNotQuoted Recommended.Proto3.JsonInput.DoubleFieldNanNotQuoted
Recommended.JsonInput.DoubleFieldNegativeInfinityNotQuoted Recommended.Proto3.JsonInput.DoubleFieldNegativeInfinityNotQuoted
Recommended.JsonInput.FieldMaskInvalidCharacter Recommended.Proto3.JsonInput.FieldMaskInvalidCharacter
Recommended.JsonInput.FieldNameDuplicate Recommended.Proto3.JsonInput.FieldNameDuplicate
Recommended.JsonInput.FieldNameNotQuoted Recommended.Proto3.JsonInput.FieldNameNotQuoted
Recommended.JsonInput.FloatFieldInfinityNotQuoted Recommended.Proto3.JsonInput.FloatFieldInfinityNotQuoted
Recommended.JsonInput.FloatFieldNanNotQuoted Recommended.Proto3.JsonInput.FloatFieldNanNotQuoted
Recommended.JsonInput.FloatFieldNegativeInfinityNotQuoted Recommended.Proto3.JsonInput.FloatFieldNegativeInfinityNotQuoted
Recommended.JsonInput.Int32MapFieldKeyNotQuoted Recommended.Proto3.JsonInput.Int32MapFieldKeyNotQuoted
Recommended.JsonInput.Int64MapFieldKeyNotQuoted Recommended.Proto3.JsonInput.Int64MapFieldKeyNotQuoted
Recommended.JsonInput.JsonWithComments Recommended.Proto3.JsonInput.JsonWithComments
Recommended.JsonInput.StringFieldSingleQuoteBoth Recommended.Proto3.JsonInput.StringFieldSingleQuoteBoth
Recommended.JsonInput.StringFieldSingleQuoteKey Recommended.Proto3.JsonInput.StringFieldSingleQuoteKey
Recommended.JsonInput.StringFieldSingleQuoteValue Recommended.Proto3.JsonInput.StringFieldSingleQuoteValue
Recommended.JsonInput.StringFieldSurrogateInWrongOrder Recommended.Proto3.JsonInput.StringFieldSurrogateInWrongOrder
Recommended.JsonInput.StringFieldUnpairedHighSurrogate Recommended.Proto3.JsonInput.StringFieldUnpairedHighSurrogate
Recommended.JsonInput.StringFieldUnpairedLowSurrogate Recommended.Proto3.JsonInput.StringFieldUnpairedLowSurrogate
Recommended.JsonInput.Uint32MapFieldKeyNotQuoted Recommended.Proto3.JsonInput.Uint32MapFieldKeyNotQuoted
Recommended.JsonInput.Uint64MapFieldKeyNotQuoted Recommended.Proto3.JsonInput.Uint64MapFieldKeyNotQuoted
Required.JsonInput.EnumFieldNotQuoted Required.Proto3.JsonInput.EnumFieldNotQuoted
Required.JsonInput.Int32FieldLeadingZero Required.Proto3.JsonInput.Int32FieldLeadingZero
Required.JsonInput.Int32FieldNegativeWithLeadingZero Required.Proto3.JsonInput.Int32FieldNegativeWithLeadingZero
Required.JsonInput.Int32FieldPlusSign Required.Proto3.JsonInput.Int32FieldPlusSign
Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool
Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
Required.JsonInput.StringFieldNotAString Required.Proto3.JsonInput.StringFieldNotAString
Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
\ No newline at end of file
Required.ProtobufInput.RepeatedScalarSelectsLast.INT32.ProtobufOutput Required.Proto3.ProtobufInput.RepeatedScalarSelectsLast.INT32.ProtobufOutput
Required.ProtobufInput.RepeatedScalarSelectsLast.UINT32.ProtobufOutput Required.Proto3.ProtobufInput.RepeatedScalarSelectsLast.UINT32.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.BOOL.ProtobufOutput Required.Proto3.ProtobufInput.ValidDataRepeated.BOOL.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.DOUBLE.ProtobufOutput Required.Proto3.ProtobufInput.ValidDataRepeated.DOUBLE.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.FIXED32.ProtobufOutput Required.Proto3.ProtobufInput.ValidDataRepeated.FIXED32.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.FIXED64.ProtobufOutput Required.Proto3.ProtobufInput.ValidDataRepeated.FIXED64.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.FLOAT.ProtobufOutput Required.Proto3.ProtobufInput.ValidDataRepeated.FLOAT.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.INT32.ProtobufOutput Required.Proto3.ProtobufInput.ValidDataRepeated.INT32.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.INT64.ProtobufOutput Required.Proto3.ProtobufInput.ValidDataRepeated.INT64.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.SFIXED32.ProtobufOutput Required.Proto3.ProtobufInput.ValidDataRepeated.SFIXED32.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.SFIXED64.ProtobufOutput Required.Proto3.ProtobufInput.ValidDataRepeated.SFIXED64.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.SINT32.ProtobufOutput Required.Proto3.ProtobufInput.ValidDataRepeated.SINT32.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.SINT64.ProtobufOutput Required.Proto3.ProtobufInput.ValidDataRepeated.SINT64.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.UINT32.ProtobufOutput Required.Proto3.ProtobufInput.ValidDataRepeated.UINT32.ProtobufOutput
Required.ProtobufInput.ValidDataRepeated.UINT64.ProtobufOutput Required.Proto3.ProtobufInput.ValidDataRepeated.UINT64.ProtobufOutput
Required.Proto2.ProtobufInput.RepeatedScalarSelectsLast.INT32.ProtobufOutput
Required.Proto2.ProtobufInput.RepeatedScalarSelectsLast.UINT32.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.INT32.ProtobufOutput
Required.Proto2.ProtobufInput.ValidDataRepeated.UINT32.ProtobufOutput
This diff is collapsed.
This diff is collapsed.
Recommended.JsonInput.DoubleFieldInfinityNotQuoted Recommended.Proto3.JsonInput.DoubleFieldInfinityNotQuoted
Recommended.JsonInput.DoubleFieldNanNotQuoted Recommended.Proto3.JsonInput.DoubleFieldNanNotQuoted
Recommended.JsonInput.DoubleFieldNegativeInfinityNotQuoted Recommended.Proto3.JsonInput.DoubleFieldNegativeInfinityNotQuoted
Recommended.JsonInput.FloatFieldInfinityNotQuoted Recommended.Proto3.JsonInput.FloatFieldInfinityNotQuoted
Recommended.JsonInput.FloatFieldNanNotQuoted Recommended.Proto3.JsonInput.FloatFieldNanNotQuoted
Recommended.JsonInput.FloatFieldNegativeInfinityNotQuoted Recommended.Proto3.JsonInput.FloatFieldNegativeInfinityNotQuoted
Required.JsonInput.BytesFieldInvalidBase64Characters Required.Proto3.JsonInput.BytesFieldInvalidBase64Characters
Required.JsonInput.DoubleFieldTooSmall Required.Proto3.JsonInput.DoubleFieldTooSmall
Required.JsonInput.EnumFieldUnknownValue.Validator Required.Proto3.JsonInput.EnumFieldUnknownValue.Validator
Required.JsonInput.FloatFieldTooLarge Required.Proto3.JsonInput.FloatFieldTooLarge
Required.JsonInput.FloatFieldTooSmall Required.Proto3.JsonInput.FloatFieldTooSmall
Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
Required.JsonInput.TimestampJsonInputLowercaseT Required.Proto3.JsonInput.TimestampJsonInputLowercaseT
Required.ProtobufInput.IllegalZeroFieldNum_Case_0 Required.Proto2.ProtobufInput.IllegalZeroFieldNum_Case_0
Required.ProtobufInput.IllegalZeroFieldNum_Case_1 Required.Proto2.ProtobufInput.IllegalZeroFieldNum_Case_1
Required.ProtobufInput.IllegalZeroFieldNum_Case_2 Required.Proto2.ProtobufInput.IllegalZeroFieldNum_Case_2
Required.ProtobufInput.IllegalZeroFieldNum_Case_3 Required.Proto2.ProtobufInput.IllegalZeroFieldNum_Case_3
Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_0
Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_1
Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_2
Required.Proto3.ProtobufInput.IllegalZeroFieldNum_Case_3
...@@ -7,32 +7,48 @@ ...@@ -7,32 +7,48 @@
# TODO(haberman): insert links to corresponding bugs tracking the issue. # TODO(haberman): insert links to corresponding bugs tracking the issue.
# Should we use GitHub issues or the Google-internal bug tracker? # Should we use GitHub issues or the Google-internal bug tracker?
Recommended.JsonInput.DoubleFieldInfinityNotQuoted Recommended.Proto3.JsonInput.DoubleFieldInfinityNotQuoted
Recommended.JsonInput.DoubleFieldNanNotQuoted Recommended.Proto3.JsonInput.DoubleFieldNanNotQuoted
Recommended.JsonInput.DoubleFieldNegativeInfinityNotQuoted Recommended.Proto3.JsonInput.DoubleFieldNegativeInfinityNotQuoted
Recommended.JsonInput.FloatFieldInfinityNotQuoted Recommended.Proto3.JsonInput.FloatFieldInfinityNotQuoted
Recommended.JsonInput.FloatFieldNanNotQuoted Recommended.Proto3.JsonInput.FloatFieldNanNotQuoted
Recommended.JsonInput.FloatFieldNegativeInfinityNotQuoted Recommended.Proto3.JsonInput.FloatFieldNegativeInfinityNotQuoted
Required.JsonInput.BytesFieldInvalidBase64Characters Required.Proto3.JsonInput.BytesFieldInvalidBase64Characters
Required.JsonInput.DoubleFieldTooSmall Required.Proto3.JsonInput.DoubleFieldTooSmall
Required.JsonInput.EnumFieldUnknownValue.Validator Required.Proto3.JsonInput.EnumFieldUnknownValue.Validator
Required.JsonInput.FloatFieldTooLarge Required.Proto3.JsonInput.FloatFieldTooLarge
Required.JsonInput.FloatFieldTooSmall Required.Proto3.JsonInput.FloatFieldTooSmall
Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool Required.Proto3.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
Required.JsonInput.TimestampJsonInputLowercaseT Required.Proto3.JsonInput.TimestampJsonInputLowercaseT
Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE Required.Proto3.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
Required.ProtobufInput.PrematureEofInPackedField.BOOL Required.Proto3.ProtobufInput.PrematureEofInPackedField.BOOL
Required.ProtobufInput.PrematureEofInPackedField.DOUBLE Required.Proto3.ProtobufInput.PrematureEofInPackedField.DOUBLE
Required.ProtobufInput.PrematureEofInPackedField.ENUM Required.Proto3.ProtobufInput.PrematureEofInPackedField.ENUM
Required.ProtobufInput.PrematureEofInPackedField.FIXED32 Required.Proto3.ProtobufInput.PrematureEofInPackedField.FIXED32
Required.ProtobufInput.PrematureEofInPackedField.FIXED64 Required.Proto3.ProtobufInput.PrematureEofInPackedField.FIXED64
Required.ProtobufInput.PrematureEofInPackedField.FLOAT Required.Proto3.ProtobufInput.PrematureEofInPackedField.FLOAT
Required.ProtobufInput.PrematureEofInPackedField.INT32 Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT32
Required.ProtobufInput.PrematureEofInPackedField.INT64 Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT64
Required.ProtobufInput.PrematureEofInPackedField.SFIXED32 Required.Proto3.ProtobufInput.PrematureEofInPackedField.SFIXED32
Required.ProtobufInput.PrematureEofInPackedField.SFIXED64 Required.Proto3.ProtobufInput.PrematureEofInPackedField.SFIXED64
Required.ProtobufInput.PrematureEofInPackedField.SINT32 Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT32
Required.ProtobufInput.PrematureEofInPackedField.SINT64 Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT64
Required.ProtobufInput.PrematureEofInPackedField.UINT32 Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT32
Required.ProtobufInput.PrematureEofInPackedField.UINT64 Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT64
Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
Required.Proto2.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
Required.Proto2.ProtobufInput.PrematureEofInPackedField.BOOL
Required.Proto2.ProtobufInput.PrematureEofInPackedField.DOUBLE
Required.Proto2.ProtobufInput.PrematureEofInPackedField.ENUM
Required.Proto2.ProtobufInput.PrematureEofInPackedField.FIXED32
Required.Proto2.ProtobufInput.PrematureEofInPackedField.FIXED64
Required.Proto2.ProtobufInput.PrematureEofInPackedField.FLOAT
Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT32
Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT64
Required.Proto2.ProtobufInput.PrematureEofInPackedField.SFIXED32
Required.Proto2.ProtobufInput.PrematureEofInPackedField.SFIXED64
Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT32
Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT64
Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT32
Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT64
This diff is collapsed.
...@@ -22,21 +22,21 @@ namespace Conformance { ...@@ -22,21 +22,21 @@ namespace Conformance {
static ConformanceReflection() { static ConformanceReflection() {
byte[] descriptorData = global::System.Convert.FromBase64String( byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat( string.Concat(
"ChFjb25mb3JtYW5jZS5wcm90bxILY29uZm9ybWFuY2UijQEKEkNvbmZvcm1h", "ChFjb25mb3JtYW5jZS5wcm90bxILY29uZm9ybWFuY2UiowEKEkNvbmZvcm1h",
"bmNlUmVxdWVzdBIaChBwcm90b2J1Zl9wYXlsb2FkGAEgASgMSAASFgoManNv", "bmNlUmVxdWVzdBIaChBwcm90b2J1Zl9wYXlsb2FkGAEgASgMSAASFgoManNv",
"bl9wYXlsb2FkGAIgASgJSAASOAoXcmVxdWVzdGVkX291dHB1dF9mb3JtYXQY", "bl9wYXlsb2FkGAIgASgJSAASOAoXcmVxdWVzdGVkX291dHB1dF9mb3JtYXQY",
"AyABKA4yFy5jb25mb3JtYW5jZS5XaXJlRm9ybWF0QgkKB3BheWxvYWQisQEK", "AyABKA4yFy5jb25mb3JtYW5jZS5XaXJlRm9ybWF0EhQKDG1lc3NhZ2VfdHlw",
"E0NvbmZvcm1hbmNlUmVzcG9uc2USFQoLcGFyc2VfZXJyb3IYASABKAlIABIZ", "ZRgEIAEoCUIJCgdwYXlsb2FkIrEBChNDb25mb3JtYW5jZVJlc3BvbnNlEhUK",
"Cg9zZXJpYWxpemVfZXJyb3IYBiABKAlIABIXCg1ydW50aW1lX2Vycm9yGAIg", "C3BhcnNlX2Vycm9yGAEgASgJSAASGQoPc2VyaWFsaXplX2Vycm9yGAYgASgJ",
"ASgJSAASGgoQcHJvdG9idWZfcGF5bG9hZBgDIAEoDEgAEhYKDGpzb25fcGF5", "SAASFwoNcnVudGltZV9lcnJvchgCIAEoCUgAEhoKEHByb3RvYnVmX3BheWxv",
"bG9hZBgEIAEoCUgAEhEKB3NraXBwZWQYBSABKAlIAEIICgZyZXN1bHQqNQoK", "YWQYAyABKAxIABIWCgxqc29uX3BheWxvYWQYBCABKAlIABIRCgdza2lwcGVk",
"V2lyZUZvcm1hdBIPCgtVTlNQRUNJRklFRBAAEgwKCFBST1RPQlVGEAESCAoE", "GAUgASgJSABCCAoGcmVzdWx0KjUKCldpcmVGb3JtYXQSDwoLVU5TUEVDSUZJ",
"SlNPThACQiEKH2NvbS5nb29nbGUucHJvdG9idWYuY29uZm9ybWFuY2ViBnBy", "RUQQABIMCghQUk9UT0JVRhABEggKBEpTT04QAkIhCh9jb20uZ29vZ2xlLnBy",
"b3RvMw==")); "b3RvYnVmLmNvbmZvcm1hbmNlYgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { }, new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Conformance.WireFormat), }, new pbr::GeneratedClrTypeInfo[] { new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Conformance.WireFormat), }, new pbr::GeneratedClrTypeInfo[] {
new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ConformanceRequest), global::Conformance.ConformanceRequest.Parser, new[]{ "ProtobufPayload", "JsonPayload", "RequestedOutputFormat" }, new[]{ "Payload" }, null, null), new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ConformanceRequest), global::Conformance.ConformanceRequest.Parser, new[]{ "ProtobufPayload", "JsonPayload", "RequestedOutputFormat", "MessageType" }, new[]{ "Payload" }, null, null),
new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ConformanceResponse), global::Conformance.ConformanceResponse.Parser, new[]{ "ParseError", "SerializeError", "RuntimeError", "ProtobufPayload", "JsonPayload", "Skipped" }, new[]{ "Result" }, null, null) new pbr::GeneratedClrTypeInfo(typeof(global::Conformance.ConformanceResponse), global::Conformance.ConformanceResponse.Parser, new[]{ "ParseError", "SerializeError", "RuntimeError", "ProtobufPayload", "JsonPayload", "Skipped" }, new[]{ "Result" }, null, null)
})); }));
} }
...@@ -85,6 +85,7 @@ namespace Conformance { ...@@ -85,6 +85,7 @@ namespace Conformance {
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public ConformanceRequest(ConformanceRequest other) : this() { public ConformanceRequest(ConformanceRequest other) : this() {
requestedOutputFormat_ = other.requestedOutputFormat_; requestedOutputFormat_ = other.requestedOutputFormat_;
messageType_ = other.messageType_;
switch (other.PayloadCase) { switch (other.PayloadCase) {
case PayloadOneofCase.ProtobufPayload: case PayloadOneofCase.ProtobufPayload:
ProtobufPayload = other.ProtobufPayload; ProtobufPayload = other.ProtobufPayload;
...@@ -137,6 +138,20 @@ namespace Conformance { ...@@ -137,6 +138,20 @@ namespace Conformance {
} }
} }
/// <summary>Field number for the "message_type" field.</summary>
public const int MessageTypeFieldNumber = 4;
private string messageType_ = "";
/// <summary>
/// should be set to either "proto2" or "proto3"
/// </summary>
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
public string MessageType {
get { return messageType_; }
set {
messageType_ = pb::ProtoPreconditions.CheckNotNull(value, "value");
}
}
private object payload_; private object payload_;
/// <summary>Enum of possible cases for the "payload" oneof.</summary> /// <summary>Enum of possible cases for the "payload" oneof.</summary>
public enum PayloadOneofCase { public enum PayloadOneofCase {
...@@ -172,6 +187,7 @@ namespace Conformance { ...@@ -172,6 +187,7 @@ namespace Conformance {
if (ProtobufPayload != other.ProtobufPayload) return false; if (ProtobufPayload != other.ProtobufPayload) return false;
if (JsonPayload != other.JsonPayload) return false; if (JsonPayload != other.JsonPayload) return false;
if (RequestedOutputFormat != other.RequestedOutputFormat) return false; if (RequestedOutputFormat != other.RequestedOutputFormat) return false;
if (MessageType != other.MessageType) return false;
if (PayloadCase != other.PayloadCase) return false; if (PayloadCase != other.PayloadCase) return false;
return true; return true;
} }
...@@ -182,6 +198,7 @@ namespace Conformance { ...@@ -182,6 +198,7 @@ namespace Conformance {
if (payloadCase_ == PayloadOneofCase.ProtobufPayload) hash ^= ProtobufPayload.GetHashCode(); if (payloadCase_ == PayloadOneofCase.ProtobufPayload) hash ^= ProtobufPayload.GetHashCode();
if (payloadCase_ == PayloadOneofCase.JsonPayload) hash ^= JsonPayload.GetHashCode(); if (payloadCase_ == PayloadOneofCase.JsonPayload) hash ^= JsonPayload.GetHashCode();
if (RequestedOutputFormat != 0) hash ^= RequestedOutputFormat.GetHashCode(); if (RequestedOutputFormat != 0) hash ^= RequestedOutputFormat.GetHashCode();
if (MessageType.Length != 0) hash ^= MessageType.GetHashCode();
hash ^= (int) payloadCase_; hash ^= (int) payloadCase_;
return hash; return hash;
} }
...@@ -205,6 +222,10 @@ namespace Conformance { ...@@ -205,6 +222,10 @@ namespace Conformance {
output.WriteRawTag(24); output.WriteRawTag(24);
output.WriteEnum((int) RequestedOutputFormat); output.WriteEnum((int) RequestedOutputFormat);
} }
if (MessageType.Length != 0) {
output.WriteRawTag(34);
output.WriteString(MessageType);
}
} }
[global::System.Diagnostics.DebuggerNonUserCodeAttribute] [global::System.Diagnostics.DebuggerNonUserCodeAttribute]
...@@ -219,6 +240,9 @@ namespace Conformance { ...@@ -219,6 +240,9 @@ namespace Conformance {
if (RequestedOutputFormat != 0) { if (RequestedOutputFormat != 0) {
size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) RequestedOutputFormat); size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) RequestedOutputFormat);
} }
if (MessageType.Length != 0) {
size += 1 + pb::CodedOutputStream.ComputeStringSize(MessageType);
}
return size; return size;
} }
...@@ -230,6 +254,9 @@ namespace Conformance { ...@@ -230,6 +254,9 @@ namespace Conformance {
if (other.RequestedOutputFormat != 0) { if (other.RequestedOutputFormat != 0) {
RequestedOutputFormat = other.RequestedOutputFormat; RequestedOutputFormat = other.RequestedOutputFormat;
} }
if (other.MessageType.Length != 0) {
MessageType = other.MessageType;
}
switch (other.PayloadCase) { switch (other.PayloadCase) {
case PayloadOneofCase.ProtobufPayload: case PayloadOneofCase.ProtobufPayload:
ProtobufPayload = other.ProtobufPayload; ProtobufPayload = other.ProtobufPayload;
...@@ -261,6 +288,10 @@ namespace Conformance { ...@@ -261,6 +288,10 @@ namespace Conformance {
requestedOutputFormat_ = (global::Conformance.WireFormat) input.ReadEnum(); requestedOutputFormat_ = (global::Conformance.WireFormat) input.ReadEnum();
break; break;
} }
case 34: {
MessageType = input.ReadString();
break;
}
} }
} }
} }
......
...@@ -48,7 +48,7 @@ namespace Google.Protobuf.Conformance ...@@ -48,7 +48,7 @@ namespace Google.Protobuf.Conformance
// This way we get the binary streams instead of readers/writers. // This way we get the binary streams instead of readers/writers.
var input = new BinaryReader(Console.OpenStandardInput()); var input = new BinaryReader(Console.OpenStandardInput());
var output = new BinaryWriter(Console.OpenStandardOutput()); var output = new BinaryWriter(Console.OpenStandardOutput());
var typeRegistry = TypeRegistry.FromMessages(ProtobufTestMessages.Proto3.TestAllTypes.Descriptor); var typeRegistry = TypeRegistry.FromMessages(ProtobufTestMessages.Proto3.TestAllTypesProto3.Descriptor);
int count = 0; int count = 0;
while (RunTest(input, output, typeRegistry)) while (RunTest(input, output, typeRegistry))
...@@ -81,18 +81,31 @@ namespace Google.Protobuf.Conformance ...@@ -81,18 +81,31 @@ namespace Google.Protobuf.Conformance
private static ConformanceResponse PerformRequest(ConformanceRequest request, TypeRegistry typeRegistry) private static ConformanceResponse PerformRequest(ConformanceRequest request, TypeRegistry typeRegistry)
{ {
ProtobufTestMessages.Proto3.TestAllTypes message; ProtobufTestMessages.Proto3.TestAllTypesProto3 message;
try try
{ {
switch (request.PayloadCase) switch (request.PayloadCase)
{ {
case ConformanceRequest.PayloadOneofCase.JsonPayload: case ConformanceRequest.PayloadOneofCase.JsonPayload:
var parser = new JsonParser(new JsonParser.Settings(20, typeRegistry)); var parser = new JsonParser(new JsonParser.Settings(20, typeRegistry));
message = parser.Parse<ProtobufTestMessages.Proto3.TestAllTypes>(request.JsonPayload); message = parser.Parse<ProtobufTestMessages.Proto3.TestAllTypesProto3>(request.JsonPayload);
break; break;
case ConformanceRequest.PayloadOneofCase.ProtobufPayload: case ConformanceRequest.PayloadOneofCase.ProtobufPayload:
message = ProtobufTestMessages.Proto3.TestAllTypes.Parser.ParseFrom(request.ProtobufPayload); {
if (request.MessageType.Equals("protobuf_test_messages.proto3.TestAllTypesProto3"))
{
message = ProtobufTestMessages.Proto3.TestAllTypesProto3.Parser.ParseFrom(request.ProtobufPayload);
}
else if (request.MessageType.Equals("protobuf_test_messages.proto2.TestAllTypesProto2"))
{
return new ConformanceResponse { Skipped = "CSharp doesn't support proto2" };
}
else
{
throw new Exception(" Protobuf request doesn't have specific payload type");
}
break; break;
}
default: default:
throw new Exception("Unsupported request payload: " + request.PayloadCase); throw new Exception("Unsupported request payload: " + request.PayloadCase);
} }
......
...@@ -80,6 +80,7 @@ def GenerateUnittestProtos(): ...@@ -80,6 +80,7 @@ def GenerateUnittestProtos():
generate_proto("../src/google/protobuf/any_test.proto", False) generate_proto("../src/google/protobuf/any_test.proto", False)
generate_proto("../src/google/protobuf/map_unittest.proto", False) generate_proto("../src/google/protobuf/map_unittest.proto", False)
generate_proto("../src/google/protobuf/test_messages_proto3.proto", False) generate_proto("../src/google/protobuf/test_messages_proto3.proto", False)
generate_proto("../src/google/protobuf/test_messages_proto2.proto", False)
generate_proto("../src/google/protobuf/unittest_arena.proto", False) generate_proto("../src/google/protobuf/unittest_arena.proto", False)
generate_proto("../src/google/protobuf/unittest_no_arena.proto", False) generate_proto("../src/google/protobuf/unittest_no_arena.proto", False)
generate_proto("../src/google/protobuf/unittest_no_arena_import.proto", False) generate_proto("../src/google/protobuf/unittest_no_arena_import.proto", False)
......
// Protocol Buffers - Google's data interchange format
// Copyright 2008 Google Inc. All rights reserved.
// https://developers.google.com/protocol-buffers/
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Test schema for proto2 messages. This test schema is used by:
//
// - conformance tests
//
syntax = "proto2";
package protobuf_test_messages.proto2;
option java_package = "com.google.protobuf_test_messages.proto2";
// This is the default, but we specify it here explicitly.
option optimize_for = SPEED;
option cc_enable_arenas = true;
// This proto includes every type of field in both singular and repeated
// forms.
//
// Also, crucially, all messages and enums in this file are eventually
// submessages of this message. So for example, a fuzz test of TestAllTypes
// could trigger bugs that occur in any message type in this file. We verify
// this stays true in a unit test.
message TestAllTypesProto2 {
message NestedMessage {
optional int32 a = 1;
optional TestAllTypesProto2 corecursive = 2;
}
enum NestedEnum {
FOO = 0;
BAR = 1;
BAZ = 2;
NEG = -1; // Intentionally negative.
}
// Singular
optional int32 optional_int32 = 1;
optional int64 optional_int64 = 2;
optional uint32 optional_uint32 = 3;
optional uint64 optional_uint64 = 4;
optional sint32 optional_sint32 = 5;
optional sint64 optional_sint64 = 6;
optional fixed32 optional_fixed32 = 7;
optional fixed64 optional_fixed64 = 8;
optional sfixed32 optional_sfixed32 = 9;
optional sfixed64 optional_sfixed64 = 10;
optional float optional_float = 11;
optional double optional_double = 12;
optional bool optional_bool = 13;
optional string optional_string = 14;
optional bytes optional_bytes = 15;
optional NestedMessage optional_nested_message = 18;
optional ForeignMessage optional_foreign_message = 19;
optional NestedEnum optional_nested_enum = 21;
optional ForeignEnum optional_foreign_enum = 22;
optional string optional_string_piece = 24 [ctype=STRING_PIECE];
optional string optional_cord = 25 [ctype=CORD];
optional TestAllTypesProto2 recursive_message = 27;
// Repeated
repeated int32 repeated_int32 = 31;
repeated int64 repeated_int64 = 32;
repeated uint32 repeated_uint32 = 33;
repeated uint64 repeated_uint64 = 34;
repeated sint32 repeated_sint32 = 35;
repeated sint64 repeated_sint64 = 36;
repeated fixed32 repeated_fixed32 = 37;
repeated fixed64 repeated_fixed64 = 38;
repeated sfixed32 repeated_sfixed32 = 39;
repeated sfixed64 repeated_sfixed64 = 40;
repeated float repeated_float = 41;
repeated double repeated_double = 42;
repeated bool repeated_bool = 43;
repeated string repeated_string = 44;
repeated bytes repeated_bytes = 45;
repeated NestedMessage repeated_nested_message = 48;
repeated ForeignMessage repeated_foreign_message = 49;
repeated NestedEnum repeated_nested_enum = 51;
repeated ForeignEnum repeated_foreign_enum = 52;
repeated string repeated_string_piece = 54 [ctype=STRING_PIECE];
repeated string repeated_cord = 55 [ctype=CORD];
// Map
map < int32, int32> map_int32_int32 = 56;
map < int64, int64> map_int64_int64 = 57;
map < uint32, uint32> map_uint32_uint32 = 58;
map < uint64, uint64> map_uint64_uint64 = 59;
map < sint32, sint32> map_sint32_sint32 = 60;
map < sint64, sint64> map_sint64_sint64 = 61;
map < fixed32, fixed32> map_fixed32_fixed32 = 62;
map < fixed64, fixed64> map_fixed64_fixed64 = 63;
map <sfixed32, sfixed32> map_sfixed32_sfixed32 = 64;
map <sfixed64, sfixed64> map_sfixed64_sfixed64 = 65;
map < int32, float> map_int32_float = 66;
map < int32, double> map_int32_double = 67;
map < bool, bool> map_bool_bool = 68;
map < string, string> map_string_string = 69;
map < string, bytes> map_string_bytes = 70;
map < string, NestedMessage> map_string_nested_message = 71;
map < string, ForeignMessage> map_string_foreign_message = 72;
map < string, NestedEnum> map_string_nested_enum = 73;
map < string, ForeignEnum> map_string_foreign_enum = 74;
oneof oneof_field {
uint32 oneof_uint32 = 111;
NestedMessage oneof_nested_message = 112;
string oneof_string = 113;
bytes oneof_bytes = 114;
bool oneof_bool = 115;
uint64 oneof_uint64 = 116;
float oneof_float = 117;
double oneof_double = 118;
NestedEnum oneof_enum = 119;
}
// extensions
extensions 120 to 200;
// groups
optional group Data = 201 {
optional int32 group_int32 = 202;
optional uint32 group_uint32 = 203;
};
// Test field-name-to-JSON-name convention.
// (protobuf says names can be any valid C/C++ identifier.)
optional int32 fieldname1 = 401;
optional int32 field_name2 = 402;
optional int32 _field_name3 = 403;
optional int32 field__name4_ = 404;
optional int32 field0name5 = 405;
optional int32 field_0_name6 = 406;
optional int32 fieldName7 = 407;
optional int32 FieldName8 = 408;
optional int32 field_Name9 = 409;
optional int32 Field_Name10 = 410;
optional int32 FIELD_NAME11 = 411;
optional int32 FIELD_name12 = 412;
optional int32 __field_name13 = 413;
optional int32 __Field_name14 = 414;
optional int32 field__name15 = 415;
optional int32 field__Name16 = 416;
optional int32 field_name17__ = 417;
optional int32 Field_name18__ = 418;
// message_set test case.
message MessageSetCorrect {
option message_set_wire_format = true;
extensions 4 to max;
}
message MessageSetCorrectExtension1 {
extend MessageSetCorrect {
optional MessageSetCorrectExtension1 message_set_extension = 1547769;
}
optional string str = 25;
}
message MessageSetCorrectExtension2 {
extend MessageSetCorrect {
optional MessageSetCorrectExtension2 message_set_extension = 4135312;
}
optional int32 i = 9;
}
}
message ForeignMessage {
optional int32 c = 1;
}
enum ForeignEnum {
FOREIGN_FOO = 0;
FOREIGN_BAR = 1;
FOREIGN_BAZ = 2;
}
extend TestAllTypesProto2 {
optional int32 extension_int32 = 120;
}
...@@ -59,10 +59,10 @@ option cc_enable_arenas = true; ...@@ -59,10 +59,10 @@ option cc_enable_arenas = true;
// submessages of this message. So for example, a fuzz test of TestAllTypes // submessages of this message. So for example, a fuzz test of TestAllTypes
// could trigger bugs that occur in any message type in this file. We verify // could trigger bugs that occur in any message type in this file. We verify
// this stays true in a unit test. // this stays true in a unit test.
message TestAllTypes { message TestAllTypesProto3 {
message NestedMessage { message NestedMessage {
int32 a = 1; int32 a = 1;
TestAllTypes corecursive = 2; TestAllTypesProto3 corecursive = 2;
} }
enum NestedEnum { enum NestedEnum {
...@@ -98,7 +98,7 @@ message TestAllTypes { ...@@ -98,7 +98,7 @@ message TestAllTypes {
string optional_string_piece = 24 [ctype=STRING_PIECE]; string optional_string_piece = 24 [ctype=STRING_PIECE];
string optional_cord = 25 [ctype=CORD]; string optional_cord = 25 [ctype=CORD];
TestAllTypes recursive_message = 27; TestAllTypesProto3 recursive_message = 27;
// Repeated // Repeated
repeated int32 repeated_int32 = 31; repeated int32 repeated_int32 = 31;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment