Commit 19cf9d1e authored by Jon Skeet's avatar Jon Skeet

Merge pull request #606 from jtattermusch/csharp-experimental-merged

Update csharp-experimental with changes from upstream/master
parents 385baaa8 11002e70
This diff is collapsed.
...@@ -11,25 +11,11 @@ Pod::Spec.new do |s| ...@@ -11,25 +11,11 @@ Pod::Spec.new do |s|
s.license = 'New BSD' s.license = 'New BSD'
s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' } s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' }
s.source_files = 'objectivec/*.{h,m}', s.source_files = 'objectivec/GPBProtocolBuffers.{h,m}'
'objectivec/google/protobuf/Any.pbobjc.{h,m}', # GPBProtocolBuffers.{h,m} are umbrella files. We need Cocoapods to preserve the files imported by
'objectivec/google/protobuf/Api.pbobjc.{h,m}', # them.
'objectivec/google/protobuf/Descriptor.pbobjc.{h,m}', s.preserve_paths = 'objectivec/*.{h,m}',
'objectivec/google/protobuf/Duration.pbobjc.h', 'objectivec/google/protobuf/*.pbobjc.{h,m}'
'objectivec/google/protobuf/Empty.pbobjc.{h,m}',
'objectivec/google/protobuf/FieldMask.pbobjc.{h,m}',
'objectivec/google/protobuf/SourceContext.pbobjc.{h,m}',
'objectivec/google/protobuf/Struct.pbobjc.{h,m}',
'objectivec/google/protobuf/Timestamp.pbobjc.h',
'objectivec/google/protobuf/Type.pbobjc.{h,m}'
'objectivec/google/protobuf/Wrappers.pbobjc.{h,m}'
# Timestamp.pbobjc.m and Duration.pbobjc.m are #imported by GPBWellKnownTypes.m. So we can't
# compile them (duplicate symbols), but we need them available for the importing:
s.preserve_paths = 'objectivec/google/protobuf/Duration.pbobjc.m',
'objectivec/google/protobuf/Timestamp.pbobjc.m'
# The following would cause duplicate symbol definitions. GPBProtocolBuffers is expected to be
# left out, as it's an umbrella implementation file.
s.exclude_files = 'objectivec/GPBProtocolBuffers.m'
s.header_mappings_dir = 'objectivec' s.header_mappings_dir = 'objectivec'
s.ios.deployment_target = '6.0' s.ios.deployment_target = '6.0'
......
new_http_archive(
name = "gmock_archive",
url = "https://googlemock.googlecode.com/files/gmock-1.7.0.zip",
sha256 = "26fcbb5925b74ad5fc8c26b0495dfc96353f4d553492eb97e85a8a6d2f43095b",
build_file = "gmock.BUILD",
)
bind(
name = "gtest",
actual = "@gmock_archive//:gtest",
)
bind(
name = "gtest_main",
actual = "@gmock_archive//:gtest_main",
)
...@@ -32,7 +32,7 @@ Compiling and Installing ...@@ -32,7 +32,7 @@ Compiling and Installing
If you don't have gmock, skip the build of tests by turning off the If you don't have gmock, skip the build of tests by turning off the
BUILD_TESTING option: BUILD_TESTING option:
$ cmake -G "Visutal Studio 9 2008" -DBUILD_TESTING=OFF .. $ cmake -G "Visual Studio 9 2008" -DBUILD_TESTING=OFF ..
3. Open the generated protobuf.sln file in Microsoft Visual Studio. 3. Open the generated protobuf.sln file in Microsoft Visual Studio.
4. Choose "Debug" or "Release" configuration as desired. 4. Choose "Debug" or "Release" configuration as desired.
......
...@@ -89,7 +89,6 @@ copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\common.h include ...@@ -89,7 +89,6 @@ copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\common.h include
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\fastmem.h include\google\protobuf\stubs\fastmem.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\fastmem.h include\google\protobuf\stubs\fastmem.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\hash.h include\google\protobuf\stubs\hash.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\hash.h include\google\protobuf\stubs\hash.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\once.h include\google\protobuf\stubs\once.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\once.h include\google\protobuf\stubs\once.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\pbconfig.h include\google\protobuf\stubs\pbconfig.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\platform_macros.h include\google\protobuf\stubs\platform_macros.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\platform_macros.h include\google\protobuf\stubs\platform_macros.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\shared_ptr.h include\google\protobuf\stubs\shared_ptr.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\shared_ptr.h include\google\protobuf\stubs\shared_ptr.h
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\singleton.h include\google\protobuf\stubs\singleton.h copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\singleton.h include\google\protobuf\stubs\singleton.h
......
...@@ -54,7 +54,7 @@ class ConformanceJava { ...@@ -54,7 +54,7 @@ class ConformanceJava {
break; break;
} }
case JSON_PAYLOAD: { case JSON_PAYLOAD: {
return Conformance.ConformanceResponse.newBuilder().setRuntimeError("JSON not yet supported.").build(); return Conformance.ConformanceResponse.newBuilder().setSkipped("JSON not yet supported.").build();
} }
case PAYLOAD_NOT_SET: { case PAYLOAD_NOT_SET: {
throw new RuntimeException("Request didn't have payload."); throw new RuntimeException("Request didn't have payload.");
...@@ -65,7 +65,7 @@ class ConformanceJava { ...@@ -65,7 +65,7 @@ class ConformanceJava {
} }
} }
switch (request.getRequestedOutput()) { switch (request.getRequestedOutputFormat()) {
case UNSPECIFIED: case UNSPECIFIED:
throw new RuntimeException("Unspecified output format."); throw new RuntimeException("Unspecified output format.");
...@@ -73,7 +73,7 @@ class ConformanceJava { ...@@ -73,7 +73,7 @@ class ConformanceJava {
return Conformance.ConformanceResponse.newBuilder().setProtobufPayload(testMessage.toByteString()).build(); return Conformance.ConformanceResponse.newBuilder().setProtobufPayload(testMessage.toByteString()).build();
case JSON: case JSON:
return Conformance.ConformanceResponse.newBuilder().setRuntimeError("JSON not yet supported.").build(); return Conformance.ConformanceResponse.newBuilder().setSkipped("JSON not yet supported.").build();
default: { default: {
throw new RuntimeException("Unexpected request output."); throw new RuntimeException("Unexpected request output.");
......
...@@ -51,6 +51,12 @@ option java_package = "com.google.protobuf.conformance"; ...@@ -51,6 +51,12 @@ option java_package = "com.google.protobuf.conformance";
// - running as a sub-process may be more tricky in unusual environments like // - running as a sub-process may be more tricky in unusual environments like
// iOS apps, where fork/stdin/stdout are not available. // iOS apps, where fork/stdin/stdout are not available.
enum WireFormat {
UNSPECIFIED = 0;
PROTOBUF = 1;
JSON = 2;
}
// Represents a single test case's input. The testee should: // Represents a single test case's input. The testee should:
// //
// 1. parse this proto (which should always succeed) // 1. parse this proto (which should always succeed)
...@@ -64,14 +70,8 @@ message ConformanceRequest { ...@@ -64,14 +70,8 @@ message ConformanceRequest {
string json_payload = 2; string json_payload = 2;
} }
enum RequestedOutput {
UNSPECIFIED = 0;
PROTOBUF = 1;
JSON = 2;
}
// Which format should the testee serialize its message to? // Which format should the testee serialize its message to?
RequestedOutput requested_output = 3; WireFormat requested_output_format = 3;
} }
// Represents a single test case's output. // Represents a single test case's output.
...@@ -96,6 +96,10 @@ message ConformanceResponse { ...@@ -96,6 +96,10 @@ message ConformanceResponse {
// If the input was successfully parsed and the requested output was JSON, // If the input was successfully parsed and the requested output was JSON,
// serialize to JSON and set it in this field. // serialize to JSON and set it in this field.
string json_payload = 4; string json_payload = 4;
// For when the testee skipped the test, likely because a certain feature
// wasn't supported, like JSON input/output.
string skipped = 5;
} }
} }
......
...@@ -33,14 +33,33 @@ ...@@ -33,14 +33,33 @@
#include <unistd.h> #include <unistd.h>
#include "conformance.pb.h" #include "conformance.pb.h"
#include <google/protobuf/util/json_util.h>
#include <google/protobuf/util/type_resolver_util.h>
using std::string;
using conformance::ConformanceRequest; using conformance::ConformanceRequest;
using conformance::ConformanceResponse; using conformance::ConformanceResponse;
using conformance::TestAllTypes; using conformance::TestAllTypes;
using google::protobuf::Descriptor;
using google::protobuf::DescriptorPool;
using google::protobuf::internal::scoped_ptr;
using google::protobuf::util::BinaryToJsonString;
using google::protobuf::util::JsonToBinaryString;
using google::protobuf::util::NewTypeResolverForDescriptorPool;
using google::protobuf::util::Status;
using google::protobuf::util::TypeResolver;
using std::string;
static const char kTypeUrlPrefix[] = "type.googleapis.com";
static string GetTypeUrl(const Descriptor* message) {
return string(kTypeUrlPrefix) + "/" + message->full_name();
}
int test_count = 0; int test_count = 0;
bool verbose = false; bool verbose = false;
TypeResolver* type_resolver;
string* type_url;
bool CheckedRead(int fd, void *buf, size_t len) { bool CheckedRead(int fd, void *buf, size_t len) {
size_t ofs = 0; size_t ofs = 0;
...@@ -79,28 +98,44 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) { ...@@ -79,28 +98,44 @@ void DoTest(const ConformanceRequest& request, ConformanceResponse* response) {
} }
break; break;
case ConformanceRequest::kJsonPayload: case ConformanceRequest::kJsonPayload: {
response->set_runtime_error("JSON input is not yet supported."); string proto_binary;
Status status = JsonToBinaryString(type_resolver, *type_url,
request.json_payload(), &proto_binary);
if (!status.ok()) {
response->set_parse_error(string("Parse error: ") +
status.error_message().as_string());
return;
}
GOOGLE_CHECK(test_message.ParseFromString(proto_binary));
break; break;
}
case ConformanceRequest::PAYLOAD_NOT_SET: case ConformanceRequest::PAYLOAD_NOT_SET:
GOOGLE_LOG(FATAL) << "Request didn't have payload."; GOOGLE_LOG(FATAL) << "Request didn't have payload.";
break; break;
} }
switch (request.requested_output()) { switch (request.requested_output_format()) {
case ConformanceRequest::UNSPECIFIED: case conformance::UNSPECIFIED:
GOOGLE_LOG(FATAL) << "Unspecified output format"; GOOGLE_LOG(FATAL) << "Unspecified output format";
break; break;
case ConformanceRequest::PROTOBUF: case conformance::PROTOBUF:
test_message.SerializeToString(response->mutable_protobuf_payload()); GOOGLE_CHECK(
test_message.SerializeToString(response->mutable_protobuf_payload()));
break; break;
case ConformanceRequest::JSON: case conformance::JSON: {
response->set_runtime_error("JSON output is not yet supported."); string proto_binary;
GOOGLE_CHECK(test_message.SerializeToString(&proto_binary));
Status status = BinaryToJsonString(type_resolver, *type_url, proto_binary,
response->mutable_json_payload());
GOOGLE_CHECK(status.ok());
break; break;
} }
}
} }
bool DoTestIo() { bool DoTestIo() {
...@@ -146,6 +181,9 @@ bool DoTestIo() { ...@@ -146,6 +181,9 @@ bool DoTestIo() {
} }
int main() { int main() {
type_resolver = NewTypeResolverForDescriptorPool(
kTypeUrlPrefix, DescriptorPool::generated_pool());
type_url = new string(GetTypeUrl(TestAllTypes::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 "
......
This diff is collapsed.
...@@ -39,6 +39,8 @@ ...@@ -39,6 +39,8 @@
#define CONFORMANCE_CONFORMANCE_TEST_H #define CONFORMANCE_CONFORMANCE_TEST_H
#include <string> #include <string>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/util/type_resolver.h>
#include <google/protobuf/wire_format_lite.h> #include <google/protobuf/wire_format_lite.h>
namespace conformance { namespace conformance {
...@@ -98,10 +100,22 @@ class ConformanceTestSuite { ...@@ -98,10 +100,22 @@ class ConformanceTestSuite {
private: private:
void ReportSuccess(const std::string& test_name); void ReportSuccess(const std::string& test_name);
void ReportFailure(const std::string& test_name, const char* fmt, ...); void ReportFailure(const string& test_name,
const conformance::ConformanceRequest& request,
const conformance::ConformanceResponse& response,
const char* fmt, ...);
void ReportSkip(const string& test_name,
const conformance::ConformanceRequest& request,
const conformance::ConformanceResponse& response);
void RunTest(const std::string& test_name, void RunTest(const std::string& test_name,
const conformance::ConformanceRequest& request, const conformance::ConformanceRequest& request,
conformance::ConformanceResponse* response); conformance::ConformanceResponse* response);
void RunValidInputTest(const string& test_name, const string& input,
conformance::WireFormat input_format,
const string& equivalent_text_format,
conformance::WireFormat requested_output);
void RunValidJsonTest(const string& test_name, const string& input_json,
const string& equivalent_text_format);
void ExpectParseFailureForProto(const std::string& proto, void ExpectParseFailureForProto(const std::string& proto,
const std::string& test_name); const std::string& test_name);
void ExpectHardParseFailureForProto(const std::string& proto, void ExpectHardParseFailureForProto(const std::string& proto,
...@@ -110,7 +124,7 @@ class ConformanceTestSuite { ...@@ -110,7 +124,7 @@ class ConformanceTestSuite {
bool CheckSetEmpty(const set<string>& set_to_check, const char* msg); bool CheckSetEmpty(const set<string>& set_to_check, const char* msg);
ConformanceTestRunner* runner_; ConformanceTestRunner* runner_;
int successes_; int successes_;
int failures_; int expected_failures_;
bool verbose_; bool verbose_;
std::string output_; std::string output_;
...@@ -127,6 +141,13 @@ class ConformanceTestSuite { ...@@ -127,6 +141,13 @@ class ConformanceTestSuite {
// The set of tests that succeeded, but weren't expected to. // The set of tests that succeeded, but weren't expected to.
std::set<std::string> unexpected_succeeding_tests_; std::set<std::string> unexpected_succeeding_tests_;
// The set of tests that the testee opted out of;
std::set<std::string> skipped_;
google::protobuf::internal::scoped_ptr<google::protobuf::util::TypeResolver>
type_resolver_;
std::string type_url_;
}; };
} // namespace protobuf } // namespace protobuf
......
...@@ -7,15 +7,15 @@ ...@@ -7,15 +7,15 @@
# 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?
PrematureEofBeforeKnownRepeatedValue.MESSAGE ProtobufInput.PrematureEofBeforeKnownRepeatedValue.MESSAGE
PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
PrematureEofInPackedField.BOOL ProtobufInput.PrematureEofInPackedField.BOOL
PrematureEofInPackedField.ENUM ProtobufInput.PrematureEofInPackedField.ENUM
PrematureEofInPackedField.INT32 ProtobufInput.PrematureEofInPackedField.INT32
PrematureEofInPackedField.INT64 ProtobufInput.PrematureEofInPackedField.INT64
PrematureEofInPackedField.SINT32 ProtobufInput.PrematureEofInPackedField.SINT32
PrematureEofInPackedField.SINT64 ProtobufInput.PrematureEofInPackedField.SINT64
PrematureEofInPackedField.UINT32 ProtobufInput.PrematureEofInPackedField.UINT32
PrematureEofInPackedField.UINT64 ProtobufInput.PrematureEofInPackedField.UINT64
PrematureEofInsideKnownRepeatedValue.MESSAGE ProtobufInput.PrematureEofInsideKnownRepeatedValue.MESSAGE
cc_library(
name = "gtest",
srcs = [
"gmock-1.7.0/gtest/src/gtest-all.cc",
"gmock-1.7.0/src/gmock-all.cc",
],
includes = [
"gmock-1.7.0",
"gmock-1.7.0/gtest",
"gmock-1.7.0/gtest/include",
"gmock-1.7.0/include",
],
linkopts = ["-pthread"],
visibility = ["//visibility:public"],
)
cc_library(
name = "gtest_main",
srcs = ["gmock-1.7.0/src/gmock_main.cc"],
linkopts = ["-pthread"],
visibility = ["//visibility:public"],
deps = [":gtest"],
)
...@@ -42,3 +42,15 @@ ...@@ -42,3 +42,15 @@
#import "GPBUnknownFieldSet.h" #import "GPBUnknownFieldSet.h"
#import "GPBUtilities.h" #import "GPBUtilities.h"
#import "GPBWireFormat.h" #import "GPBWireFormat.h"
// Well-known proto types
#import "google/protobuf/Any.pbobjc.h"
#import "google/protobuf/Api.pbobjc.h"
#import "google/protobuf/Duration.pbobjc.h"
#import "google/protobuf/Empty.pbobjc.h"
#import "google/protobuf/FieldMask.pbobjc.h"
#import "google/protobuf/SourceContext.pbobjc.h"
#import "google/protobuf/Struct.pbobjc.h"
#import "google/protobuf/Timestamp.pbobjc.h"
#import "google/protobuf/Type.pbobjc.h"
#import "google/protobuf/Wrappers.pbobjc.h"
...@@ -602,6 +602,13 @@ def GoldenFile(filename): ...@@ -602,6 +602,13 @@ def GoldenFile(filename):
return open(full_path, 'rb') return open(full_path, 'rb')
path = os.path.join(path, '..') path = os.path.join(path, '..')
# Search internally.
path = '.'
full_path = os.path.join(path, 'third_party/py/google/protobuf/testdata', filename)
if os.path.exists(full_path):
# Found it. Load the golden file from the testdata directory.
return open(full_path, 'rb')
raise RuntimeError( raise RuntimeError(
'Could not find golden files. This test must be run from within the ' 'Could not find golden files. This test must be run from within the '
'protobuf source package so that it can read test data files from the ' 'protobuf source package so that it can read test data files from the '
......
...@@ -30,6 +30,18 @@ ...@@ -30,6 +30,18 @@
#include "protobuf.h" #include "protobuf.h"
// This function is equivalent to rb_str_cat(), but unlike the real
// rb_str_cat(), it doesn't leak memory in some versions of Ruby.
// For more information, see:
// https://bugs.ruby-lang.org/issues/11328
VALUE noleak_rb_str_cat(VALUE rb_str, const char *str, long len) {
size_t oldlen = RSTRING_LEN(rb_str);
rb_str_modify_expand(rb_str, len);
char *p = RSTRING_PTR(rb_str);
memcpy(p + oldlen, str, len);
rb_str_set_len(rb_str, oldlen + len);
}
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
// Parsing. // Parsing.
// ----------------------------------------------------------------------------- // -----------------------------------------------------------------------------
...@@ -164,7 +176,7 @@ static size_t stringdata_handler(void* closure, const void* hd, ...@@ -164,7 +176,7 @@ static size_t stringdata_handler(void* closure, const void* hd,
const char* str, size_t len, const char* str, size_t len,
const upb_bufhandle* handle) { const upb_bufhandle* handle) {
VALUE rb_str = (VALUE)closure; VALUE rb_str = (VALUE)closure;
rb_str_cat(rb_str, str, len); noleak_rb_str_cat(rb_str, str, len);
return len; return len;
} }
......
...@@ -76,7 +76,6 @@ nobase_include_HEADERS = \ ...@@ -76,7 +76,6 @@ nobase_include_HEADERS = \
google/protobuf/stubs/fastmem.h \ google/protobuf/stubs/fastmem.h \
google/protobuf/stubs/hash.h \ google/protobuf/stubs/hash.h \
google/protobuf/stubs/once.h \ google/protobuf/stubs/once.h \
google/protobuf/stubs/pbconfig.h \
google/protobuf/stubs/platform_macros.h \ google/protobuf/stubs/platform_macros.h \
google/protobuf/stubs/shared_ptr.h \ google/protobuf/stubs/shared_ptr.h \
google/protobuf/stubs/singleton.h \ google/protobuf/stubs/singleton.h \
......
...@@ -2932,7 +2932,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) { ...@@ -2932,7 +2932,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
"commontag", SimpleItoa(WireFormat::MakeTag(field))); "commontag", SimpleItoa(WireFormat::MakeTag(field)));
if (need_label || if (need_label ||
(field->is_repeated() && !field->options().packed() && !loops)) { (field->is_repeated() && !field->is_packed() && !loops)) {
printer->Print( printer->Print(
" parse_$name$:\n", " parse_$name$:\n",
"name", field->name()); "name", field->name());
...@@ -2945,7 +2945,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) { ...@@ -2945,7 +2945,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
} }
printer->Indent(); printer->Indent();
if (field->options().packed()) { if (field->is_packed()) {
field_generator.GenerateMergeFromCodedStreamWithPacking(printer); field_generator.GenerateMergeFromCodedStreamWithPacking(printer);
} else { } else {
field_generator.GenerateMergeFromCodedStream(printer); field_generator.GenerateMergeFromCodedStream(printer);
...@@ -2953,7 +2953,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) { ...@@ -2953,7 +2953,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
printer->Outdent(); printer->Outdent();
// Emit code to parse unexpectedly packed or unpacked values. // Emit code to parse unexpectedly packed or unpacked values.
if (field->is_packable() && field->options().packed()) { if (field->is_packed()) {
internal::WireFormatLite::WireType wiretype = internal::WireFormatLite::WireType wiretype =
WireFormat::WireTypeForFieldType(field->type()); WireFormat::WireTypeForFieldType(field->type());
printer->Print("} else if (tag == $uncommontag$) {\n", printer->Print("} else if (tag == $uncommontag$) {\n",
...@@ -2963,7 +2963,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) { ...@@ -2963,7 +2963,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
printer->Indent(); printer->Indent();
field_generator.GenerateMergeFromCodedStream(printer); field_generator.GenerateMergeFromCodedStream(printer);
printer->Outdent(); printer->Outdent();
} else if (field->is_packable() && !field->options().packed()) { } else if (field->is_packable() && !field->is_packed()) {
internal::WireFormatLite::WireType wiretype = internal::WireFormatLite::WireType wiretype =
internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED; internal::WireFormatLite::WIRETYPE_LENGTH_DELIMITED;
printer->Print("} else if (tag == $uncommontag$) {\n", printer->Print("} else if (tag == $uncommontag$) {\n",
...@@ -2988,7 +2988,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) { ...@@ -2988,7 +2988,7 @@ GenerateMergeFromCodedStream(io::Printer* printer) {
"if (input->ExpectTag($tag$)) goto parse_loop_$name$;\n", "if (input->ExpectTag($tag$)) goto parse_loop_$name$;\n",
"tag", SimpleItoa(WireFormat::MakeTag(field)), "tag", SimpleItoa(WireFormat::MakeTag(field)),
"name", field->name()); "name", field->name());
} else if (field->is_repeated() && !field->options().packed()) { } else if (field->is_repeated() && !field->is_packed()) {
printer->Print( printer->Print(
"if (input->ExpectTag($tag$)) goto parse_$name$;\n", "if (input->ExpectTag($tag$)) goto parse_$name$;\n",
"tag", SimpleItoa(WireFormat::MakeTag(field)), "tag", SimpleItoa(WireFormat::MakeTag(field)),
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <google/protobuf/io/coded_stream.h> #include <google/protobuf/io/coded_stream.h>
#include <google/protobuf/io/printer.h> #include <google/protobuf/io/printer.h>
#include <google/protobuf/io/zero_copy_stream.h> #include <google/protobuf/io/zero_copy_stream.h>
#include <google/protobuf/stubs/mathlimits.h>
#include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/wire_format.h> #include <google/protobuf/wire_format.h>
...@@ -276,11 +277,6 @@ bool FieldGeneratorBase::is_nullable_type() { ...@@ -276,11 +277,6 @@ bool FieldGeneratorBase::is_nullable_type() {
} }
} }
inline bool IsNaN(double value) {
// NaN is never equal to anything, even itself.
return value != value;
}
bool AllPrintableAscii(const std::string& text) { bool AllPrintableAscii(const std::string& text) {
for(int i = 0; i < text.size(); i++) { for(int i = 0; i < text.size(); i++) {
if (text[i] < 0x20 || text[i] > 0x7e) { if (text[i] < 0x20 || text[i] > 0x7e) {
...@@ -313,7 +309,7 @@ std::string FieldGeneratorBase::default_value() { ...@@ -313,7 +309,7 @@ std::string FieldGeneratorBase::default_value() {
return "double.PositiveInfinity"; return "double.PositiveInfinity";
} else if (value == -numeric_limits<double>::infinity()) { } else if (value == -numeric_limits<double>::infinity()) {
return "double.NegativeInfinity"; return "double.NegativeInfinity";
} else if (IsNaN(value)) { } else if (MathLimits<double>::IsNaN(value)) {
return "double.NaN"; return "double.NaN";
} }
return SimpleDtoa(value) + "D"; return SimpleDtoa(value) + "D";
...@@ -324,7 +320,7 @@ std::string FieldGeneratorBase::default_value() { ...@@ -324,7 +320,7 @@ std::string FieldGeneratorBase::default_value() {
return "float.PositiveInfinity"; return "float.PositiveInfinity";
} else if (value == -numeric_limits<float>::infinity()) { } else if (value == -numeric_limits<float>::infinity()) {
return "float.NegativeInfinity"; return "float.NegativeInfinity";
} else if (IsNaN(value)) { } else if (MathLimits<float>::IsNaN(value)) {
return "float.NaN"; return "float.NaN";
} }
return SimpleFtoa(value) + "F"; return SimpleFtoa(value) + "F";
......
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <climits>
#include <fstream> #include <fstream>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
......
...@@ -171,7 +171,7 @@ bool Subprocess::Communicate(const Message& input, Message* output, ...@@ -171,7 +171,7 @@ bool Subprocess::Communicate(const Message& input, Message* output,
DWORD wait_result = DWORD wait_result =
WaitForMultipleObjects(handle_count, handles, FALSE, INFINITE); WaitForMultipleObjects(handle_count, handles, FALSE, INFINITE);
HANDLE signaled_handle; HANDLE signaled_handle = NULL;
if (wait_result >= WAIT_OBJECT_0 && if (wait_result >= WAIT_OBJECT_0 &&
wait_result < WAIT_OBJECT_0 + handle_count) { wait_result < WAIT_OBJECT_0 + handle_count) {
signaled_handle = handles[wait_result - WAIT_OBJECT_0]; signaled_handle = handles[wait_result - WAIT_OBJECT_0];
......
...@@ -168,7 +168,8 @@ class Map { ...@@ -168,7 +168,8 @@ class Map {
} }
} }
#if __cplusplus >= 201103L && !defined(GOOGLE_PROTOBUF_OS_APPLE) #if __cplusplus >= 201103L && !defined(GOOGLE_PROTOBUF_OS_APPLE) && \
!defined(GOOGLE_PROTOBUF_OS_NACL) && !defined(GOOGLE_PROTOBUF_OS_ANDROID)
template<class NodeType, class... Args> template<class NodeType, class... Args>
void construct(NodeType* p, Args&&... args) { void construct(NodeType* p, Args&&... args) {
new (p) NodeType(std::forward<Args>(args)...); new (p) NodeType(std::forward<Args>(args)...);
......
...@@ -162,7 +162,19 @@ class MapEntryLite : public MessageLite { ...@@ -162,7 +162,19 @@ class MapEntryLite : public MessageLite {
if (!KeyWireHandler::Read(input, mutable_key())) return false; if (!KeyWireHandler::Read(input, mutable_key())) return false;
set_has_key(); set_has_key();
if (!input->ExpectTag(kValueTag)) break; if (!input->ExpectTag(kValueTag)) break;
// BEGIN GOOGLE LOCAL MODIFICATION
// Add __has_cpp_attribute and NaCl and Emscripten checks.
#if defined(__clang__) && defined(__has_cpp_attribute) \
&& !defined(GOOGLE_PROTOBUF_OS_APPLE)
#if defined(GOOGLE_PROTOBUF_OS_NACL) || defined(EMSCRIPTEN)
[[clang::fallthrough]];
#elif __has_cpp_attribute(clang::fallthrough)
[[clang::fallthrough]];
#endif
#else
GOOGLE_FALLTHROUGH_INTENDED; GOOGLE_FALLTHROUGH_INTENDED;
#endif
// END GOOGLE LOCAL MODIFICATION
case kValueTag: case kValueTag:
if (!ValueWireHandler::Read(input, mutable_value())) return false; if (!ValueWireHandler::Read(input, mutable_value())) return false;
......
...@@ -61,7 +61,7 @@ inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr, ...@@ -61,7 +61,7 @@ inline Atomic32 Barrier_AtomicIncrement(volatile Atomic32* ptr,
inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr, inline Atomic32 Acquire_CompareAndSwap(volatile Atomic32* ptr,
Atomic32 old_value, Atomic32 old_value,
Atomic32 new_value) { Atomic32 new_value) {
__atomic_compare_exchange(ptr, &old_value, &new_value, true, __atomic_compare_exchange_n(ptr, &old_value, new_value, true,
__ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE); __ATOMIC_ACQUIRE, __ATOMIC_ACQUIRE);
return old_value; return old_value;
} }
......
...@@ -203,14 +203,22 @@ typedef unsigned __int16 uint16; ...@@ -203,14 +203,22 @@ typedef unsigned __int16 uint16;
typedef unsigned __int32 uint32; typedef unsigned __int32 uint32;
typedef unsigned __int64 uint64; typedef unsigned __int64 uint64;
#else #else
typedef int8_t int8; typedef signed char int8;
typedef int16_t int16; typedef short int16;
typedef int32_t int32; typedef int int32;
// NOTE: This should be "long long" for consistency with upstream, but
// something is stacked against this particular type for 64bit hashing.
// Switching it causes an obvious missing hash function (with an unobvious
// cause) when building the tests.
typedef int64_t int64; typedef int64_t int64;
typedef uint8_t uint8; typedef unsigned char uint8;
typedef uint16_t uint16; typedef unsigned short uint16;
typedef uint32_t uint32; typedef unsigned int uint32;
// NOTE: This should be "unsigned long long" for consistency with upstream, but
// something is stacked against this particular type for 64bit hashing.
// Switching it causes an obvious missing hash function (with an unobvious
// cause) when building the tests.
typedef uint64_t uint64; typedef uint64_t uint64;
#endif #endif
...@@ -1459,14 +1467,14 @@ static inline uint32 bswap_32(uint32 x) { ...@@ -1459,14 +1467,14 @@ static inline uint32 bswap_32(uint32 x) {
} }
#define bswap_32(x) bswap_32(x) #define bswap_32(x) bswap_32(x)
static inline uint64 bswap_64(uint64 x) { static inline uint64 bswap_64(uint64 x) {
return (((x & GG_ULONGLONG(0xFF)) << 56) | return (((x & GOOGLE_ULONGLONG(0xFF)) << 56) |
((x & GG_ULONGLONG(0xFF00)) << 40) | ((x & GOOGLE_ULONGLONG(0xFF00)) << 40) |
((x & GG_ULONGLONG(0xFF0000)) << 24) | ((x & GOOGLE_ULONGLONG(0xFF0000)) << 24) |
((x & GG_ULONGLONG(0xFF000000)) << 8) | ((x & GOOGLE_ULONGLONG(0xFF000000)) << 8) |
((x & GG_ULONGLONG(0xFF00000000)) >> 8) | ((x & GOOGLE_ULONGLONG(0xFF00000000)) >> 8) |
((x & GG_ULONGLONG(0xFF0000000000)) >> 24) | ((x & GOOGLE_ULONGLONG(0xFF0000000000)) >> 24) |
((x & GG_ULONGLONG(0xFF000000000000)) >> 40) | ((x & GOOGLE_ULONGLONG(0xFF000000000000)) >> 40) |
((x & GG_ULONGLONG(0xFF00000000000000)) >> 56)); ((x & GOOGLE_ULONGLONG(0xFF00000000000000)) >> 56));
} }
#define bswap_64(x) bswap_64(x) #define bswap_64(x) bswap_64(x)
......
...@@ -37,12 +37,117 @@ ...@@ -37,12 +37,117 @@
#include <string.h> #include <string.h>
#include <google/protobuf/stubs/common.h> #include <google/protobuf/stubs/common.h>
#include <google/protobuf/stubs/pbconfig.h>
#define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1
#define GOOGLE_PROTOBUF_HAVE_HASH_SET 1
// Use C++11 unordered_{map|set} if available. Otherwise, libc++ always support
// unordered_{map|set}
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X) || \
defined(_LIBCPP_VERSION)
# define GOOGLE_PROTOBUF_HAS_CXX11_HASH
// For XCode >= 4.6: the compiler is clang with libc++.
// For earlier XCode version: the compiler is gcc-4.2.1 with libstdc++.
// libc++ provides <unordered_map> and friends even in non C++11 mode,
// and it does not provide the tr1 library. Therefore the following macro
// checks against this special case.
// Note that we should not test the __APPLE_CC__ version number or the
// __clang__ macro, since the new compiler can still use -stdlib=libstdc++, in
// which case <unordered_map> is not compilable without -std=c++11
#elif defined(__APPLE_CC__)
# if __GNUC__ >= 4
# define GOOGLE_PROTOBUF_HAS_TR1
# else
// Not tested for gcc < 4... These setting can compile under 4.2.1 though.
# define GOOGLE_PROTOBUF_HASH_NAMESPACE __gnu_cxx
# include <ext/hash_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
# include <ext/hash_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# endif
// Version checks for gcc.
#elif defined(__GNUC__)
// For GCC 4.x+, use tr1::unordered_map/set; otherwise, follow the
// instructions from:
// https://gcc.gnu.org/onlinedocs/libstdc++/manual/backwards.html
# if __GNUC__ >= 4
# define GOOGLE_PROTOBUF_HAS_TR1
# elif __GNUC__ >= 3
# include <backward/hash_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
# include <backward/hash_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# if __GNUC__ == 3 && __GNUC_MINOR__ == 0
# define GOOGLE_PROTOBUF_HASH_NAMESPACE std // GCC 3.0
# else
# define GOOGLE_PROTOBUF_HASH_NAMESPACE __gnu_cxx // GCC 3.1 and later
# endif
# else
# define GOOGLE_PROTOBUF_HASH_NAMESPACE
# include <hash_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
# include <hash_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# endif
// Version checks for MSC.
// Apparently Microsoft decided to move hash_map *back* to the std namespace in
// MSVC 2010:
// http://blogs.msdn.com/vcblog/archive/2009/05/25/stl-breaking-changes-in-visual-studio-2010-beta-1.aspx
// And.. they are moved back to stdext in MSVC 2013 (haven't checked 2012). That
// said, use unordered_map for MSVC 2010 and beyond is our safest bet.
#elif defined(_MSC_VER)
# if _MSC_VER >= 1600 // Since Visual Studio 2010
# define GOOGLE_PROTOBUF_HAS_CXX11_HASH
# define GOOGLE_PROTOBUF_HASH_COMPARE std::hash_compare
# elif _MSC_VER >= 1500 // Since Visual Studio 2008
# define GOOGLE_PROTOBUF_HAS_TR1
# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare
# elif _MSC_VER >= 1310
# define GOOGLE_PROTOBUF_HASH_NAMESPACE stdext
# include <hash_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
# include <hash_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare
# else
# define GOOGLE_PROTOBUF_HASH_NAMESPACE std
# include <hash_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
# include <hash_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare
# endif
// **ADD NEW COMPILERS SUPPORT HERE.**
// For other compilers, undefine the macro and fallback to use std::map, in
// google/protobuf/stubs/hash.h
#else
# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP
# undef GOOGLE_PROTOBUF_HAVE_HASH_SET
#endif
#if defined(GOOGLE_PROTOBUF_HAS_CXX11_HASH)
# define GOOGLE_PROTOBUF_HASH_NAMESPACE std
# include <unordered_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS unordered_map
# include <unordered_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set
#elif defined(GOOGLE_PROTOBUF_HAS_TR1)
# define GOOGLE_PROTOBUF_HASH_NAMESPACE std::tr1
# include <tr1/unordered_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS unordered_map
# include <tr1/unordered_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set
#endif
#undef GOOGLE_PROTOBUF_HAS_CXX11_HASH
#undef GOOGLE_PROTOBUF_HAS_TR1
#if defined(GOOGLE_PROTOBUF_HAVE_HASH_MAP) && \ #if defined(GOOGLE_PROTOBUF_HAVE_HASH_MAP) && \
defined(GOOGLE_PROTOBUF_HAVE_HASH_SET) defined(GOOGLE_PROTOBUF_HAVE_HASH_SET)
#include GOOGLE_PROTOBUF_HASH_MAP_H
#include GOOGLE_PROTOBUF_HASH_SET_H
#else #else
#define GOOGLE_PROTOBUF_MISSING_HASH #define GOOGLE_PROTOBUF_MISSING_HASH
#include <map> #include <map>
...@@ -92,13 +197,13 @@ template <typename Key, typename Data, ...@@ -92,13 +197,13 @@ template <typename Key, typename Data,
typename HashFcn = hash<Key>, typename HashFcn = hash<Key>,
typename EqualKey = std::equal_to<Key>, typename EqualKey = std::equal_to<Key>,
typename Alloc = std::allocator< std::pair<const Key, Data> > > typename Alloc = std::allocator< std::pair<const Key, Data> > >
class hash_map : public std::map<Key, Data, HashFcn, EqualKey, Alloc> { class hash_map : public std::map<Key, Data, HashFcn, Alloc> {
typedef std::map<Key, Data, HashFcn, EqualKey, Alloc> BaseClass; typedef std::map<Key, Data, HashFcn, Alloc> BaseClass;
public: public:
hash_map(int a = 0, const HashFcn& b = HashFcn(), hash_map(int a = 0, const HashFcn& b = HashFcn(),
const EqualKey& c = EqualKey(), const EqualKey& c = EqualKey(),
const Alloc& d = Alloc()) : BaseClass(a, b, c, d) {} const Alloc& d = Alloc()) : BaseClass(b, d) {}
}; };
template <typename Key, template <typename Key,
......
// 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.
#ifndef GOOGLE_PROTOBUF_STUBS_PBCONFIG_H__
#define GOOGLE_PROTOBUF_STUBS_PBCONFIG_H__
#define GOOGLE_PROTOBUF_HAVE_HASH_MAP 1
#define GOOGLE_PROTOBUF_HAVE_HASH_SET 1
// Use C++11 unordered_{map|set} if available.
#if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X)
# define GOOGLE_PROTOBUF_HAS_CXX11_HASH
// For XCode >= 4.6: the compiler is clang with libc++.
// For earlier XCode version: the compiler is gcc-4.2.1 with libstdc++.
// libc++ provides <unordered_map> and friends even in non C++11 mode,
// and it does not provide the tr1 library. Therefore the following macro
// checks against this special case.
// Note that we should not test the __APPLE_CC__ version number or the
// __clang__ macro, since the new compiler can still use -stdlib=libstdc++, in
// which case <unordered_map> is not compilable without -std=c++11
#elif defined(__APPLE_CC__)
# if defined(_LIBCPP_VERSION)
# define GOOGLE_PROTOBUF_HAS_CXX11_HASH
# elif __GNUC__ >= 4
# define GOOGLE_PROTOBUF_HAS_TR1
# else
// Not tested for gcc < 4... These setting can compile under 4.2.1 though.
# define GOOGLE_PROTOBUF_HASH_NAMESPACE __gnu_cxx
# define GOOGLE_PROTOBUF_HASH_MAP_H <ext/hash_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
# define GOOGLE_PROTOBUF_HASH_SET_H <ext/hash_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# endif
// Version checks for gcc.
#elif defined(__GNUC__)
// For GCC 4.x+, use tr1::unordered_map/set; otherwise, follow the
// instructions from:
// https://gcc.gnu.org/onlinedocs/libstdc++/manual/backwards.html
# if __GNUC__ >= 4
# define GOOGLE_PROTOBUF_HAS_TR1
# elif __GNUC__ >= 3
# define GOOGLE_PROTOBUF_HASH_MAP_H <backward/hash_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
# define GOOGLE_PROTOBUF_HASH_SET_H <backward/hash_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# if __GNUC__ == 3 && __GNUC_MINOR__ == 0
# define GOOGLE_PROTOBUF_HASH_NAMESPACE std // GCC 3.0
# else
# define GOOGLE_PROTOBUF_HASH_NAMESPACE __gnu_cxx // GCC 3.1 and later
# endif
# else
# define GOOGLE_PROTOBUF_HASH_NAMESPACE
# define GOOGLE_PROTOBUF_HASH_MAP_H <hash_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
# define GOOGLE_PROTOBUF_HASH_SET_H <hash_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# endif
// Version checks for MSC.
// Apparently Microsoft decided to move hash_map *back* to the std namespace in
// MSVC 2010:
// http://blogs.msdn.com/vcblog/archive/2009/05/25/stl-breaking-changes-in-visual-studio-2010-beta-1.aspx
// And.. they are moved back to stdext in MSVC 2013 (haven't checked 2012). That
// said, use unordered_map for MSVC 2010 and beyond is our safest bet.
#elif defined(_MSC_VER)
# if _MSC_VER >= 1600 // Since Visual Studio 2010
# define GOOGLE_PROTOBUF_HAS_CXX11_HASH
# define GOOGLE_PROTOBUF_HASH_COMPARE std::hash_compare
# elif _MSC_VER >= 1500 // Since Visual Studio 2008
# define GOOGLE_PROTOBUF_HAS_TR1
# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare
# elif _MSC_VER >= 1310
# define GOOGLE_PROTOBUF_HASH_NAMESPACE stdext
# define GOOGLE_PROTOBUF_HASH_MAP_H <hash_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
# define GOOGLE_PROTOBUF_HASH_SET_H <hash_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare
# else
# define GOOGLE_PROTOBUF_HASH_NAMESPACE std
# define GOOGLE_PROTOBUF_HASH_MAP_H <hash_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS hash_map
# define GOOGLE_PROTOBUF_HASH_SET_H <hash_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS hash_set
# define GOOGLE_PROTOBUF_HASH_COMPARE stdext::hash_compare
# endif
// **ADD NEW COMPILERS SUPPORT HERE.**
// For other compilers, undefine the macro and fallback to use std::map, in
// google/protobuf/stubs/hash.h
#else
# undef GOOGLE_PROTOBUF_HAVE_HASH_MAP
# undef GOOGLE_PROTOBUF_HAVE_HASH_SET
#endif
#if defined(GOOGLE_PROTOBUF_HAS_CXX11_HASH)
# define GOOGLE_PROTOBUF_HASH_NAMESPACE std
# define GOOGLE_PROTOBUF_HASH_MAP_H <unordered_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS unordered_map
# define GOOGLE_PROTOBUF_HASH_SET_H <unordered_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set
#elif defined(GOOGLE_PROTOBUF_HAS_TR1)
# define GOOGLE_PROTOBUF_HASH_NAMESPACE std::tr1
# define GOOGLE_PROTOBUF_HASH_MAP_H <tr1/unordered_map>
# define GOOGLE_PROTOBUF_HASH_MAP_CLASS unordered_map
# define GOOGLE_PROTOBUF_HASH_SET_H <tr1/unordered_set>
# define GOOGLE_PROTOBUF_HASH_SET_CLASS unordered_set
#endif
#undef GOOGLE_PROTOBUF_HAS_CXX11_HASH
#undef GOOGLE_PROTOBUF_HAS_TR1
#endif // GOOGLE_PROTOBUF_STUBS_PBCONFIG_H__
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
// from google3/strings/strutil.cc // from google3/strings/strutil.cc
#include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/mathlimits.h>
#include <errno.h> #include <errno.h>
#include <float.h> // FLT_DIG and DBL_DIG #include <float.h> // FLT_DIG and DBL_DIG
...@@ -58,11 +59,6 @@ ...@@ -58,11 +59,6 @@
namespace google { namespace google {
namespace protobuf { namespace protobuf {
inline bool IsNaN(double value) {
// NaN is never equal to anything, even itself.
return value != value;
}
// These are defined as macros on some platforms. #undef them so that we can // These are defined as macros on some platforms. #undef them so that we can
// redefine them. // redefine them.
#undef isxdigit #undef isxdigit
...@@ -1210,7 +1206,7 @@ char* DoubleToBuffer(double value, char* buffer) { ...@@ -1210,7 +1206,7 @@ char* DoubleToBuffer(double value, char* buffer) {
} else if (value == -numeric_limits<double>::infinity()) { } else if (value == -numeric_limits<double>::infinity()) {
strcpy(buffer, "-inf"); strcpy(buffer, "-inf");
return buffer; return buffer;
} else if (IsNaN(value)) { } else if (MathLimits<double>::IsNaN(value)) {
strcpy(buffer, "nan"); strcpy(buffer, "nan");
return buffer; return buffer;
} }
...@@ -1328,7 +1324,7 @@ char* FloatToBuffer(float value, char* buffer) { ...@@ -1328,7 +1324,7 @@ char* FloatToBuffer(float value, char* buffer) {
} else if (value == -numeric_limits<double>::infinity()) { } else if (value == -numeric_limits<double>::infinity()) {
strcpy(buffer, "-inf"); strcpy(buffer, "-inf");
return buffer; return buffer;
} else if (IsNaN(value)) { } else if (MathLimits<float>::IsNaN(value)) {
strcpy(buffer, "nan"); strcpy(buffer, "nan");
return buffer; return buffer;
} }
......
...@@ -43,6 +43,15 @@ ...@@ -43,6 +43,15 @@
#include <stdlib.h> #include <stdlib.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef _WIN32
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#endif
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif
#endif
#include <google/protobuf/io/gzip_stream.h> #include <google/protobuf/io/gzip_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/io/zero_copy_stream_impl.h>
......
...@@ -42,6 +42,15 @@ ...@@ -42,6 +42,15 @@
#include <stdlib.h> #include <stdlib.h>
#include <fcntl.h> #include <fcntl.h>
#ifdef _WIN32
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#endif
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif
#endif
#include <google/protobuf/io/gzip_stream.h> #include <google/protobuf/io/gzip_stream.h>
#include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/io/zero_copy_stream_impl.h>
......
...@@ -46,6 +46,7 @@ ...@@ -46,6 +46,7 @@
#include <google/protobuf/io/tokenizer.h> #include <google/protobuf/io/tokenizer.h>
#include <google/protobuf/io/zero_copy_stream_impl.h> #include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/mathlimits.h>
#include <google/protobuf/stubs/substitute.h> #include <google/protobuf/stubs/substitute.h>
#include <google/protobuf/testing/googletest.h> #include <google/protobuf/testing/googletest.h>
#include <gtest/gtest.h> #include <gtest/gtest.h>
...@@ -57,11 +58,6 @@ namespace protobuf { ...@@ -57,11 +58,6 @@ namespace protobuf {
// Can't use an anonymous namespace here due to brokenness of Tru64 compiler. // Can't use an anonymous namespace here due to brokenness of Tru64 compiler.
namespace text_format_unittest { namespace text_format_unittest {
inline bool IsNaN(double value) {
// NaN is never equal to anything, even itself.
return value != value;
}
// A basic string with different escapable characters for testing. // A basic string with different escapable characters for testing.
const string kEscapeTestString = const string kEscapeTestString =
"\"A string with ' characters \n and \r newlines and \t tabs and \001 " "\"A string with ' characters \n and \r newlines and \t tabs and \001 "
...@@ -898,8 +894,8 @@ TEST_F(TextFormatTest, ParseExotic) { ...@@ -898,8 +894,8 @@ TEST_F(TextFormatTest, ParseExotic) {
EXPECT_EQ(message.repeated_double(8), numeric_limits<double>::infinity()); EXPECT_EQ(message.repeated_double(8), numeric_limits<double>::infinity());
EXPECT_EQ(message.repeated_double(9), -numeric_limits<double>::infinity()); EXPECT_EQ(message.repeated_double(9), -numeric_limits<double>::infinity());
EXPECT_EQ(message.repeated_double(10), -numeric_limits<double>::infinity()); EXPECT_EQ(message.repeated_double(10), -numeric_limits<double>::infinity());
EXPECT_TRUE(IsNaN(message.repeated_double(11))); EXPECT_TRUE(MathLimits<double>::IsNaN(message.repeated_double(11)));
EXPECT_TRUE(IsNaN(message.repeated_double(12))); EXPECT_TRUE(MathLimits<double>::IsNaN(message.repeated_double(12)));
// Note: Since these string literals have \0's in them, we must explicitly // Note: Since these string literals have \0's in them, we must explicitly
// pass their sizes to string's constructor. // pass their sizes to string's constructor.
......
...@@ -50,8 +50,13 @@ namespace { ...@@ -50,8 +50,13 @@ namespace {
// instantiate the UnknownFieldSet dynamically only when required. // instantiate the UnknownFieldSet dynamically only when required.
UnknownFieldSet* default_unknown_field_set_instance_ = NULL; UnknownFieldSet* default_unknown_field_set_instance_ = NULL;
void DeleteDefaultUnknownFieldSet() {
delete default_unknown_field_set_instance_;
}
void InitDefaultUnknownFieldSet() { void InitDefaultUnknownFieldSet() {
default_unknown_field_set_instance_ = new UnknownFieldSet(); default_unknown_field_set_instance_ = new UnknownFieldSet();
internal::OnShutdown(&DeleteDefaultUnknownFieldSet);
} }
GOOGLE_PROTOBUF_DECLARE_ONCE(default_unknown_field_set_once_init_); GOOGLE_PROTOBUF_DECLARE_ONCE(default_unknown_field_set_once_init_);
......
...@@ -106,6 +106,7 @@ FieldComparator::ComparisonResult DefaultFieldComparator::Compare( ...@@ -106,6 +106,7 @@ FieldComparator::ComparisonResult DefaultFieldComparator::Compare(
default: default:
GOOGLE_LOG(FATAL) << "No comparison code for field " << field->full_name() GOOGLE_LOG(FATAL) << "No comparison code for field " << field->full_name()
<< " of CppType = " << field->cpp_type(); << " of CppType = " << field->cpp_type();
return DIFFERENT;
} }
} }
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
#include <google/protobuf/util/internal/utility.h> #include <google/protobuf/util/internal/utility.h>
#include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/mathutil.h> #include <google/protobuf/stubs/mathutil.h>
#include <google/protobuf/stubs/mathlimits.h>
namespace google { namespace google {
namespace protobuf { namespace protobuf {
...@@ -78,7 +79,7 @@ StatusOr<To> NumberConvertAndCheck(From before) { ...@@ -78,7 +79,7 @@ StatusOr<To> NumberConvertAndCheck(From before) {
// For conversion between double and float only. // For conversion between double and float only.
template <typename To, typename From> template <typename To, typename From>
StatusOr<To> FloatingPointConvertAndCheck(From before) { StatusOr<To> FloatingPointConvertAndCheck(From before) {
if (isnan(before)) return std::numeric_limits<To>::quiet_NaN(); if (MathLimits<From>::IsNaN(before)) return std::numeric_limits<To>::quiet_NaN();
To after = static_cast<To>(before); To after = static_cast<To>(before);
if (MathUtil::AlmostEquals<To>(after, before)) { if (MathUtil::AlmostEquals<To>(after, before)) {
......
...@@ -97,6 +97,7 @@ ProtoStreamObjectSource* TypeInfoTestHelper::NewProtoSource( ...@@ -97,6 +97,7 @@ ProtoStreamObjectSource* TypeInfoTestHelper::NewProtoSource(
} }
} }
GOOGLE_LOG(FATAL) << "Can not reach here."; GOOGLE_LOG(FATAL) << "Can not reach here.";
return NULL;
} }
ProtoStreamObjectWriter* TypeInfoTestHelper::NewProtoWriter( ProtoStreamObjectWriter* TypeInfoTestHelper::NewProtoWriter(
...@@ -110,6 +111,7 @@ ProtoStreamObjectWriter* TypeInfoTestHelper::NewProtoWriter( ...@@ -110,6 +111,7 @@ ProtoStreamObjectWriter* TypeInfoTestHelper::NewProtoWriter(
} }
} }
GOOGLE_LOG(FATAL) << "Can not reach here."; GOOGLE_LOG(FATAL) << "Can not reach here.";
return NULL;
} }
DefaultValueObjectWriter* TypeInfoTestHelper::NewDefaultValueWriter( DefaultValueObjectWriter* TypeInfoTestHelper::NewDefaultValueWriter(
...@@ -121,6 +123,7 @@ DefaultValueObjectWriter* TypeInfoTestHelper::NewDefaultValueWriter( ...@@ -121,6 +123,7 @@ DefaultValueObjectWriter* TypeInfoTestHelper::NewDefaultValueWriter(
} }
} }
GOOGLE_LOG(FATAL) << "Can not reach here."; GOOGLE_LOG(FATAL) << "Can not reach here.";
return NULL;
} }
} // namespace testing } // namespace testing
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include <google/protobuf/util/internal/constants.h> #include <google/protobuf/util/internal/constants.h>
#include <google/protobuf/stubs/strutil.h> #include <google/protobuf/stubs/strutil.h>
#include <google/protobuf/stubs/map_util.h> #include <google/protobuf/stubs/map_util.h>
#include <google/protobuf/stubs/mathlimits.h>
namespace google { namespace google {
namespace protobuf { namespace protobuf {
...@@ -302,7 +303,7 @@ bool IsMap(const google::protobuf::Field& field, ...@@ -302,7 +303,7 @@ bool IsMap(const google::protobuf::Field& field,
string DoubleAsString(double value) { string DoubleAsString(double value) {
if (value == std::numeric_limits<double>::infinity()) return "Infinity"; if (value == std::numeric_limits<double>::infinity()) return "Infinity";
if (value == -std::numeric_limits<double>::infinity()) return "-Infinity"; if (value == -std::numeric_limits<double>::infinity()) return "-Infinity";
if (::isnan(value)) return "NaN"; if (google::protobuf::MathLimits<double>::IsNaN(value)) return "NaN";
return SimpleDtoa(value); return SimpleDtoa(value);
} }
......
...@@ -289,20 +289,11 @@ class LIBPROTOBUF_EXPORT MessageDifferencer { ...@@ -289,20 +289,11 @@ class LIBPROTOBUF_EXPORT MessageDifferencer {
MapKeyComparator(); MapKeyComparator();
virtual ~MapKeyComparator(); virtual ~MapKeyComparator();
// The first IsMatch without parent_fields is only for backward
// compatibility. New users should override the second one instead.
//
// Deprecated.
// TODO(ykzhu): remove this function.
virtual bool IsMatch(const Message& message1,
const Message& message2) const {
GOOGLE_CHECK(false) << "This function shouldn't get called";
return false;
}
virtual bool IsMatch(const Message& message1, virtual bool IsMatch(const Message& message1,
const Message& message2, const Message& message2,
const vector<SpecificField>& parent_fields) const { const vector<SpecificField>& parent_fields) const {
return IsMatch(message1, message2); GOOGLE_CHECK(false) << "IsMatch() is not implemented.";
return false;
} }
private: private:
......
...@@ -290,7 +290,7 @@ class LIBPROTOBUF_EXPORT UnknownFieldSetFieldSkipper : public FieldSkipper { ...@@ -290,7 +290,7 @@ class LIBPROTOBUF_EXPORT UnknownFieldSetFieldSkipper : public FieldSkipper {
inline WireFormatLite::WireType WireFormat::WireTypeForField( inline WireFormatLite::WireType WireFormat::WireTypeForField(
const FieldDescriptor* field) { const FieldDescriptor* field) {
if (field->options().packed()) { if (field->is_packed()) {
return WireFormatLite::WIRETYPE_LENGTH_DELIMITED; return WireFormatLite::WIRETYPE_LENGTH_DELIMITED;
} else { } else {
return WireTypeForFieldType(field->type()); return WireTypeForFieldType(field->type());
......
...@@ -795,9 +795,73 @@ TEST(WireFormatTest, CompatibleTypes) { ...@@ -795,9 +795,73 @@ TEST(WireFormatTest, CompatibleTypes) {
ASSERT_EQ(static_cast<uint32>(data), msg5.data()); ASSERT_EQ(static_cast<uint32>(data), msg5.data());
} }
class Proto3PrimitiveRepeatedWireFormatTest class Proto3PrimitiveRepeatedWireFormatTest : public ::testing::Test {
: public ::testing::TestWithParam<bool> {
protected: protected:
Proto3PrimitiveRepeatedWireFormatTest()
: packedTestAllTypes_(
"\xFA\x01\x01\x01"
"\x82\x02\x01\x01"
"\x8A\x02\x01\x01"
"\x92\x02\x01\x01"
"\x9A\x02\x01\x02"
"\xA2\x02\x01\x02"
"\xAA\x02\x04\x01\x00\x00\x00"
"\xB2\x02\x08\x01\x00\x00\x00\x00\x00\x00\x00"
"\xBA\x02\x04\x01\x00\x00\x00"
"\xC2\x02\x08\x01\x00\x00\x00\x00\x00\x00\x00"
"\xCA\x02\x04\x00\x00\x80\x3f"
"\xD2\x02\x08\x00\x00\x00\x00\x00\x00\xf0\x3f"
"\xDA\x02\x01\x01"
"\x9A\x03\x01\x01",
86),
packedTestUnpackedTypes_(
"\x0A\x01\x01"
"\x12\x01\x01"
"\x1A\x01\x01"
"\x22\x01\x01"
"\x2A\x01\x02"
"\x32\x01\x02"
"\x3A\x04\x01\x00\x00\x00"
"\x42\x08\x01\x00\x00\x00\x00\x00\x00\x00"
"\x4A\x04\x01\x00\x00\x00"
"\x52\x08\x01\x00\x00\x00\x00\x00\x00\x00"
"\x5A\x04\x00\x00\x80\x3f"
"\x62\x08\x00\x00\x00\x00\x00\x00\xf0\x3f"
"\x6A\x01\x01"
"\x72\x01\x01",
72),
unpackedTestAllTypes_(
"\xF8\x01\x01"
"\x80\x02\x01"
"\x88\x02\x01"
"\x90\x02\x01"
"\x98\x02\x02"
"\xA0\x02\x02"
"\xAD\x02\x01\x00\x00\x00"
"\xB1\x02\x01\x00\x00\x00\x00\x00\x00\x00"
"\xBD\x02\x01\x00\x00\x00"
"\xC1\x02\x01\x00\x00\x00\x00\x00\x00\x00"
"\xCD\x02\x00\x00\x80\x3f"
"\xD1\x02\x00\x00\x00\x00\x00\x00\xf0\x3f"
"\xD8\x02\x01"
"\x98\x03\x01",
72),
unpackedTestUnpackedTypes_(
"\x08\x01"
"\x10\x01"
"\x18\x01"
"\x20\x01"
"\x28\x02"
"\x30\x02"
"\x3D\x01\x00\x00\x00"
"\x41\x01\x00\x00\x00\x00\x00\x00\x00"
"\x4D\x01\x00\x00\x00"
"\x51\x01\x00\x00\x00\x00\x00\x00\x00"
"\x5D\x00\x00\x80\x3f"
"\x61\x00\x00\x00\x00\x00\x00\xf0\x3f"
"\x68\x01"
"\x70\x01",
58) {}
template <class Proto> template <class Proto>
void SetProto3PrimitiveRepeatedFields(Proto* message) { void SetProto3PrimitiveRepeatedFields(Proto* message) {
message->add_repeated_int32(1); message->add_repeated_int32(1);
...@@ -837,8 +901,7 @@ class Proto3PrimitiveRepeatedWireFormatTest ...@@ -837,8 +901,7 @@ class Proto3PrimitiveRepeatedWireFormatTest
} }
template <class Proto> template <class Proto>
void TestProto3PrimitiveRepeatedFields(Proto* message, void TestSerialization(Proto* message, const string& expected) {
const string& expected) {
SetProto3PrimitiveRepeatedFields(message); SetProto3PrimitiveRepeatedFields(message);
int size = message->ByteSize(); int size = message->ByteSize();
...@@ -851,13 +914,8 @@ class Proto3PrimitiveRepeatedWireFormatTest ...@@ -851,13 +914,8 @@ class Proto3PrimitiveRepeatedWireFormatTest
message->SerializeWithCachedSizes(&output); message->SerializeWithCachedSizes(&output);
ASSERT_FALSE(output.HadError()); ASSERT_FALSE(output.HadError());
} }
EXPECT_TRUE(expected == generated_data); EXPECT_TRUE(expected == generated_data);
message->Clear();
message->ParseFromString(generated_data);
ExpectProto3PrimitiveRepeatedFieldsSet(*message);
// Serialize using the dynamic code. // Serialize using the dynamic code.
string dynamic_data; string dynamic_data;
{ {
...@@ -866,64 +924,38 @@ class Proto3PrimitiveRepeatedWireFormatTest ...@@ -866,64 +924,38 @@ class Proto3PrimitiveRepeatedWireFormatTest
WireFormat::SerializeWithCachedSizes(*message, size, &output); WireFormat::SerializeWithCachedSizes(*message, size, &output);
ASSERT_FALSE(output.HadError()); ASSERT_FALSE(output.HadError());
} }
EXPECT_TRUE(expected == dynamic_data); EXPECT_TRUE(expected == dynamic_data);
}
template <class Proto>
void TestParsing(Proto* message, const string& compatible_data) {
message->Clear();
message->ParseFromString(compatible_data);
ExpectProto3PrimitiveRepeatedFieldsSet(*message);
message->Clear(); message->Clear();
io::CodedInputStream input( io::CodedInputStream input(
reinterpret_cast<const uint8*>(dynamic_data.data()), reinterpret_cast<const uint8*>(compatible_data.data()),
dynamic_data.size()); compatible_data.size());
WireFormat::ParseAndMergePartial(&input, message); WireFormat::ParseAndMergePartial(&input, message);
ExpectProto3PrimitiveRepeatedFieldsSet(*message); ExpectProto3PrimitiveRepeatedFieldsSet(*message);
} }
const string packedTestAllTypes_;
const string packedTestUnpackedTypes_;
const string unpackedTestAllTypes_;
const string unpackedTestUnpackedTypes_;
}; };
INSTANTIATE_TEST_CASE_P(SetPacked,
Proto3PrimitiveRepeatedWireFormatTest,
::testing::Values(false, true));
TEST_P(Proto3PrimitiveRepeatedWireFormatTest, Proto3PrimitiveRepeated) { TEST_F(Proto3PrimitiveRepeatedWireFormatTest, Proto3PrimitiveRepeated) {
proto3_arena_unittest::TestAllTypes packed_message; proto3_arena_unittest::TestAllTypes packed_message;
proto3_arena_unittest::TestUnpackedTypes unpacked_message; proto3_arena_unittest::TestUnpackedTypes unpacked_message;
TestSerialization(&packed_message, packedTestAllTypes_);
const string packedExpected( TestParsing(&packed_message, packedTestAllTypes_);
"\xFA\x01\x01\x01" TestParsing(&packed_message, unpackedTestAllTypes_);
"\x82\x02\x01\x01" TestSerialization(&unpacked_message, unpackedTestUnpackedTypes_);
"\x8A\x02\x01\x01" TestParsing(&unpacked_message, packedTestUnpackedTypes_);
"\x92\x02\x01\x01" TestParsing(&unpacked_message, unpackedTestUnpackedTypes_);
"\x9A\x02\x01\x02"
"\xA2\x02\x01\x02"
"\xAA\x02\x04\x01\x00\x00\x00"
"\xB2\x02\x08\x01\x00\x00\x00\x00\x00\x00\x00"
"\xBA\x02\x04\x01\x00\x00\x00"
"\xC2\x02\x08\x01\x00\x00\x00\x00\x00\x00\x00"
"\xCA\x02\x04\x00\x00\x80\x3f"
"\xD2\x02\x08\x00\x00\x00\x00\x00\x00\xf0\x3f"
"\xDA\x02\x01\x01"
"\x9A\x03\x01\x01",
86);
const string unpackedExpected(
"\x08\x01"
"\x10\x01"
"\x18\x01"
"\x20\x01"
"\x28\x02"
"\x30\x02"
"\x3D\x01\x00\x00\x00"
"\x41\x01\x00\x00\x00\x00\x00\x00\x00"
"\x4D\x01\x00\x00\x00"
"\x51\x01\x00\x00\x00\x00\x00\x00\x00"
"\x5D\x00\x00\x80\x3f"
"\x61\x00\x00\x00\x00\x00\x00\xf0\x3f"
"\x68\x01"
"\x70\x01",
58);
if (GetParam()) {
TestProto3PrimitiveRepeatedFields(&packed_message, packedExpected);
} else {
TestProto3PrimitiveRepeatedFields(&unpacked_message, unpackedExpected);
}
} }
class WireFormatInvalidInputTest : public testing::Test { class WireFormatInvalidInputTest : public testing::Test {
......
...@@ -57,6 +57,7 @@ WKT_PROTOS=$(get_variable_value $MAKEFILE nobase_dist_proto_DATA) ...@@ -57,6 +57,7 @@ WKT_PROTOS=$(get_variable_value $MAKEFILE nobase_dist_proto_DATA)
COMMON_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_TEST_SOURCES) COMMON_TEST_SOURCES=$(get_source_files $MAKEFILE COMMON_TEST_SOURCES)
TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_test_SOURCES) TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_test_SOURCES)
LITE_TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_lite_test_SOURCES) LITE_TEST_SOURCES=$(get_source_files $MAKEFILE protobuf_lite_test_SOURCES)
TEST_PLUGIN_SOURCES=$(get_source_files $MAKEFILE test_plugin_SOURCES)
################################################################################ ################################################################################
# Update cmake files. # Update cmake files.
...@@ -177,3 +178,5 @@ set_bazel_value $BAZEL_BUILD well_known_protos "" $WKT_PROTOS ...@@ -177,3 +178,5 @@ set_bazel_value $BAZEL_BUILD well_known_protos "" $WKT_PROTOS
set_bazel_value $BAZEL_BUILD test_protos "" $PROTOS set_bazel_value $BAZEL_BUILD test_protos "" $PROTOS
set_bazel_value $BAZEL_BUILD common_test_srcs $BAZEL_PREFIX $COMMON_TEST_SOURCES set_bazel_value $BAZEL_BUILD common_test_srcs $BAZEL_PREFIX $COMMON_TEST_SOURCES
set_bazel_value $BAZEL_BUILD test_srcs $BAZEL_PREFIX $TEST_SOURCES set_bazel_value $BAZEL_BUILD test_srcs $BAZEL_PREFIX $TEST_SOURCES
set_bazel_value $BAZEL_BUILD test_plugin_srcs $BAZEL_PREFIX $TEST_PLUGIN_SOURCES
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