Sync protobuf to v3.3.0
disable-clang-format Change-Id: I520178aa9bb8fd8a00a7009279bf30d7cdb8d5a8
This commit is contained in:
parent
ec3bbfff16
commit
f68b4252b8
|
@ -15,7 +15,7 @@ index_range {
|
||||||
end: 1034
|
end: 1034
|
||||||
}
|
}
|
||||||
media_file_name: "bear-640x360-audio.mp4"
|
media_file_name: "bear-640x360-audio.mp4"
|
||||||
media_duration_seconds: 2.7631745
|
media_duration_seconds: 2.76317453
|
||||||
reference_time_scale: 44100
|
reference_time_scale: 44100
|
||||||
container_type: CONTAINER_MP4
|
container_type: CONTAINER_MP4
|
||||||
protected_content {
|
protected_content {
|
||||||
|
|
|
@ -18,7 +18,7 @@ index_range {
|
||||||
end: 1158
|
end: 1158
|
||||||
}
|
}
|
||||||
media_file_name: "bear-640x360-video.mp4"
|
media_file_name: "bear-640x360-video.mp4"
|
||||||
media_duration_seconds: 2.7360666
|
media_duration_seconds: 2.73606658
|
||||||
reference_time_scale: 30000
|
reference_time_scale: 30000
|
||||||
container_type: CONTAINER_MP4
|
container_type: CONTAINER_MP4
|
||||||
protected_content {
|
protected_content {
|
||||||
|
|
|
@ -60,10 +60,16 @@ python/build/
|
||||||
python/google/protobuf/compiler/
|
python/google/protobuf/compiler/
|
||||||
python/google/protobuf/util/
|
python/google/protobuf/util/
|
||||||
|
|
||||||
|
src/js_embed
|
||||||
src/protoc
|
src/protoc
|
||||||
src/unittest_proto_middleman
|
src/unittest_proto_middleman
|
||||||
|
|
||||||
|
# vim generated
|
||||||
|
*.swp
|
||||||
|
|
||||||
# Generated test scaffolding
|
# Generated test scaffolding
|
||||||
|
src/no_warning_test.cc
|
||||||
|
src/no-warning-test
|
||||||
src/protobuf*-test
|
src/protobuf*-test
|
||||||
src/test_plugin
|
src/test_plugin
|
||||||
src/testzip.*
|
src/testzip.*
|
||||||
|
@ -77,8 +83,11 @@ src/**/*.log
|
||||||
src/**/*.trs
|
src/**/*.trs
|
||||||
|
|
||||||
# JavaBuild output.
|
# JavaBuild output.
|
||||||
java/target
|
java/core/target
|
||||||
|
java/util/target
|
||||||
javanano/target
|
javanano/target
|
||||||
|
java/.idea
|
||||||
|
java/**/*.iml
|
||||||
|
|
||||||
# Windows native output.
|
# Windows native output.
|
||||||
cmake/build
|
cmake/build
|
||||||
|
@ -88,16 +97,14 @@ build_msvc
|
||||||
# packages themselves.
|
# packages themselves.
|
||||||
/csharp/src/packages/*/
|
/csharp/src/packages/*/
|
||||||
|
|
||||||
# Directories created by opening the Objective C Xcode projects.
|
|
||||||
objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcuserdata/
|
|
||||||
objectivec/ProtocolBuffers_OSX.xcodeproj/project.xcworkspace/xcshareddata/ProtocolBuffers_OSX.xccheckout
|
|
||||||
objectivec/ProtocolBuffers_OSX.xcodeproj/xcuserdata/
|
|
||||||
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcuserdata/
|
|
||||||
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/ProtocolBuffers_iOS.xccheckout
|
|
||||||
objectivec/ProtocolBuffers_iOS.xcodeproj/xcuserdata/
|
|
||||||
# OS X's Finder creates these for state about opened windows/etc.
|
# OS X's Finder creates these for state about opened windows/etc.
|
||||||
**/.DS_Store
|
**/.DS_Store
|
||||||
|
|
||||||
|
# Cocoapods artifacts
|
||||||
|
# Podfile.lock and the workspace file are tracked, to ease deleting them. That's
|
||||||
|
# needed to trigger "pod install" to rerun the preinstall commands.
|
||||||
|
Pods/
|
||||||
|
|
||||||
# Comformance test output
|
# Comformance test output
|
||||||
conformance/.libs/
|
conformance/.libs/
|
||||||
conformance/com/
|
conformance/com/
|
||||||
|
@ -110,8 +117,55 @@ conformance/conformance.pb.cc
|
||||||
conformance/conformance.pb.h
|
conformance/conformance.pb.h
|
||||||
conformance/Conformance.pbobjc.h
|
conformance/Conformance.pbobjc.h
|
||||||
conformance/Conformance.pbobjc.m
|
conformance/Conformance.pbobjc.m
|
||||||
conformance/conformance.rb
|
conformance/conformance_pb.js
|
||||||
|
conformance/conformance_pb.rb
|
||||||
|
conformance/failing_tests.txt
|
||||||
conformance/google/
|
conformance/google/
|
||||||
|
conformance/google-protobuf/
|
||||||
conformance/javac_middleman
|
conformance/javac_middleman
|
||||||
conformance/lite/
|
conformance/lite/
|
||||||
|
conformance/nonexistent_tests.txt
|
||||||
conformance/protoc_middleman
|
conformance/protoc_middleman
|
||||||
|
conformance/succeeding_tests.txt
|
||||||
|
conformance/Conformance/
|
||||||
|
conformance/GPBMetadata/
|
||||||
|
conformance/Google/
|
||||||
|
conformance/Protobuf_test_messages/
|
||||||
|
conformance/conformance-php
|
||||||
|
conformance/conformance-php-c
|
||||||
|
|
||||||
|
# php test output
|
||||||
|
composer.lock
|
||||||
|
php/tests/generated/
|
||||||
|
php/tests/old_protoc
|
||||||
|
php/tests/protobuf/
|
||||||
|
php/ext/google/protobuf/.libs/
|
||||||
|
php/ext/google/protobuf/Makefile.fragments
|
||||||
|
php/ext/google/protobuf/Makefile.global
|
||||||
|
php/ext/google/protobuf/Makefile.objects
|
||||||
|
php/ext/google/protobuf/acinclude.m4
|
||||||
|
php/ext/google/protobuf/build/
|
||||||
|
php/ext/google/protobuf/config.h
|
||||||
|
php/ext/google/protobuf/config.nice
|
||||||
|
php/ext/google/protobuf/configure.in
|
||||||
|
php/ext/google/protobuf/mkinstalldirs
|
||||||
|
php/ext/google/protobuf/run-tests.php
|
||||||
|
vendor/
|
||||||
|
|
||||||
|
# JavaScript artifacts
|
||||||
|
js/commonjs_out/
|
||||||
|
js/compatibility_tests/v3.0.0/commonjs_out*
|
||||||
|
js/compatibility_tests/v3.0.0/protoc
|
||||||
|
js/compatibility_tests/v3.0.0/testproto_libs1.js
|
||||||
|
js/compatibility_tests/v3.0.0/testproto_libs1_new.js
|
||||||
|
js/compatibility_tests/v3.0.0/testproto_libs2.js
|
||||||
|
js/compatibility_tests/v3.0.0/testproto_libs2_new.js
|
||||||
|
js/deps.js
|
||||||
|
js/google-protobuf.js
|
||||||
|
js/google/
|
||||||
|
js/node_modules/
|
||||||
|
js/testproto_libs1.js
|
||||||
|
js/testproto_libs2.js
|
||||||
|
|
||||||
|
# Ignore the bazel symlinks
|
||||||
|
/bazel-*
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
[submodule "third_party/benchmark"]
|
||||||
|
path = third_party/benchmark
|
||||||
|
url = https://github.com/google/benchmark.git
|
|
@ -1,66 +1,76 @@
|
||||||
sudo: required
|
sudo: required
|
||||||
|
dist: trusty
|
||||||
# Note: travis currently does not support listing more than one language so
|
# Note: travis currently does not support listing more than one language so
|
||||||
# this cheats and claims to only be cpp. If they add multiple language
|
# this cheats and claims to only be cpp. If they add multiple language
|
||||||
# support, this should probably get updated to install steps and/or
|
# support, this should probably get updated to install steps and/or
|
||||||
# rvm/gemfile/jdk/etc. entries rather than manually doing the work.
|
# rvm/gemfile/jdk/etc. entries rather than manually doing the work.
|
||||||
language: cpp
|
language: cpp
|
||||||
os:
|
os:
|
||||||
- linux
|
|
||||||
- osx
|
- osx
|
||||||
# The Objective C build needs Xcode 7.0 or later.
|
# The Objective C build needs Xcode 7.0 or later.
|
||||||
osx_image: xcode7.2
|
osx_image: xcode8.1
|
||||||
script:
|
script:
|
||||||
- ./tests.sh $CONFIG
|
- ./tests.sh $CONFIG
|
||||||
env:
|
env:
|
||||||
- CONFIG=cpp
|
- CONFIG=cpp
|
||||||
- CONFIG=cpp_distcheck
|
- CONFIG=cpp_distcheck
|
||||||
- CONFIG=csharp
|
|
||||||
- CONFIG=golang
|
- CONFIG=golang
|
||||||
- CONFIG=java_jdk6
|
|
||||||
- CONFIG=java_jdk7
|
- CONFIG=java_jdk7
|
||||||
- CONFIG=java_oracle7
|
- CONFIG=java_oracle7
|
||||||
- CONFIG=javanano_jdk6
|
|
||||||
- CONFIG=javanano_jdk7
|
- CONFIG=javanano_jdk7
|
||||||
- CONFIG=javanano_oracle7
|
- CONFIG=javanano_oracle7
|
||||||
- CONFIG=javascript
|
- CONFIG=javascript
|
||||||
|
# iOS build log was starting to choke travis UI, so split to cover the
|
||||||
|
# Xcode Debug and Release Configurations independently.
|
||||||
|
- CONFIG=objectivec_ios_debug
|
||||||
|
- CONFIG=objectivec_ios_release
|
||||||
|
- CONFIG=objectivec_osx
|
||||||
|
- CONFIG=objectivec_cocoapods_integration
|
||||||
- CONFIG=python
|
- CONFIG=python
|
||||||
- CONFIG=python_cpp
|
- CONFIG=python_cpp
|
||||||
- CONFIG=ruby19
|
|
||||||
- CONFIG=ruby20
|
|
||||||
- CONFIG=ruby21
|
- CONFIG=ruby21
|
||||||
- CONFIG=ruby22
|
- CONFIG=ruby22
|
||||||
- CONFIG=jruby
|
- CONFIG=jruby
|
||||||
|
- CONFIG=php5.6_mac
|
||||||
|
- CONFIG=php7.0_mac
|
||||||
matrix:
|
matrix:
|
||||||
exclude:
|
exclude:
|
||||||
# It's nontrivial to programmatically install a new JDK from the command
|
# It's nontrivial to programmatically install a new JDK from the command
|
||||||
# line on OS X, so we rely on testing on Linux for Java code.
|
# line on OS X, so we rely on testing on Linux for Java code.
|
||||||
- os: osx
|
|
||||||
env: CONFIG=java_jdk6
|
|
||||||
- os: osx
|
- os: osx
|
||||||
env: CONFIG=java_jdk7
|
env: CONFIG=java_jdk7
|
||||||
- os: osx
|
- os: osx
|
||||||
env: CONFIG=java_oracle7
|
env: CONFIG=java_oracle7
|
||||||
- os: osx
|
|
||||||
env: CONFIG=javanano_jdk6
|
|
||||||
- os: osx
|
- os: osx
|
||||||
env: CONFIG=javanano_jdk7
|
env: CONFIG=javanano_jdk7
|
||||||
- os: osx
|
- os: osx
|
||||||
env: CONFIG=javanano_oracle7
|
env: CONFIG=javanano_oracle7
|
||||||
# Requires installing mono, currently travis.sh is doing that with apt-get
|
|
||||||
# which doesn't work on OS X.
|
|
||||||
- os: osx
|
|
||||||
env: CONFIG=csharp
|
|
||||||
# Requires installing golang, currently travis.sh is doing that with apt-get
|
# Requires installing golang, currently travis.sh is doing that with apt-get
|
||||||
# which doesn't work on OS X.
|
# which doesn't work on OS X.
|
||||||
- os: osx
|
- os: osx
|
||||||
env: CONFIG=golang
|
env: CONFIG=golang
|
||||||
# Add into the matrix OS X tests of Objective C (needs Xcode, so it won't
|
|
||||||
# work on other platforms). These are split so it doesn't take as long to run.
|
|
||||||
include:
|
include:
|
||||||
- os: osx
|
# The dotnet environment requires Ubuntu 14.04 or 16.04. This
|
||||||
env: CONFIG=objectivec_ios
|
# configuration is effectively an "extra" one, outside the
|
||||||
- os: osx
|
# autogenerated matrix.
|
||||||
env: CONFIG=objectivec_osx
|
- os: linux
|
||||||
|
env: CONFIG=csharp
|
||||||
|
language: csharp
|
||||||
|
dist: trusty
|
||||||
|
dotnet: 1.0.1
|
||||||
|
mono: none
|
||||||
|
# This test is kept on travis because it doesn't play nicely with other
|
||||||
|
# tests on jenkins running in parallel.
|
||||||
|
- os: linux
|
||||||
|
env: CONFIG=cpp_distcheck
|
||||||
|
# The Java compatibility test currently only runs on Linux because it will
|
||||||
|
# fetch pre-built Linux protoc binaries in the test.
|
||||||
|
- os: linux
|
||||||
|
env: CONFIG=java_compatibility
|
||||||
|
# The Python compatibility test currently only runs on Linux because it will
|
||||||
|
# fetch pre-built Linux protoc binaries in the test.
|
||||||
|
- os: linux
|
||||||
|
env: CONFIG=python_compatibility
|
||||||
allow_failures:
|
allow_failures:
|
||||||
# These currently do not work on OS X but are being worked on by @haberman.
|
# These currently do not work on OS X but are being worked on by @haberman.
|
||||||
- os: osx
|
- os: osx
|
||||||
|
@ -71,14 +81,11 @@ matrix:
|
||||||
# we moved to an OS X image that is 10.11.
|
# we moved to an OS X image that is 10.11.
|
||||||
- os: osx
|
- os: osx
|
||||||
env: CONFIG=python_cpp
|
env: CONFIG=python_cpp
|
||||||
# xctool 0.2.8 seems to have a bug where it randomly kills tests saying
|
# Mark the iOS test as flakey as xcodebuild some times fails to start the
|
||||||
# they failed.
|
# iOS Simulator.
|
||||||
# https://github.com/facebook/xctool/issues/619
|
|
||||||
# https://github.com/google/protobuf/issues/1232
|
|
||||||
# travis updated their images to include 0.2.8:
|
|
||||||
# https://blog.travis-ci.com/2016-03-23-xcode-image-updates
|
|
||||||
# Mark the iOS test as flakey so these failures don't turn things red.
|
|
||||||
- os: osx
|
- os: osx
|
||||||
env: CONFIG=objectivec_ios
|
env: CONFIG=objectivec_ios_debug
|
||||||
|
- os: osx
|
||||||
|
env: CONFIG=objectivec_ios_release
|
||||||
notifications:
|
notifications:
|
||||||
email: false
|
email: false
|
||||||
|
|
|
@ -2,19 +2,41 @@
|
||||||
|
|
||||||
licenses(["notice"])
|
licenses(["notice"])
|
||||||
|
|
||||||
|
exports_files(["LICENSE"])
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Protobuf Runtime Library
|
# Protobuf Runtime Library
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
COPTS = [
|
WIN_COPTS = [
|
||||||
"-DHAVE_PTHREAD",
|
"/DHAVE_PTHREAD",
|
||||||
"-Wall",
|
"/wd4018", # -Wno-sign-compare
|
||||||
"-Wwrite-strings",
|
"/wd4514", # -Wno-unused-function
|
||||||
"-Woverloaded-virtual",
|
|
||||||
"-Wno-sign-compare",
|
|
||||||
"-Wno-error=unused-function",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
COPTS = select({
|
||||||
|
":windows" : WIN_COPTS,
|
||||||
|
":windows_msvc" : WIN_COPTS,
|
||||||
|
"//conditions:default": [
|
||||||
|
"-DHAVE_PTHREAD",
|
||||||
|
"-Wall",
|
||||||
|
"-Wwrite-strings",
|
||||||
|
"-Woverloaded-virtual",
|
||||||
|
"-Wno-sign-compare",
|
||||||
|
"-Wno-unused-function",
|
||||||
|
],
|
||||||
|
})
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "windows",
|
||||||
|
values = { "cpu": "x64_windows" },
|
||||||
|
)
|
||||||
|
|
||||||
|
config_setting(
|
||||||
|
name = "windows_msvc",
|
||||||
|
values = { "cpu": "x64_windows_msvc" },
|
||||||
|
)
|
||||||
|
|
||||||
config_setting(
|
config_setting(
|
||||||
name = "android",
|
name = "android",
|
||||||
values = {
|
values = {
|
||||||
|
@ -25,13 +47,14 @@ config_setting(
|
||||||
# Android builds do not need to link in a separate pthread library.
|
# Android builds do not need to link in a separate pthread library.
|
||||||
LINK_OPTS = select({
|
LINK_OPTS = select({
|
||||||
":android": [],
|
":android": [],
|
||||||
"//conditions:default": ["-lpthread"],
|
"//conditions:default": ["-lpthread", "-lm"],
|
||||||
})
|
})
|
||||||
|
|
||||||
load(
|
load(
|
||||||
"protobuf",
|
":protobuf.bzl",
|
||||||
"cc_proto_library",
|
"cc_proto_library",
|
||||||
"py_proto_library",
|
"py_proto_library",
|
||||||
|
"internal_copied_filegroup",
|
||||||
"internal_gen_well_known_protos_java",
|
"internal_gen_well_known_protos_java",
|
||||||
"internal_protobuf_py_tests",
|
"internal_protobuf_py_tests",
|
||||||
)
|
)
|
||||||
|
@ -57,7 +80,7 @@ config_setting(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
IOS_ARM_COPTS = COPTS + [
|
IOS_ARM_COPTS = [
|
||||||
"-DOS_IOS",
|
"-DOS_IOS",
|
||||||
"-miphoneos-version-min=7.0",
|
"-miphoneos-version-min=7.0",
|
||||||
"-arch armv7",
|
"-arch armv7",
|
||||||
|
@ -100,8 +123,8 @@ cc_library(
|
||||||
":ios_armv7": IOS_ARM_COPTS,
|
":ios_armv7": IOS_ARM_COPTS,
|
||||||
":ios_armv7s": IOS_ARM_COPTS,
|
":ios_armv7s": IOS_ARM_COPTS,
|
||||||
":ios_arm64": IOS_ARM_COPTS,
|
":ios_arm64": IOS_ARM_COPTS,
|
||||||
"//conditions:default": COPTS,
|
"//conditions:default": [],
|
||||||
}),
|
}) + COPTS,
|
||||||
includes = ["src/"],
|
includes = ["src/"],
|
||||||
linkopts = LINK_OPTS,
|
linkopts = LINK_OPTS,
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
|
@ -125,6 +148,7 @@ cc_library(
|
||||||
"src/google/protobuf/extension_set_heavy.cc",
|
"src/google/protobuf/extension_set_heavy.cc",
|
||||||
"src/google/protobuf/field_mask.pb.cc",
|
"src/google/protobuf/field_mask.pb.cc",
|
||||||
"src/google/protobuf/generated_message_reflection.cc",
|
"src/google/protobuf/generated_message_reflection.cc",
|
||||||
|
"src/google/protobuf/generated_message_table_driven.cc",
|
||||||
"src/google/protobuf/io/gzip_stream.cc",
|
"src/google/protobuf/io/gzip_stream.cc",
|
||||||
"src/google/protobuf/io/printer.cc",
|
"src/google/protobuf/io/printer.cc",
|
||||||
"src/google/protobuf/io/strtod.cc",
|
"src/google/protobuf/io/strtod.cc",
|
||||||
|
@ -142,6 +166,7 @@ cc_library(
|
||||||
"src/google/protobuf/timestamp.pb.cc",
|
"src/google/protobuf/timestamp.pb.cc",
|
||||||
"src/google/protobuf/type.pb.cc",
|
"src/google/protobuf/type.pb.cc",
|
||||||
"src/google/protobuf/unknown_field_set.cc",
|
"src/google/protobuf/unknown_field_set.cc",
|
||||||
|
"src/google/protobuf/util/delimited_message_util.cc",
|
||||||
"src/google/protobuf/util/field_comparator.cc",
|
"src/google/protobuf/util/field_comparator.cc",
|
||||||
"src/google/protobuf/util/field_mask_util.cc",
|
"src/google/protobuf/util/field_mask_util.cc",
|
||||||
"src/google/protobuf/util/internal/datapiece.cc",
|
"src/google/protobuf/util/internal/datapiece.cc",
|
||||||
|
@ -170,14 +195,25 @@ cc_library(
|
||||||
":ios_armv7": IOS_ARM_COPTS,
|
":ios_armv7": IOS_ARM_COPTS,
|
||||||
":ios_armv7s": IOS_ARM_COPTS,
|
":ios_armv7s": IOS_ARM_COPTS,
|
||||||
":ios_arm64": IOS_ARM_COPTS,
|
":ios_arm64": IOS_ARM_COPTS,
|
||||||
"//conditions:default": COPTS,
|
"//conditions:default": [],
|
||||||
}),
|
}) + COPTS,
|
||||||
includes = ["src/"],
|
includes = ["src/"],
|
||||||
linkopts = LINK_OPTS,
|
linkopts = LINK_OPTS,
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
deps = [":protobuf_lite"],
|
deps = [":protobuf_lite"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# This provides just the header files for use in projects that need to build
|
||||||
|
# shared libraries for dynamic loading. This target is available until Bazel
|
||||||
|
# adds native support for such use cases.
|
||||||
|
# TODO(keveman): Remove this target once the support gets added to Bazel.
|
||||||
|
cc_library(
|
||||||
|
name = "protobuf_headers",
|
||||||
|
hdrs = glob(["src/**/*.h"]),
|
||||||
|
includes = ["src/"],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
|
||||||
objc_library(
|
objc_library(
|
||||||
name = "protobuf_objc",
|
name = "protobuf_objc",
|
||||||
hdrs = ["objectivec/GPBProtocolBuffers.h"],
|
hdrs = ["objectivec/GPBProtocolBuffers.h"],
|
||||||
|
@ -191,6 +227,7 @@ RELATIVE_WELL_KNOWN_PROTOS = [
|
||||||
"google/protobuf/any.proto",
|
"google/protobuf/any.proto",
|
||||||
"google/protobuf/api.proto",
|
"google/protobuf/api.proto",
|
||||||
"google/protobuf/compiler/plugin.proto",
|
"google/protobuf/compiler/plugin.proto",
|
||||||
|
"google/protobuf/compiler/profile.proto",
|
||||||
"google/protobuf/descriptor.proto",
|
"google/protobuf/descriptor.proto",
|
||||||
"google/protobuf/duration.proto",
|
"google/protobuf/duration.proto",
|
||||||
"google/protobuf/empty.proto",
|
"google/protobuf/empty.proto",
|
||||||
|
@ -224,6 +261,24 @@ cc_proto_library(
|
||||||
# Protocol Buffers Compiler
|
# Protocol Buffers Compiler
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
|
cc_binary(
|
||||||
|
name = "js_embed",
|
||||||
|
srcs = ["src/google/protobuf/compiler/js/embed.cc"],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
|
||||||
|
genrule(
|
||||||
|
name = "generate_js_well_known_types_embed",
|
||||||
|
srcs = [
|
||||||
|
"src/google/protobuf/compiler/js/well_known_types/any.js",
|
||||||
|
"src/google/protobuf/compiler/js/well_known_types/struct.js",
|
||||||
|
"src/google/protobuf/compiler/js/well_known_types/timestamp.js",
|
||||||
|
],
|
||||||
|
outs = ["src/google/protobuf/compiler/js/well_known_types_embed.cc"],
|
||||||
|
cmd = "$(location :js_embed) $(SRCS) > $@",
|
||||||
|
tools = [":js_embed"],
|
||||||
|
)
|
||||||
|
|
||||||
cc_library(
|
cc_library(
|
||||||
name = "protoc_lib",
|
name = "protoc_lib",
|
||||||
srcs = [
|
srcs = [
|
||||||
|
@ -301,6 +356,7 @@ cc_library(
|
||||||
"src/google/protobuf/compiler/javanano/javanano_message_field.cc",
|
"src/google/protobuf/compiler/javanano/javanano_message_field.cc",
|
||||||
"src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
|
"src/google/protobuf/compiler/javanano/javanano_primitive_field.cc",
|
||||||
"src/google/protobuf/compiler/js/js_generator.cc",
|
"src/google/protobuf/compiler/js/js_generator.cc",
|
||||||
|
"src/google/protobuf/compiler/js/well_known_types_embed.cc",
|
||||||
"src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
|
"src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
|
||||||
"src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
|
"src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
|
||||||
"src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
|
"src/google/protobuf/compiler/objectivec/objectivec_extension.cc",
|
||||||
|
@ -313,8 +369,10 @@ cc_library(
|
||||||
"src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
|
"src/google/protobuf/compiler/objectivec/objectivec_message_field.cc",
|
||||||
"src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
|
"src/google/protobuf/compiler/objectivec/objectivec_oneof.cc",
|
||||||
"src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
|
"src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
|
||||||
|
"src/google/protobuf/compiler/php/php_generator.cc",
|
||||||
"src/google/protobuf/compiler/plugin.cc",
|
"src/google/protobuf/compiler/plugin.cc",
|
||||||
"src/google/protobuf/compiler/plugin.pb.cc",
|
"src/google/protobuf/compiler/plugin.pb.cc",
|
||||||
|
"src/google/protobuf/compiler/profile.pb.cc",
|
||||||
"src/google/protobuf/compiler/python/python_generator.cc",
|
"src/google/protobuf/compiler/python/python_generator.cc",
|
||||||
"src/google/protobuf/compiler/ruby/ruby_generator.cc",
|
"src/google/protobuf/compiler/ruby/ruby_generator.cc",
|
||||||
"src/google/protobuf/compiler/subprocess.cc",
|
"src/google/protobuf/compiler/subprocess.cc",
|
||||||
|
@ -366,6 +424,9 @@ RELATIVE_TEST_PROTOS = [
|
||||||
"google/protobuf/unittest_enormous_descriptor.proto",
|
"google/protobuf/unittest_enormous_descriptor.proto",
|
||||||
"google/protobuf/unittest_import.proto",
|
"google/protobuf/unittest_import.proto",
|
||||||
"google/protobuf/unittest_import_public.proto",
|
"google/protobuf/unittest_import_public.proto",
|
||||||
|
"google/protobuf/unittest_lazy_dependencies.proto",
|
||||||
|
"google/protobuf/unittest_lazy_dependencies_custom_option.proto",
|
||||||
|
"google/protobuf/unittest_lazy_dependencies_enum.proto",
|
||||||
"google/protobuf/unittest_lite_imports_nonlite.proto",
|
"google/protobuf/unittest_lite_imports_nonlite.proto",
|
||||||
"google/protobuf/unittest_mset.proto",
|
"google/protobuf/unittest_mset.proto",
|
||||||
"google/protobuf/unittest_mset_wire_format.proto",
|
"google/protobuf/unittest_mset_wire_format.proto",
|
||||||
|
@ -387,8 +448,10 @@ RELATIVE_TEST_PROTOS = [
|
||||||
"google/protobuf/util/internal/testdata/field_mask.proto",
|
"google/protobuf/util/internal/testdata/field_mask.proto",
|
||||||
"google/protobuf/util/internal/testdata/maps.proto",
|
"google/protobuf/util/internal/testdata/maps.proto",
|
||||||
"google/protobuf/util/internal/testdata/oneofs.proto",
|
"google/protobuf/util/internal/testdata/oneofs.proto",
|
||||||
|
"google/protobuf/util/internal/testdata/proto3.proto",
|
||||||
"google/protobuf/util/internal/testdata/struct.proto",
|
"google/protobuf/util/internal/testdata/struct.proto",
|
||||||
"google/protobuf/util/internal/testdata/timestamp_duration.proto",
|
"google/protobuf/util/internal/testdata/timestamp_duration.proto",
|
||||||
|
"google/protobuf/util/internal/testdata/wrappers.proto",
|
||||||
"google/protobuf/util/json_format_proto3.proto",
|
"google/protobuf/util/json_format_proto3.proto",
|
||||||
"google/protobuf/util/message_differencer_unittest.proto",
|
"google/protobuf/util/message_differencer_unittest.proto",
|
||||||
]
|
]
|
||||||
|
@ -440,6 +503,7 @@ cc_test(
|
||||||
"src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
|
"src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc",
|
||||||
"src/google/protobuf/compiler/cpp/cpp_unittest.cc",
|
"src/google/protobuf/compiler/cpp/cpp_unittest.cc",
|
||||||
"src/google/protobuf/compiler/cpp/metadata_test.cc",
|
"src/google/protobuf/compiler/cpp/metadata_test.cc",
|
||||||
|
"src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc",
|
||||||
"src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
|
"src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc",
|
||||||
"src/google/protobuf/compiler/importer_unittest.cc",
|
"src/google/protobuf/compiler/importer_unittest.cc",
|
||||||
"src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
|
"src/google/protobuf/compiler/java/java_doc_comment_unittest.cc",
|
||||||
|
@ -485,6 +549,7 @@ cc_test(
|
||||||
"src/google/protobuf/stubs/type_traits_unittest.cc",
|
"src/google/protobuf/stubs/type_traits_unittest.cc",
|
||||||
"src/google/protobuf/text_format_unittest.cc",
|
"src/google/protobuf/text_format_unittest.cc",
|
||||||
"src/google/protobuf/unknown_field_set_unittest.cc",
|
"src/google/protobuf/unknown_field_set_unittest.cc",
|
||||||
|
"src/google/protobuf/util/delimited_message_util_test.cc",
|
||||||
"src/google/protobuf/util/field_comparator_test.cc",
|
"src/google/protobuf/util/field_comparator_test.cc",
|
||||||
"src/google/protobuf/util/field_mask_util_test.cc",
|
"src/google/protobuf/util/field_mask_util_test.cc",
|
||||||
"src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
|
"src/google/protobuf/util/internal/default_value_objectwriter_test.cc",
|
||||||
|
@ -505,6 +570,10 @@ cc_test(
|
||||||
":test_plugin",
|
":test_plugin",
|
||||||
] + glob([
|
] + glob([
|
||||||
"src/google/protobuf/**/*",
|
"src/google/protobuf/**/*",
|
||||||
|
# Files for csharp_bootstrap_unittest.cc.
|
||||||
|
"conformance/**/*",
|
||||||
|
"csharp/src/**/*",
|
||||||
|
"examples/**/*",
|
||||||
]),
|
]),
|
||||||
includes = [
|
includes = [
|
||||||
"src/",
|
"src/",
|
||||||
|
@ -532,6 +601,7 @@ java_library(
|
||||||
]) + [
|
]) + [
|
||||||
":gen_well_known_protos_java",
|
":gen_well_known_protos_java",
|
||||||
],
|
],
|
||||||
|
javacopts = ["-source 6", "-target 6"],
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -540,12 +610,13 @@ java_library(
|
||||||
srcs = glob([
|
srcs = glob([
|
||||||
"java/util/src/main/java/com/google/protobuf/util/*.java",
|
"java/util/src/main/java/com/google/protobuf/util/*.java",
|
||||||
]),
|
]),
|
||||||
|
javacopts = ["-source 6", "-target 6"],
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
deps = [
|
deps = [
|
||||||
"protobuf_java",
|
"protobuf_java",
|
||||||
"//external:gson",
|
"//external:gson",
|
||||||
"//external:guava",
|
"//external:guava",
|
||||||
],
|
],
|
||||||
visibility = ["//visibility:public"],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
|
@ -560,16 +631,18 @@ py_library(
|
||||||
"python/google/protobuf/**/*.py",
|
"python/google/protobuf/**/*.py",
|
||||||
],
|
],
|
||||||
exclude = [
|
exclude = [
|
||||||
|
"python/google/protobuf/__init__.py",
|
||||||
|
"python/google/protobuf/**/__init__.py",
|
||||||
"python/google/protobuf/internal/*_test.py",
|
"python/google/protobuf/internal/*_test.py",
|
||||||
"python/google/protobuf/internal/test_util.py",
|
"python/google/protobuf/internal/test_util.py",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
srcs_version = "PY2AND3",
|
|
||||||
imports = ["python"],
|
imports = ["python"],
|
||||||
|
srcs_version = "PY2AND3",
|
||||||
)
|
)
|
||||||
|
|
||||||
cc_binary(
|
cc_binary(
|
||||||
name = "internal/_api_implementation.so",
|
name = "python/google/protobuf/internal/_api_implementation.so",
|
||||||
srcs = ["python/google/protobuf/internal/api_implementation.cc"],
|
srcs = ["python/google/protobuf/internal/api_implementation.cc"],
|
||||||
copts = COPTS + [
|
copts = COPTS + [
|
||||||
"-DPYTHON_PROTO2_CPP_IMPL_V2",
|
"-DPYTHON_PROTO2_CPP_IMPL_V2",
|
||||||
|
@ -583,7 +656,7 @@ cc_binary(
|
||||||
)
|
)
|
||||||
|
|
||||||
cc_binary(
|
cc_binary(
|
||||||
name = "pyext/_message.so",
|
name = "python/google/protobuf/pyext/_message.so",
|
||||||
srcs = glob([
|
srcs = glob([
|
||||||
"python/google/protobuf/pyext/*.cc",
|
"python/google/protobuf/pyext/*.cc",
|
||||||
"python/google/protobuf/pyext/*.h",
|
"python/google/protobuf/pyext/*.h",
|
||||||
|
@ -622,31 +695,65 @@ config_setting(
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Copy the builtin proto files from src/google/protobuf to
|
||||||
|
# python/google/protobuf. This way, the generated Python sources will be in the
|
||||||
|
# same directory as the Python runtime sources. This is necessary for the
|
||||||
|
# modules to be imported correctly since they are all part of the same Python
|
||||||
|
# package.
|
||||||
|
internal_copied_filegroup(
|
||||||
|
name = "protos_python",
|
||||||
|
srcs = WELL_KNOWN_PROTOS,
|
||||||
|
dest = "python",
|
||||||
|
strip_prefix = "src",
|
||||||
|
)
|
||||||
|
|
||||||
|
# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
|
||||||
|
# which case we can simply add :protos_python in srcs.
|
||||||
|
COPIED_WELL_KNOWN_PROTOS = ["python/" + s for s in RELATIVE_WELL_KNOWN_PROTOS]
|
||||||
|
|
||||||
py_proto_library(
|
py_proto_library(
|
||||||
name = "protobuf_python",
|
name = "protobuf_python",
|
||||||
srcs = WELL_KNOWN_PROTOS,
|
srcs = COPIED_WELL_KNOWN_PROTOS,
|
||||||
include = "src",
|
include = "python",
|
||||||
data = select({
|
data = select({
|
||||||
"//conditions:default": [],
|
"//conditions:default": [],
|
||||||
":use_fast_cpp_protos": [
|
":use_fast_cpp_protos": [
|
||||||
":internal/_api_implementation.so",
|
":python/google/protobuf/internal/_api_implementation.so",
|
||||||
":pyext/_message.so",
|
":python/google/protobuf/pyext/_message.so",
|
||||||
],
|
],
|
||||||
}),
|
}),
|
||||||
default_runtime = "",
|
default_runtime = "",
|
||||||
protoc = ":protoc",
|
protoc = ":protoc",
|
||||||
py_libs = [
|
py_libs = [
|
||||||
":python_srcs",
|
":python_srcs",
|
||||||
"//external:six"
|
"//external:six",
|
||||||
],
|
],
|
||||||
srcs_version = "PY2AND3",
|
srcs_version = "PY2AND3",
|
||||||
visibility = ["//visibility:public"],
|
visibility = ["//visibility:public"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Copy the test proto files from src/google/protobuf to
|
||||||
|
# python/google/protobuf. This way, the generated Python sources will be in the
|
||||||
|
# same directory as the Python runtime sources. This is necessary for the
|
||||||
|
# modules to be imported correctly by the tests since they are all part of the
|
||||||
|
# same Python package.
|
||||||
|
internal_copied_filegroup(
|
||||||
|
name = "protos_python_test",
|
||||||
|
srcs = LITE_TEST_PROTOS + TEST_PROTOS,
|
||||||
|
dest = "python",
|
||||||
|
strip_prefix = "src",
|
||||||
|
)
|
||||||
|
|
||||||
|
# TODO(dzc): Remove this once py_proto_library can have labels in srcs, in
|
||||||
|
# which case we can simply add :protos_python_test in srcs.
|
||||||
|
COPIED_LITE_TEST_PROTOS = ["python/" + s for s in RELATIVE_LITE_TEST_PROTOS]
|
||||||
|
|
||||||
|
COPIED_TEST_PROTOS = ["python/" + s for s in RELATIVE_TEST_PROTOS]
|
||||||
|
|
||||||
py_proto_library(
|
py_proto_library(
|
||||||
name = "python_common_test_protos",
|
name = "python_common_test_protos",
|
||||||
srcs = LITE_TEST_PROTOS + TEST_PROTOS,
|
srcs = COPIED_LITE_TEST_PROTOS + COPIED_TEST_PROTOS,
|
||||||
include = "src",
|
include = "python",
|
||||||
default_runtime = "",
|
default_runtime = "",
|
||||||
protoc = ":protoc",
|
protoc = ":protoc",
|
||||||
srcs_version = "PY2AND3",
|
srcs_version = "PY2AND3",
|
||||||
|
@ -672,6 +779,7 @@ py_library(
|
||||||
[
|
[
|
||||||
"python/google/protobuf/internal/*_test.py",
|
"python/google/protobuf/internal/*_test.py",
|
||||||
"python/google/protobuf/internal/test_util.py",
|
"python/google/protobuf/internal/test_util.py",
|
||||||
|
"python/google/protobuf/internal/import_test_package/__init__.py",
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
imports = ["python"],
|
imports = ["python"],
|
||||||
|
@ -707,3 +815,98 @@ internal_protobuf_py_tests(
|
||||||
],
|
],
|
||||||
deps = [":python_tests"],
|
deps = [":python_tests"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
proto_lang_toolchain(
|
||||||
|
name = "cc_toolchain",
|
||||||
|
command_line = "--cpp_out=$(OUT)",
|
||||||
|
runtime = ":protobuf",
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
|
||||||
|
proto_lang_toolchain(
|
||||||
|
name = "java_toolchain",
|
||||||
|
command_line = "--java_out=$(OUT)",
|
||||||
|
runtime = ":protobuf_java",
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
|
||||||
|
OBJC_HDRS = [
|
||||||
|
"objectivec/GPBArray.h",
|
||||||
|
"objectivec/GPBBootstrap.h",
|
||||||
|
"objectivec/GPBCodedInputStream.h",
|
||||||
|
"objectivec/GPBCodedOutputStream.h",
|
||||||
|
"objectivec/GPBDescriptor.h",
|
||||||
|
"objectivec/GPBDictionary.h",
|
||||||
|
"objectivec/GPBExtensionInternals.h",
|
||||||
|
"objectivec/GPBExtensionRegistry.h",
|
||||||
|
"objectivec/GPBMessage.h",
|
||||||
|
"objectivec/GPBProtocolBuffers.h",
|
||||||
|
"objectivec/GPBProtocolBuffers_RuntimeSupport.h",
|
||||||
|
"objectivec/GPBRootObject.h",
|
||||||
|
"objectivec/GPBRuntimeTypes.h",
|
||||||
|
"objectivec/GPBUnknownField.h",
|
||||||
|
"objectivec/GPBUnknownFieldSet.h",
|
||||||
|
"objectivec/GPBUtilities.h",
|
||||||
|
"objectivec/GPBWellKnownTypes.h",
|
||||||
|
"objectivec/GPBWireFormat.h",
|
||||||
|
"objectivec/google/protobuf/Any.pbobjc.h",
|
||||||
|
"objectivec/google/protobuf/Api.pbobjc.h",
|
||||||
|
"objectivec/google/protobuf/Duration.pbobjc.h",
|
||||||
|
"objectivec/google/protobuf/Empty.pbobjc.h",
|
||||||
|
"objectivec/google/protobuf/FieldMask.pbobjc.h",
|
||||||
|
"objectivec/google/protobuf/SourceContext.pbobjc.h",
|
||||||
|
"objectivec/google/protobuf/Struct.pbobjc.h",
|
||||||
|
"objectivec/google/protobuf/Timestamp.pbobjc.h",
|
||||||
|
"objectivec/google/protobuf/Type.pbobjc.h",
|
||||||
|
"objectivec/google/protobuf/Wrappers.pbobjc.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
OBJC_PRIVATE_HDRS = [
|
||||||
|
"objectivec/GPBArray_PackagePrivate.h",
|
||||||
|
"objectivec/GPBCodedInputStream_PackagePrivate.h",
|
||||||
|
"objectivec/GPBCodedOutputStream_PackagePrivate.h",
|
||||||
|
"objectivec/GPBDescriptor_PackagePrivate.h",
|
||||||
|
"objectivec/GPBDictionary_PackagePrivate.h",
|
||||||
|
"objectivec/GPBMessage_PackagePrivate.h",
|
||||||
|
"objectivec/GPBRootObject_PackagePrivate.h",
|
||||||
|
"objectivec/GPBUnknownFieldSet_PackagePrivate.h",
|
||||||
|
"objectivec/GPBUnknownField_PackagePrivate.h",
|
||||||
|
"objectivec/GPBUtilities_PackagePrivate.h",
|
||||||
|
]
|
||||||
|
|
||||||
|
OBJC_SRCS = [
|
||||||
|
"objectivec/GPBArray.m",
|
||||||
|
"objectivec/GPBCodedInputStream.m",
|
||||||
|
"objectivec/GPBCodedOutputStream.m",
|
||||||
|
"objectivec/GPBDescriptor.m",
|
||||||
|
"objectivec/GPBDictionary.m",
|
||||||
|
"objectivec/GPBExtensionInternals.m",
|
||||||
|
"objectivec/GPBExtensionRegistry.m",
|
||||||
|
"objectivec/GPBMessage.m",
|
||||||
|
"objectivec/GPBRootObject.m",
|
||||||
|
"objectivec/GPBUnknownField.m",
|
||||||
|
"objectivec/GPBUnknownFieldSet.m",
|
||||||
|
"objectivec/GPBUtilities.m",
|
||||||
|
"objectivec/GPBWellKnownTypes.m",
|
||||||
|
"objectivec/GPBWireFormat.m",
|
||||||
|
"objectivec/google/protobuf/Any.pbobjc.m",
|
||||||
|
"objectivec/google/protobuf/Api.pbobjc.m",
|
||||||
|
"objectivec/google/protobuf/Duration.pbobjc.m",
|
||||||
|
"objectivec/google/protobuf/Empty.pbobjc.m",
|
||||||
|
"objectivec/google/protobuf/FieldMask.pbobjc.m",
|
||||||
|
"objectivec/google/protobuf/SourceContext.pbobjc.m",
|
||||||
|
"objectivec/google/protobuf/Struct.pbobjc.m",
|
||||||
|
"objectivec/google/protobuf/Timestamp.pbobjc.m",
|
||||||
|
"objectivec/google/protobuf/Type.pbobjc.m",
|
||||||
|
"objectivec/google/protobuf/Wrappers.pbobjc.m",
|
||||||
|
]
|
||||||
|
|
||||||
|
objc_library(
|
||||||
|
name = "objectivec",
|
||||||
|
hdrs = OBJC_HDRS + OBJC_PRIVATE_HDRS,
|
||||||
|
includes = [
|
||||||
|
"objectivec",
|
||||||
|
],
|
||||||
|
non_arc_srcs = OBJC_SRCS,
|
||||||
|
visibility = ["//visibility:public"],
|
||||||
|
)
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
# Copyright 2014 The Chromium Authors. All rights reserved.
|
# Copyright 2014 The Chromium Authors. All rights reserved.
|
||||||
# Use of this source code is governed by a BSD-style license that can be
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
import("//build/config/sanitizers/sanitizers.gni")
|
||||||
|
|
||||||
config("protobuf_config") {
|
config("protobuf_config") {
|
||||||
include_dirs = [ "src" ]
|
include_dirs = [ "src" ]
|
||||||
|
@ -52,6 +53,7 @@ protobuf_lite_sources = [
|
||||||
"src/google/protobuf/io/zero_copy_stream.h",
|
"src/google/protobuf/io/zero_copy_stream.h",
|
||||||
"src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
|
"src/google/protobuf/io/zero_copy_stream_impl_lite.cc",
|
||||||
"src/google/protobuf/io/zero_copy_stream_impl_lite.h",
|
"src/google/protobuf/io/zero_copy_stream_impl_lite.h",
|
||||||
|
"src/google/protobuf/has_bits.h",
|
||||||
"src/google/protobuf/map.h",
|
"src/google/protobuf/map.h",
|
||||||
"src/google/protobuf/map_entry_lite.h",
|
"src/google/protobuf/map_entry_lite.h",
|
||||||
"src/google/protobuf/map_field_lite.h",
|
"src/google/protobuf/map_field_lite.h",
|
||||||
|
@ -65,10 +67,10 @@ protobuf_lite_sources = [
|
||||||
"src/google/protobuf/stubs/atomicops_internals_arm_gcc.h",
|
"src/google/protobuf/stubs/atomicops_internals_arm_gcc.h",
|
||||||
"src/google/protobuf/stubs/atomicops_internals_arm_qnx.h",
|
"src/google/protobuf/stubs/atomicops_internals_arm_qnx.h",
|
||||||
"src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h",
|
"src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h",
|
||||||
|
"src/google/protobuf/stubs/atomicops_internals_generic_c11_atomic.h",
|
||||||
"src/google/protobuf/stubs/atomicops_internals_generic_gcc.h",
|
"src/google/protobuf/stubs/atomicops_internals_generic_gcc.h",
|
||||||
"src/google/protobuf/stubs/atomicops_internals_macosx.h",
|
"src/google/protobuf/stubs/atomicops_internals_macosx.h",
|
||||||
"src/google/protobuf/stubs/atomicops_internals_mips_gcc.h",
|
"src/google/protobuf/stubs/atomicops_internals_mips_gcc.h",
|
||||||
"src/google/protobuf/stubs/atomicops_internals_pnacl.h",
|
|
||||||
"src/google/protobuf/stubs/atomicops_internals_power.h",
|
"src/google/protobuf/stubs/atomicops_internals_power.h",
|
||||||
"src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h",
|
"src/google/protobuf/stubs/atomicops_internals_ppc_gcc.h",
|
||||||
"src/google/protobuf/stubs/atomicops_internals_solaris.h",
|
"src/google/protobuf/stubs/atomicops_internals_solaris.h",
|
||||||
|
@ -136,6 +138,27 @@ if (is_win) {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Do not allow libprotobuf_lite to be dynamically linked on Linux. Later
|
||||||
|
# versions of Ubuntu like Xenial and Yakkety link in the system
|
||||||
|
# libprotobuf_lite by the following dependency chain: chrome -> gtk ->
|
||||||
|
# libmirclient -> libmirprotobuf -> libprotobuf-lite. Trying to load
|
||||||
|
# the system libprotobuf-lite after already having loaded the libprotobuf_lite
|
||||||
|
# component will result in an immediate crash. (crbug.com/700120)
|
||||||
|
if (is_component_build && is_desktop_linux) {
|
||||||
|
shared_library("mirclient") {
|
||||||
|
inputs = [
|
||||||
|
"mirclient.map",
|
||||||
|
]
|
||||||
|
sources = [
|
||||||
|
"mirclient.cc",
|
||||||
|
]
|
||||||
|
ldflags =
|
||||||
|
[ "-Wl,--version-script=" +
|
||||||
|
rebase_path("//third_party/protobuf/mirclient.map", root_build_dir) ]
|
||||||
|
output_extension = "so.9"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
component("protobuf_lite") {
|
component("protobuf_lite") {
|
||||||
sources = protobuf_lite_sources
|
sources = protobuf_lite_sources
|
||||||
|
|
||||||
|
@ -148,6 +171,12 @@ component("protobuf_lite") {
|
||||||
":protobuf_warnings",
|
":protobuf_warnings",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Remove Sanitizers and coverage for a performance boost when fuzzing. This is
|
||||||
|
# OK because the only fuzzers that use protobuf are libprotobuf-mutator based
|
||||||
|
# fuzzers, and they don't actually target the protobuf code, they just use it.
|
||||||
|
configs -= not_fuzzed_remove_configs
|
||||||
|
configs += [ "//build/config/sanitizers:not_fuzzed" ]
|
||||||
|
|
||||||
if (is_win) {
|
if (is_win) {
|
||||||
configs -= [ "//build/config/win:lean_and_mean" ]
|
configs -= [ "//build/config/win:lean_and_mean" ]
|
||||||
}
|
}
|
||||||
|
@ -160,11 +189,19 @@ component("protobuf_lite") {
|
||||||
]
|
]
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
"//build/config/sanitizers:deps",
|
"//build/config:exe_and_shlib_deps",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if (is_android) {
|
||||||
|
libs = [ "log" ] # Used by src/google/protobuf/stubs/common.cc
|
||||||
|
}
|
||||||
|
|
||||||
cflags = protobuf_lite_cflags
|
cflags = protobuf_lite_cflags
|
||||||
|
|
||||||
|
if (is_component_build && is_desktop_linux) {
|
||||||
|
deps += [ ":mirclient" ]
|
||||||
|
}
|
||||||
|
|
||||||
# Required for component builds. See http://crbug.com/172800.
|
# Required for component builds. See http://crbug.com/172800.
|
||||||
if (is_component_build) {
|
if (is_component_build) {
|
||||||
public_configs += [ ":protobuf_use_dlls" ]
|
public_configs += [ ":protobuf_use_dlls" ]
|
||||||
|
@ -177,141 +214,158 @@ component("protobuf_lite") {
|
||||||
# into that category. Do not use in Chrome code.
|
# into that category. Do not use in Chrome code.
|
||||||
static_library("protobuf_full") {
|
static_library("protobuf_full") {
|
||||||
# Prevent people from depending on this outside our file.
|
# Prevent people from depending on this outside our file.
|
||||||
visibility = [ ":*" ]
|
visibility = [
|
||||||
|
":*",
|
||||||
|
|
||||||
sources = protobuf_lite_sources
|
# requires descriptors & reflection; testonly.
|
||||||
sources += [
|
"//third_party/libprotobuf-mutator:*",
|
||||||
"src/google/protobuf/any.cc",
|
|
||||||
"src/google/protobuf/any.h",
|
|
||||||
"src/google/protobuf/any.pb.cc",
|
|
||||||
"src/google/protobuf/any.pb.h",
|
|
||||||
"src/google/protobuf/api.pb.cc",
|
|
||||||
"src/google/protobuf/api.pb.h",
|
|
||||||
"src/google/protobuf/compiler/importer.cc",
|
|
||||||
"src/google/protobuf/compiler/importer.h",
|
|
||||||
"src/google/protobuf/compiler/parser.cc",
|
|
||||||
"src/google/protobuf/compiler/parser.h",
|
|
||||||
"src/google/protobuf/descriptor.cc",
|
|
||||||
"src/google/protobuf/descriptor.h",
|
|
||||||
"src/google/protobuf/descriptor.pb.cc",
|
|
||||||
"src/google/protobuf/descriptor.pb.h",
|
|
||||||
"src/google/protobuf/descriptor_database.cc",
|
|
||||||
"src/google/protobuf/descriptor_database.h",
|
|
||||||
"src/google/protobuf/duration.pb.cc",
|
|
||||||
"src/google/protobuf/duration.pb.h",
|
|
||||||
"src/google/protobuf/dynamic_message.cc",
|
|
||||||
"src/google/protobuf/dynamic_message.h",
|
|
||||||
"src/google/protobuf/empty.pb.cc",
|
|
||||||
"src/google/protobuf/empty.pb.h",
|
|
||||||
"src/google/protobuf/extension_set_heavy.cc",
|
|
||||||
"src/google/protobuf/field_mask.pb.cc",
|
|
||||||
"src/google/protobuf/field_mask.pb.h",
|
|
||||||
"src/google/protobuf/generated_enum_reflection.h",
|
|
||||||
"src/google/protobuf/generated_enum_util.h",
|
|
||||||
"src/google/protobuf/generated_message_reflection.cc",
|
|
||||||
"src/google/protobuf/generated_message_reflection.h",
|
|
||||||
|
|
||||||
# gzip_stream.cc pulls in zlib, but it's not actually used by protoc, just
|
# The traffic_annotation tool is not part of Chrome itself, and needs to
|
||||||
# by test code, so instead of compiling zlib for the host, let's just
|
# parse human-readable protobufs.
|
||||||
# exclude this.
|
"//tools/traffic_annotation/*",
|
||||||
# "src/google/protobuf/io/gzip_stream.cc",
|
|
||||||
# "src/google/protobuf/io/gzip_stream.h",
|
|
||||||
|
|
||||||
"src/google/protobuf/io/printer.cc",
|
# Chromecast requires descriptors and reflection.
|
||||||
"src/google/protobuf/io/printer.h",
|
"//chromecast/*",
|
||||||
"src/google/protobuf/io/strtod.cc",
|
|
||||||
"src/google/protobuf/io/strtod.h",
|
# Perfetto uses the full library for testing.
|
||||||
"src/google/protobuf/io/tokenizer.cc",
|
"//third_party/perfetto/protos/ftrace:full",
|
||||||
"src/google/protobuf/io/tokenizer.h",
|
"//third_party/perfetto/gn:protobuf_full_deps",
|
||||||
"src/google/protobuf/io/zero_copy_stream_impl.cc",
|
|
||||||
"src/google/protobuf/io/zero_copy_stream_impl.h",
|
|
||||||
"src/google/protobuf/map_entry.h",
|
|
||||||
"src/google/protobuf/map_field.cc",
|
|
||||||
"src/google/protobuf/map_field.h",
|
|
||||||
"src/google/protobuf/map_field_inl.h",
|
|
||||||
"src/google/protobuf/message.cc",
|
|
||||||
"src/google/protobuf/message.h",
|
|
||||||
"src/google/protobuf/metadata.h",
|
|
||||||
"src/google/protobuf/reflection.h",
|
|
||||||
"src/google/protobuf/reflection_internal.h",
|
|
||||||
"src/google/protobuf/reflection_ops.cc",
|
|
||||||
"src/google/protobuf/reflection_ops.h",
|
|
||||||
"src/google/protobuf/service.cc",
|
|
||||||
"src/google/protobuf/service.h",
|
|
||||||
"src/google/protobuf/source_context.pb.cc",
|
|
||||||
"src/google/protobuf/source_context.pb.h",
|
|
||||||
"src/google/protobuf/struct.pb.cc",
|
|
||||||
"src/google/protobuf/struct.pb.h",
|
|
||||||
"src/google/protobuf/stubs/mathlimits.cc",
|
|
||||||
"src/google/protobuf/stubs/mathlimits.h",
|
|
||||||
"src/google/protobuf/stubs/mathutil.h",
|
|
||||||
"src/google/protobuf/stubs/singleton.h",
|
|
||||||
"src/google/protobuf/stubs/substitute.cc",
|
|
||||||
"src/google/protobuf/stubs/substitute.h",
|
|
||||||
"src/google/protobuf/text_format.cc",
|
|
||||||
"src/google/protobuf/text_format.h",
|
|
||||||
"src/google/protobuf/timestamp.pb.cc",
|
|
||||||
"src/google/protobuf/timestamp.pb.h",
|
|
||||||
"src/google/protobuf/type.pb.cc",
|
|
||||||
"src/google/protobuf/type.pb.h",
|
|
||||||
"src/google/protobuf/unknown_field_set.cc",
|
|
||||||
"src/google/protobuf/unknown_field_set.h",
|
|
||||||
"src/google/protobuf/util/field_comparator.cc",
|
|
||||||
"src/google/protobuf/util/field_comparator.h",
|
|
||||||
"src/google/protobuf/util/field_mask_util.cc",
|
|
||||||
"src/google/protobuf/util/field_mask_util.h",
|
|
||||||
"src/google/protobuf/util/internal/constants.h",
|
|
||||||
"src/google/protobuf/util/internal/datapiece.cc",
|
|
||||||
"src/google/protobuf/util/internal/datapiece.h",
|
|
||||||
"src/google/protobuf/util/internal/default_value_objectwriter.cc",
|
|
||||||
"src/google/protobuf/util/internal/default_value_objectwriter.h",
|
|
||||||
"src/google/protobuf/util/internal/error_listener.cc",
|
|
||||||
"src/google/protobuf/util/internal/error_listener.h",
|
|
||||||
"src/google/protobuf/util/internal/field_mask_utility.cc",
|
|
||||||
"src/google/protobuf/util/internal/field_mask_utility.h",
|
|
||||||
"src/google/protobuf/util/internal/json_escaping.cc",
|
|
||||||
"src/google/protobuf/util/internal/json_escaping.h",
|
|
||||||
"src/google/protobuf/util/internal/json_objectwriter.cc",
|
|
||||||
"src/google/protobuf/util/internal/json_objectwriter.h",
|
|
||||||
"src/google/protobuf/util/internal/json_stream_parser.cc",
|
|
||||||
"src/google/protobuf/util/internal/json_stream_parser.h",
|
|
||||||
"src/google/protobuf/util/internal/location_tracker.h",
|
|
||||||
"src/google/protobuf/util/internal/object_location_tracker.h",
|
|
||||||
"src/google/protobuf/util/internal/object_source.h",
|
|
||||||
"src/google/protobuf/util/internal/object_writer.cc",
|
|
||||||
"src/google/protobuf/util/internal/object_writer.h",
|
|
||||||
"src/google/protobuf/util/internal/proto_writer.cc",
|
|
||||||
"src/google/protobuf/util/internal/proto_writer.h",
|
|
||||||
"src/google/protobuf/util/internal/protostream_objectsource.cc",
|
|
||||||
"src/google/protobuf/util/internal/protostream_objectsource.h",
|
|
||||||
"src/google/protobuf/util/internal/protostream_objectwriter.cc",
|
|
||||||
"src/google/protobuf/util/internal/protostream_objectwriter.h",
|
|
||||||
"src/google/protobuf/util/internal/structured_objectwriter.h",
|
|
||||||
"src/google/protobuf/util/internal/type_info.cc",
|
|
||||||
"src/google/protobuf/util/internal/type_info.h",
|
|
||||||
"src/google/protobuf/util/internal/type_info_test_helper.cc",
|
|
||||||
"src/google/protobuf/util/internal/type_info_test_helper.h",
|
|
||||||
"src/google/protobuf/util/internal/utility.cc",
|
|
||||||
"src/google/protobuf/util/internal/utility.h",
|
|
||||||
"src/google/protobuf/util/json_util.cc",
|
|
||||||
"src/google/protobuf/util/json_util.h",
|
|
||||||
"src/google/protobuf/util/message_differencer.cc",
|
|
||||||
"src/google/protobuf/util/message_differencer.h",
|
|
||||||
"src/google/protobuf/util/time_util.cc",
|
|
||||||
"src/google/protobuf/util/time_util.h",
|
|
||||||
"src/google/protobuf/util/type_resolver.h",
|
|
||||||
"src/google/protobuf/util/type_resolver_util.cc",
|
|
||||||
"src/google/protobuf/util/type_resolver_util.h",
|
|
||||||
"src/google/protobuf/wire_format.cc",
|
|
||||||
"src/google/protobuf/wire_format.h",
|
|
||||||
"src/google/protobuf/wrappers.pb.cc",
|
|
||||||
"src/google/protobuf/wrappers.pb.h",
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
sources = protobuf_lite_sources + [
|
||||||
|
"src/google/protobuf/any.cc",
|
||||||
|
"src/google/protobuf/any.h",
|
||||||
|
"src/google/protobuf/any.pb.cc",
|
||||||
|
"src/google/protobuf/any.pb.h",
|
||||||
|
"src/google/protobuf/api.pb.cc",
|
||||||
|
"src/google/protobuf/api.pb.h",
|
||||||
|
"src/google/protobuf/compiler/importer.cc",
|
||||||
|
"src/google/protobuf/compiler/importer.h",
|
||||||
|
"src/google/protobuf/compiler/parser.cc",
|
||||||
|
"src/google/protobuf/compiler/parser.h",
|
||||||
|
"src/google/protobuf/descriptor.cc",
|
||||||
|
"src/google/protobuf/descriptor.h",
|
||||||
|
"src/google/protobuf/descriptor.pb.cc",
|
||||||
|
"src/google/protobuf/descriptor.pb.h",
|
||||||
|
"src/google/protobuf/descriptor_database.cc",
|
||||||
|
"src/google/protobuf/descriptor_database.h",
|
||||||
|
"src/google/protobuf/duration.pb.cc",
|
||||||
|
"src/google/protobuf/duration.pb.h",
|
||||||
|
"src/google/protobuf/dynamic_message.cc",
|
||||||
|
"src/google/protobuf/dynamic_message.h",
|
||||||
|
"src/google/protobuf/empty.pb.cc",
|
||||||
|
"src/google/protobuf/empty.pb.h",
|
||||||
|
"src/google/protobuf/extension_set_heavy.cc",
|
||||||
|
"src/google/protobuf/field_mask.pb.cc",
|
||||||
|
"src/google/protobuf/field_mask.pb.h",
|
||||||
|
"src/google/protobuf/generated_enum_reflection.h",
|
||||||
|
"src/google/protobuf/generated_enum_util.h",
|
||||||
|
"src/google/protobuf/generated_message_reflection.cc",
|
||||||
|
"src/google/protobuf/generated_message_reflection.h",
|
||||||
|
|
||||||
|
"src/google/protobuf/io/gzip_stream.cc",
|
||||||
|
"src/google/protobuf/io/gzip_stream.h",
|
||||||
|
|
||||||
|
"src/google/protobuf/io/printer.cc",
|
||||||
|
"src/google/protobuf/io/printer.h",
|
||||||
|
"src/google/protobuf/io/strtod.cc",
|
||||||
|
"src/google/protobuf/io/strtod.h",
|
||||||
|
"src/google/protobuf/io/tokenizer.cc",
|
||||||
|
"src/google/protobuf/io/tokenizer.h",
|
||||||
|
"src/google/protobuf/io/zero_copy_stream_impl.cc",
|
||||||
|
"src/google/protobuf/io/zero_copy_stream_impl.h",
|
||||||
|
"src/google/protobuf/map_entry.h",
|
||||||
|
"src/google/protobuf/map_field.cc",
|
||||||
|
"src/google/protobuf/map_field.h",
|
||||||
|
"src/google/protobuf/map_field_inl.h",
|
||||||
|
"src/google/protobuf/message.cc",
|
||||||
|
"src/google/protobuf/message.h",
|
||||||
|
"src/google/protobuf/metadata.h",
|
||||||
|
"src/google/protobuf/reflection.h",
|
||||||
|
"src/google/protobuf/reflection_internal.h",
|
||||||
|
"src/google/protobuf/reflection_ops.cc",
|
||||||
|
"src/google/protobuf/reflection_ops.h",
|
||||||
|
"src/google/protobuf/service.cc",
|
||||||
|
"src/google/protobuf/service.h",
|
||||||
|
"src/google/protobuf/source_context.pb.cc",
|
||||||
|
"src/google/protobuf/source_context.pb.h",
|
||||||
|
"src/google/protobuf/struct.pb.cc",
|
||||||
|
"src/google/protobuf/struct.pb.h",
|
||||||
|
"src/google/protobuf/stubs/mathlimits.cc",
|
||||||
|
"src/google/protobuf/stubs/mathlimits.h",
|
||||||
|
"src/google/protobuf/stubs/mathutil.h",
|
||||||
|
"src/google/protobuf/stubs/singleton.h",
|
||||||
|
"src/google/protobuf/stubs/substitute.cc",
|
||||||
|
"src/google/protobuf/stubs/substitute.h",
|
||||||
|
"src/google/protobuf/text_format.cc",
|
||||||
|
"src/google/protobuf/text_format.h",
|
||||||
|
"src/google/protobuf/timestamp.pb.cc",
|
||||||
|
"src/google/protobuf/timestamp.pb.h",
|
||||||
|
"src/google/protobuf/type.pb.cc",
|
||||||
|
"src/google/protobuf/type.pb.h",
|
||||||
|
"src/google/protobuf/unknown_field_set.cc",
|
||||||
|
"src/google/protobuf/unknown_field_set.h",
|
||||||
|
"src/google/protobuf/util/field_comparator.cc",
|
||||||
|
"src/google/protobuf/util/field_comparator.h",
|
||||||
|
"src/google/protobuf/util/field_mask_util.cc",
|
||||||
|
"src/google/protobuf/util/field_mask_util.h",
|
||||||
|
"src/google/protobuf/util/internal/constants.h",
|
||||||
|
"src/google/protobuf/util/internal/datapiece.cc",
|
||||||
|
"src/google/protobuf/util/internal/datapiece.h",
|
||||||
|
"src/google/protobuf/util/internal/default_value_objectwriter.cc",
|
||||||
|
"src/google/protobuf/util/internal/default_value_objectwriter.h",
|
||||||
|
"src/google/protobuf/util/internal/error_listener.cc",
|
||||||
|
"src/google/protobuf/util/internal/error_listener.h",
|
||||||
|
"src/google/protobuf/util/internal/field_mask_utility.cc",
|
||||||
|
"src/google/protobuf/util/internal/field_mask_utility.h",
|
||||||
|
"src/google/protobuf/util/internal/json_escaping.cc",
|
||||||
|
"src/google/protobuf/util/internal/json_escaping.h",
|
||||||
|
"src/google/protobuf/util/internal/json_objectwriter.cc",
|
||||||
|
"src/google/protobuf/util/internal/json_objectwriter.h",
|
||||||
|
"src/google/protobuf/util/internal/json_stream_parser.cc",
|
||||||
|
"src/google/protobuf/util/internal/json_stream_parser.h",
|
||||||
|
"src/google/protobuf/util/internal/location_tracker.h",
|
||||||
|
"src/google/protobuf/util/internal/object_location_tracker.h",
|
||||||
|
"src/google/protobuf/util/internal/object_source.h",
|
||||||
|
"src/google/protobuf/util/internal/object_writer.cc",
|
||||||
|
"src/google/protobuf/util/internal/object_writer.h",
|
||||||
|
"src/google/protobuf/util/internal/proto_writer.cc",
|
||||||
|
"src/google/protobuf/util/internal/proto_writer.h",
|
||||||
|
"src/google/protobuf/util/internal/protostream_objectsource.cc",
|
||||||
|
"src/google/protobuf/util/internal/protostream_objectsource.h",
|
||||||
|
"src/google/protobuf/util/internal/protostream_objectwriter.cc",
|
||||||
|
"src/google/protobuf/util/internal/protostream_objectwriter.h",
|
||||||
|
"src/google/protobuf/util/internal/structured_objectwriter.h",
|
||||||
|
"src/google/protobuf/util/internal/type_info.cc",
|
||||||
|
"src/google/protobuf/util/internal/type_info.h",
|
||||||
|
"src/google/protobuf/util/internal/type_info_test_helper.cc",
|
||||||
|
"src/google/protobuf/util/internal/type_info_test_helper.h",
|
||||||
|
"src/google/protobuf/util/internal/utility.cc",
|
||||||
|
"src/google/protobuf/util/internal/utility.h",
|
||||||
|
"src/google/protobuf/util/json_util.cc",
|
||||||
|
"src/google/protobuf/util/json_util.h",
|
||||||
|
"src/google/protobuf/util/message_differencer.cc",
|
||||||
|
"src/google/protobuf/util/message_differencer.h",
|
||||||
|
"src/google/protobuf/util/time_util.cc",
|
||||||
|
"src/google/protobuf/util/time_util.h",
|
||||||
|
"src/google/protobuf/util/type_resolver.h",
|
||||||
|
"src/google/protobuf/util/type_resolver_util.cc",
|
||||||
|
"src/google/protobuf/util/type_resolver_util.h",
|
||||||
|
"src/google/protobuf/wire_format.cc",
|
||||||
|
"src/google/protobuf/wire_format.h",
|
||||||
|
"src/google/protobuf/wrappers.pb.cc",
|
||||||
|
"src/google/protobuf/wrappers.pb.h",
|
||||||
|
]
|
||||||
|
|
||||||
deps = [
|
deps = [
|
||||||
"//build/config/sanitizers:deps",
|
"//build/config:exe_and_shlib_deps",
|
||||||
|
"//third_party/zlib",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
if (is_android) {
|
||||||
|
libs = [ "log" ] # Used by src/google/protobuf/stubs/common.cc
|
||||||
|
}
|
||||||
|
|
||||||
configs -= [ "//build/config/compiler:chromium_code" ]
|
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||||
configs += [
|
configs += [
|
||||||
"//build/config/compiler:no_chromium_code",
|
"//build/config/compiler:no_chromium_code",
|
||||||
|
@ -320,6 +374,13 @@ static_library("protobuf_full") {
|
||||||
# correctly.
|
# correctly.
|
||||||
":protobuf_warnings",
|
":protobuf_warnings",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
# Remove coverage and Sanitizers other than ASan for a performance boost when
|
||||||
|
# fuzzing. ASan can't be removed here because of a bug preventing unsanitized
|
||||||
|
# code from using libc++, which protobuf_full uses.
|
||||||
|
configs -= not_fuzzed_remove_nonasan_configs
|
||||||
|
configs += [ "//build/config/sanitizers:not_fuzzed" ]
|
||||||
|
|
||||||
if (is_win) {
|
if (is_win) {
|
||||||
configs -= [ "//build/config/win:lean_and_mean" ]
|
configs -= [ "//build/config/win:lean_and_mean" ]
|
||||||
}
|
}
|
||||||
|
@ -331,6 +392,8 @@ static_library("protobuf_full") {
|
||||||
]
|
]
|
||||||
|
|
||||||
cflags = protobuf_lite_cflags
|
cflags = protobuf_lite_cflags
|
||||||
|
|
||||||
|
defines = [ "HAVE_ZLIB" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Only compile the compiler for the host architecture.
|
# Only compile the compiler for the host architecture.
|
||||||
|
@ -452,6 +515,7 @@ if (current_toolchain == host_toolchain) {
|
||||||
"src/google/protobuf/compiler/java/java_message_lite.h",
|
"src/google/protobuf/compiler/java/java_message_lite.h",
|
||||||
"src/google/protobuf/compiler/java/java_name_resolver.cc",
|
"src/google/protobuf/compiler/java/java_name_resolver.cc",
|
||||||
"src/google/protobuf/compiler/java/java_name_resolver.h",
|
"src/google/protobuf/compiler/java/java_name_resolver.h",
|
||||||
|
"src/google/protobuf/compiler/java/java_options.h",
|
||||||
"src/google/protobuf/compiler/java/java_primitive_field.cc",
|
"src/google/protobuf/compiler/java/java_primitive_field.cc",
|
||||||
"src/google/protobuf/compiler/java/java_primitive_field.h",
|
"src/google/protobuf/compiler/java/java_primitive_field.h",
|
||||||
"src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
|
"src/google/protobuf/compiler/java/java_primitive_field_lite.cc",
|
||||||
|
@ -488,6 +552,8 @@ if (current_toolchain == host_toolchain) {
|
||||||
"src/google/protobuf/compiler/javanano/javanano_primitive_field.h",
|
"src/google/protobuf/compiler/javanano/javanano_primitive_field.h",
|
||||||
"src/google/protobuf/compiler/js/js_generator.cc",
|
"src/google/protobuf/compiler/js/js_generator.cc",
|
||||||
"src/google/protobuf/compiler/js/js_generator.h",
|
"src/google/protobuf/compiler/js/js_generator.h",
|
||||||
|
"src/google/protobuf/compiler/js/well_known_types_embed.cc",
|
||||||
|
"src/google/protobuf/compiler/js/well_known_types_embed.h",
|
||||||
"src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
|
"src/google/protobuf/compiler/objectivec/objectivec_enum.cc",
|
||||||
"src/google/protobuf/compiler/objectivec/objectivec_enum.h",
|
"src/google/protobuf/compiler/objectivec/objectivec_enum.h",
|
||||||
"src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
|
"src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc",
|
||||||
|
@ -512,6 +578,8 @@ if (current_toolchain == host_toolchain) {
|
||||||
"src/google/protobuf/compiler/objectivec/objectivec_oneof.h",
|
"src/google/protobuf/compiler/objectivec/objectivec_oneof.h",
|
||||||
"src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
|
"src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc",
|
||||||
"src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h",
|
"src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h",
|
||||||
|
"src/google/protobuf/compiler/php/php_generator.cc",
|
||||||
|
"src/google/protobuf/compiler/php/php_generator.h",
|
||||||
"src/google/protobuf/compiler/plugin.cc",
|
"src/google/protobuf/compiler/plugin.cc",
|
||||||
"src/google/protobuf/compiler/plugin.h",
|
"src/google/protobuf/compiler/plugin.h",
|
||||||
"src/google/protobuf/compiler/plugin.pb.cc",
|
"src/google/protobuf/compiler/plugin.pb.cc",
|
||||||
|
@ -565,6 +633,18 @@ if (current_toolchain == host_toolchain) {
|
||||||
"//build/win:default_exe_manifest",
|
"//build/win:default_exe_manifest",
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
executable("js_embed") {
|
||||||
|
deps = [
|
||||||
|
"//build/config:exe_and_shlib_deps",
|
||||||
|
]
|
||||||
|
sources = [
|
||||||
|
"src/google/protobuf/compiler/js/embed.cc",
|
||||||
|
]
|
||||||
|
|
||||||
|
configs -= [ "//build/config/compiler:chromium_code" ]
|
||||||
|
configs += [ "//build/config/compiler:no_chromium_code" ]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
google_python_dir = "$root_out_dir/pyproto/google"
|
google_python_dir = "$root_out_dir/pyproto/google"
|
||||||
|
@ -650,3 +730,59 @@ group("py_proto") {
|
||||||
data += get_target_outputs(":copy_google_protobuf")
|
data += get_target_outputs(":copy_google_protobuf")
|
||||||
data += get_target_outputs(":copy_google_protobuf_internal")
|
data += get_target_outputs(":copy_google_protobuf_internal")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (is_android) {
|
||||||
|
import("//build/config/android/rules.gni")
|
||||||
|
|
||||||
|
android_library("protobuf_lite_javalib") {
|
||||||
|
chromium_code = false
|
||||||
|
java_files = [
|
||||||
|
"java/core/src/main/java/com/google/protobuf/AbstractMessageLite.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/AbstractParser.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/AbstractProtobufList.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/BooleanArrayList.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/ByteBufferWriter.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/ByteOutput.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/ByteString.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/CodedInputStream.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/CodedOutputStream.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/DoubleArrayList.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/ExperimentalApi.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/ExtensionLite.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/ExtensionRegistryFactory.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/FieldSet.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/FloatArrayList.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/IntArrayList.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/Internal.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/LazyField.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/LazyFieldLite.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/LazyStringArrayList.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/LazyStringList.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/LongArrayList.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/MapEntryLite.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/MapFieldLite.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/MessageLite.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/MessageLiteToString.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/MutabilityOracle.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/NioByteString.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/Parser.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/PrimitiveNonBoxingCollection.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/ProtocolStringList.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/RopeByteString.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/SmallSortedMap.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/TextFormatEscaper.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/UninitializedMessageException.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/UnsafeUtil.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/Utf8.java",
|
||||||
|
"java/core/src/main/java/com/google/protobuf/WireFormat.java",
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -1,3 +1,415 @@
|
||||||
|
2017-04-05 version 3.3.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
|
||||||
|
Planned Future Changes
|
||||||
|
* There are some changes that are not included in this release but are
|
||||||
|
planned for the near future:
|
||||||
|
- Preserve unknown fields in proto3: please read this doc:
|
||||||
|
|
||||||
|
https://docs.google.com/document/d/1KMRX-G91Aa-Y2FkEaHeeviLRRNblgIahbsk4wA14gRk/view
|
||||||
|
|
||||||
|
for the timeline and follow up this github issue:
|
||||||
|
|
||||||
|
https://github.com/google/protobuf/issues/272
|
||||||
|
|
||||||
|
for discussion.
|
||||||
|
- Make C++ implementation C++11 only: we plan to require C++11 to build
|
||||||
|
protobuf code starting from 3.4.0 or 3.5.0 release. Please join this
|
||||||
|
github issue:
|
||||||
|
|
||||||
|
https://github.com/google/protobuf/issues/2780
|
||||||
|
|
||||||
|
to provide your feedback.
|
||||||
|
|
||||||
|
C++
|
||||||
|
* Fixed map fields serialization of DynamicMessage to correctly serialize
|
||||||
|
both key and value regardless of their presence.
|
||||||
|
* Parser now rejects field number 0 correctly.
|
||||||
|
* New API Message::SpaceUsedLong() that’s equivalent to
|
||||||
|
Message::SpaceUsed() but returns the value in size_t.
|
||||||
|
* JSON support
|
||||||
|
- New flag always_print_enums_as_ints in JsonPrintOptions.
|
||||||
|
- New flag preserve_proto_field_names in JsonPrintOptions. It will instruct
|
||||||
|
the JSON printer to use the original field name declared in the .proto
|
||||||
|
file instead of converting them to lowerCamelCase when printing JSON.
|
||||||
|
- JsonPrintOptions.always_print_primtive_fields now works for oneof message
|
||||||
|
fields.
|
||||||
|
- Fixed a bug that doesn’t allow different fields to set the same json_name
|
||||||
|
value.
|
||||||
|
- Fixed a performance bug that causes excessive memory copy when printing
|
||||||
|
large messages.
|
||||||
|
* Various performance optimizations.
|
||||||
|
|
||||||
|
Java
|
||||||
|
* Map field setters eagerly validate inputs and throw NullPointerExceptions
|
||||||
|
as appropriate.
|
||||||
|
* Added ByteBuffer overloads to the generated parsing methods and the Parser
|
||||||
|
interface.
|
||||||
|
* proto3 enum's getNumber() method now throws on UNRECOGNIZED values.
|
||||||
|
* Output of JsonFormat is now locale independent.
|
||||||
|
|
||||||
|
Python
|
||||||
|
* Added FindServiceByName() in the pure-Python DescriptorPool. This works only
|
||||||
|
for descriptors added with DescriptorPool.Add(). Generated descriptor_pool
|
||||||
|
does not support this yet.
|
||||||
|
* Added a descriptor_pool parameter for parsing Any in text_format.Parse().
|
||||||
|
* descriptor_pool.FindFileContainingSymbol() now is able to find nested
|
||||||
|
extensions.
|
||||||
|
* Extending empty [] to repeated field now sets parent message presence.
|
||||||
|
|
||||||
|
PHP
|
||||||
|
* Added file option php_class_prefix. The prefix will be prepended to all
|
||||||
|
generated classes defined in the file.
|
||||||
|
* When encoding, negative int32 values are sign-extended to int64.
|
||||||
|
* Repeated/Map field setter accepts a regular PHP array. Type checking is
|
||||||
|
done on the array elements.
|
||||||
|
* encode/decode are renamed to serializeToString/mergeFromString.
|
||||||
|
* Added mergeFrom, clear method on Message.
|
||||||
|
* Fixed a bug that oneof accessor didn’t return the field name that is
|
||||||
|
actually set.
|
||||||
|
* C extension now works with php7.
|
||||||
|
* This is the first GA release of PHP. We guarantee that old generated code
|
||||||
|
can always work with new runtime and new generated code.
|
||||||
|
|
||||||
|
Objective-C
|
||||||
|
* Fixed help for GPBTimestamp for dates before the epoch that contain
|
||||||
|
fractional seconds.
|
||||||
|
* Added GPBMessageDropUnknownFieldsRecursively() to remove unknowns from a
|
||||||
|
message and any sub messages.
|
||||||
|
* Addressed a threading race in extension registration/lookup.
|
||||||
|
* Increased the max message parsing depth to 100 to match the other languages.
|
||||||
|
* Removed some use of dispatch_once in favor of atomic compare/set since it
|
||||||
|
needs to be heap based.
|
||||||
|
* Fixes for new Xcode 8.3 warnings.
|
||||||
|
|
||||||
|
C#
|
||||||
|
* Fixed MapField.Values.CopyTo, which would throw an exception unnecessarily
|
||||||
|
if provided exactly the right size of array to copy to.
|
||||||
|
* Fixed enum JSON formatting when multiple names mapped to the same numeric
|
||||||
|
value.
|
||||||
|
* Added JSON formatting option to format enums as integers.
|
||||||
|
* Modified RepeatedField<T> to implement IReadOnlyList<T>.
|
||||||
|
* Introduced the start of custom option handling; it's not as pleasant as it
|
||||||
|
might be, but the information is at least present. We expect to extend code
|
||||||
|
generation to improve this in the future.
|
||||||
|
* Introduced ByteString.FromStream and ByteString.FromStreamAsync to
|
||||||
|
efficiently create a ByteString from a stream.
|
||||||
|
* Added whole-message deprecation, which decorates the class with [Obsolete].
|
||||||
|
|
||||||
|
Ruby
|
||||||
|
* Fixed Message#to_h for messages with map fields.
|
||||||
|
* Fixed memcpy() in binary gems to work for old glibc, without breaking the
|
||||||
|
build for non-glibc libc’s like musl.
|
||||||
|
|
||||||
|
Javascript
|
||||||
|
* Added compatibility tests for version 3.0.0.
|
||||||
|
* Added conformance tests.
|
||||||
|
* Fixed serialization of extensions: we need to emit a value even if it is
|
||||||
|
falsy (like the number 0).
|
||||||
|
* Use closurebuilder.py in favor of calcdeps.py for compiling JavaScript.
|
||||||
|
|
||||||
|
2017-01-23 version 3.2.0 (C++/Java/Python/PHP/Ruby/Objective-C/C#/JavaScript/Lite)
|
||||||
|
General
|
||||||
|
* Added protoc version number to protoc plugin protocol. It can be used by
|
||||||
|
protoc plugin to detect which version of protoc is used with the plugin and
|
||||||
|
mitigate known problems in certain version of protoc.
|
||||||
|
|
||||||
|
C++
|
||||||
|
* The default parsing byte size limit has been raised from 64MB to 2GB.
|
||||||
|
* Added rvalue setters for non-arena string fields.
|
||||||
|
* Enabled debug logging for Android.
|
||||||
|
* Fixed a double-free problem when using Reflection::SetAllocatedMessage()
|
||||||
|
with extension fields.
|
||||||
|
* Fixed several deterministic serialization bugs:
|
||||||
|
* MessageLite::SerializeAsString() now respects the global deterministic
|
||||||
|
serialization flag.
|
||||||
|
* Extension fields are serialized deterministically as well. Fixed protocol
|
||||||
|
compiler to correctly report importing-self as an error.
|
||||||
|
* Fixed FileDescriptor::DebugString() to print custom options correctly.
|
||||||
|
* Various performance/codesize optimizations and cleanups.
|
||||||
|
|
||||||
|
Java
|
||||||
|
* The default parsing byte size limit has been raised from 64MB to 2GB.
|
||||||
|
* Added recursion limit when parsing JSON.
|
||||||
|
* Fixed a bug that enumType.getDescriptor().getOptions() doesn't have custom
|
||||||
|
options.
|
||||||
|
* Fixed generated code to support field numbers up to 2^29-1.
|
||||||
|
|
||||||
|
Python
|
||||||
|
* You can now assign NumPy scalars/arrays (np.int32, np.int64) to protobuf
|
||||||
|
fields, and assigning other numeric types has been optimized for
|
||||||
|
performance.
|
||||||
|
* Pure-Python: message types are now garbage-collectable.
|
||||||
|
* Python/C++: a lot of internal cleanup/refactoring.
|
||||||
|
|
||||||
|
PHP (Alpha)
|
||||||
|
* For 64-bit integers type (int64/uint64/sfixed64/fixed64/sint64), use PHP
|
||||||
|
integer on 64-bit environment and PHP string on 32-bit environment.
|
||||||
|
* PHP generated code also conforms to PSR-4 now.
|
||||||
|
* Fixed ZTS build for c extension.
|
||||||
|
* Fixed c extension build on Mac.
|
||||||
|
* Fixed c extension build on 32-bit linux.
|
||||||
|
* Fixed the bug that message without namespace is not found in the descriptor
|
||||||
|
pool. (#2240)
|
||||||
|
* Fixed the bug that repeated field is not iterable in c extension.
|
||||||
|
* Message names Empty will be converted to GPBEmpty in generated code.
|
||||||
|
* Added phpdoc in generated files.
|
||||||
|
* The released API is almost stable. Unless there is large problem, we won't
|
||||||
|
change it. See
|
||||||
|
https://developers.google.com/protocol-buffers/docs/reference/php-generated
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
Objective-C
|
||||||
|
* Added support for push/pop of the stream limit on CodedInputStream for
|
||||||
|
anyone doing manual parsing.
|
||||||
|
|
||||||
|
C#
|
||||||
|
* No changes.
|
||||||
|
|
||||||
|
Ruby
|
||||||
|
* Message objects now support #respond_to? for field getters/setters.
|
||||||
|
* You can now compare “message == non_message_object” and it will return false
|
||||||
|
instead of throwing an exception.
|
||||||
|
* JRuby: fixed #hashCode to properly reflect the values in the message.
|
||||||
|
|
||||||
|
Javascript
|
||||||
|
* Deserialization of repeated fields no longer has quadratic performance
|
||||||
|
behavior.
|
||||||
|
* UTF-8 encoding/decoding now properly supports high codepoints.
|
||||||
|
* Added convenience methods for some well-known types: Any, Struct, and
|
||||||
|
Timestamp. These make it easier to convert data between native JavaScript
|
||||||
|
types and the well-known protobuf types.
|
||||||
|
|
||||||
|
2016-09-23 version 3.1.0 (C++/Java/Python/PHP/Ruby/Objective-C/C#/JavaScript/Lite)
|
||||||
|
General
|
||||||
|
* Proto3 support in PHP (alpha).
|
||||||
|
* Various bug fixes.
|
||||||
|
|
||||||
|
C++
|
||||||
|
* Added MessageLite::ByteSizeLong() that’s equivalent to
|
||||||
|
MessageLite::ByteSize() but returns the value in size_t. Useful to check
|
||||||
|
whether a message is over the 2G size limit that protobuf can support.
|
||||||
|
* Moved default_instances to global variables. This allows default_instance
|
||||||
|
addresses to be known at compile time.
|
||||||
|
* Adding missing generic gcc 64-bit atomicops.
|
||||||
|
* Restore New*Callback into google::protobuf namespace since these are used
|
||||||
|
by the service stubs code
|
||||||
|
* JSON support.
|
||||||
|
* Fixed some conformance issues.
|
||||||
|
* Fixed a JSON serialization bug for bytes fields.
|
||||||
|
|
||||||
|
Java
|
||||||
|
* Fixed a bug in TextFormat that doesn’t accept empty repeated fields (i.e.,
|
||||||
|
“field: [ ]”).
|
||||||
|
* JSON support
|
||||||
|
* Fixed JsonFormat to do correct snake_case-to-camelCase conversion for
|
||||||
|
non-style-conforming field names.
|
||||||
|
* Fixed JsonFormat to parse empty Any message correctly.
|
||||||
|
* Added an option to JsonFormat.Parser to ignore unknown fields.
|
||||||
|
* Experimental API
|
||||||
|
* Added UnsafeByteOperations.unsafeWrap(byte[]) to wrap a byte array into
|
||||||
|
ByteString without copy.
|
||||||
|
|
||||||
|
Python
|
||||||
|
* JSON support
|
||||||
|
* Fixed some conformance issues.
|
||||||
|
|
||||||
|
PHP (Alpha)
|
||||||
|
* We have added the proto3 support for PHP via both a pure PHP package and a
|
||||||
|
native c extension. The pure PHP package is intended to provide usability
|
||||||
|
to wider range of PHP platforms, while the c extension is intended to
|
||||||
|
provide higher performance. Both implementations provide the same runtime
|
||||||
|
APIs and share the same generated code. Users don’t need to re-generate
|
||||||
|
code for the same proto definition when they want to switch the
|
||||||
|
implementation later. The pure PHP package is included in the php/src
|
||||||
|
directory, and the c extension is included in the php/ext directory.
|
||||||
|
|
||||||
|
Both implementations provide idiomatic PHP APIs:
|
||||||
|
* All messages and enums are defined as PHP classes.
|
||||||
|
* All message fields can only be accessed via getter/setter.
|
||||||
|
* Both repeated field elements and map elements are stored in containers
|
||||||
|
that act like a normal PHP array.
|
||||||
|
|
||||||
|
Unlike several existing third-party PHP implementations for protobuf, our
|
||||||
|
implementations are built on a "strongly-typed" philosophy: message fields
|
||||||
|
and array/map containers will throw exceptions eagerly when values of the
|
||||||
|
incorrect type (not including those that can be type converted, e.g.,
|
||||||
|
double <-> integer <-> numeric string) are inserted.
|
||||||
|
|
||||||
|
Currently, pure PHP runtime supports php5.5, 5.6 and 7 on linux. C
|
||||||
|
extension runtime supports php5.5 and 5.6 on linux.
|
||||||
|
|
||||||
|
See php/README.md for more details about installment. See
|
||||||
|
https://developers.google.com/protocol-buffers/docs/phptutorial for more
|
||||||
|
details about APIs.
|
||||||
|
|
||||||
|
Objective-C
|
||||||
|
* Helpers are now provided for working the the Any well known type (see
|
||||||
|
GPBWellKnownTypes.h for the api additions).
|
||||||
|
* Some improvements in startup code (especially when extensions aren’t used).
|
||||||
|
|
||||||
|
Javascript
|
||||||
|
* Fixed missing import of jspb.Map
|
||||||
|
* Fixed valueWriterFn variable name
|
||||||
|
|
||||||
|
Ruby
|
||||||
|
* Fixed hash computation for JRuby's RubyMessage
|
||||||
|
* Make sure map parsing frames are GC-rooted.
|
||||||
|
* Added API support for well-known types.
|
||||||
|
|
||||||
|
C#
|
||||||
|
* Removed check on dependency in the C# reflection API.
|
||||||
|
|
||||||
|
2016-09-06 version 3.0.2 (C++/Java/Python/Ruby/Objective-C/C#/JavaScript/Lite)
|
||||||
|
General
|
||||||
|
* Various bug fixes.
|
||||||
|
|
||||||
|
Objective C
|
||||||
|
* Fix for oneofs in proto3 syntax files where fields were set to the zero
|
||||||
|
value.
|
||||||
|
* Fix for embedded null character in strings.
|
||||||
|
* CocoaDocs support
|
||||||
|
|
||||||
|
Ruby
|
||||||
|
* Fixed memory corruption bug in parsing that could occur under GC pressure.
|
||||||
|
|
||||||
|
Javascript
|
||||||
|
* jspb.Map is now properly exported to CommonJS modules.
|
||||||
|
|
||||||
|
C#
|
||||||
|
* Removed legacy_enum_values flag.
|
||||||
|
|
||||||
|
|
||||||
|
2016-07-27 version 3.0.0 (C++/Java/Python/Ruby/Objective-C/C#/JavaScript/Lite)
|
||||||
|
General
|
||||||
|
* This log only contains changes since the beta-4 release. Summarized change
|
||||||
|
log since the last stable release (v2.6.1) can be found in the github
|
||||||
|
release page.
|
||||||
|
|
||||||
|
Compatibility Notice
|
||||||
|
* v3.0.0 is the first API stable release of the v3.x series. We do not expect
|
||||||
|
any future API breaking changes.
|
||||||
|
* For C++, Java Lite and Objective-C, source level compatibility is
|
||||||
|
guaranteed. Upgrading from v3.0.0 to newer minor version releases will be
|
||||||
|
source compatible. For example, if your code compiles against protobuf
|
||||||
|
v3.0.0, it will continue to compile after you upgrade protobuf library to
|
||||||
|
v3.1.0.
|
||||||
|
* For other languages, both source level compatibility and binary level
|
||||||
|
compatibility are guaranteed. For example, if you have a Java binary built
|
||||||
|
against protobuf v3.0.0. After switching the protobuf runtime binary to
|
||||||
|
v3.1.0, your built binary should continue to work.
|
||||||
|
* Compatibility is only guaranteed for documented API and documented
|
||||||
|
behaviors. If you are using undocumented API (e.g., use anything in the C++
|
||||||
|
internal namespace), it can be broken by minor version releases in an
|
||||||
|
undetermined manner.
|
||||||
|
|
||||||
|
Ruby
|
||||||
|
* When you assign a string field `a.string_field = "X"`, we now call
|
||||||
|
#encode(UTF-8) on the string and freeze the copy. This saves you from
|
||||||
|
needing to ensure the string is already encoded as UTF-8. It also prevents
|
||||||
|
you from mutating the string after it has been assigned (this is how we
|
||||||
|
ensure it stays valid UTF-8).
|
||||||
|
* The generated file for `foo.proto` is now `foo_pb.rb` instead of just
|
||||||
|
`foo.rb`. This makes it easier to see which imports/requires are from
|
||||||
|
protobuf generated code, and also prevents conflicts with any `foo.rb` file
|
||||||
|
you might have written directly in Ruby. It is a backward-incompatible
|
||||||
|
change: you will need to update all of your `require` statements.
|
||||||
|
* For package names like `foo_bar`, we now translate this to the Ruby module
|
||||||
|
`FooBar`. This is more idiomatic Ruby than what we used to do (`Foo_bar`).
|
||||||
|
|
||||||
|
JavaScript
|
||||||
|
* Scalar fields like numbers and boolean now return defaults instead of
|
||||||
|
`undefined` or `null` when they are unset. You can test for presence
|
||||||
|
explicitly by calling `hasFoo()`, which we now generate for scalar fields.
|
||||||
|
|
||||||
|
Java Lite
|
||||||
|
* Java Lite is now implemented as a separate plugin, maintained in the
|
||||||
|
`javalite` branch. Both lite runtime and protoc artifacts will be available
|
||||||
|
in Maven.
|
||||||
|
|
||||||
|
C#
|
||||||
|
* Target platforms now .NET 4.5, selected portable subsets and .NET Core.
|
||||||
|
* legacy_enum_values option is no longer supported.
|
||||||
|
|
||||||
|
2016-07-15 version 3.0.0-beta-4 (C++/Java/Python/Ruby/Objective-C/C#/JavaScript)
|
||||||
|
General
|
||||||
|
* Added a deterministic serialization API for C++. The deterministic
|
||||||
|
serialization guarantees that given a binary, equal messages will be
|
||||||
|
serialized to the same bytes. This allows applications like MapReduce to
|
||||||
|
group equal messages based on the serialized bytes. The deterministic
|
||||||
|
serialization is, however, NOT canonical across languages; it is also
|
||||||
|
unstable across different builds with schema changes due to unknown fields.
|
||||||
|
Users who need canonical serialization, e.g. persistent storage in a
|
||||||
|
canonical form, fingerprinting, etc, should define their own
|
||||||
|
canonicalization specification and implement the serializer using reflection
|
||||||
|
APIs rather than relying on this API.
|
||||||
|
* Added OneofOptions. You can now define custom options for oneof groups.
|
||||||
|
import "google/protobuf/descriptor.proto";
|
||||||
|
extend google.protobuf.OneofOptions {
|
||||||
|
optional int32 my_oneof_extension = 12345;
|
||||||
|
}
|
||||||
|
message Foo {
|
||||||
|
oneof oneof_group {
|
||||||
|
(my_oneof_extension) = 54321;
|
||||||
|
...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
C++ (beta)
|
||||||
|
* Introduced a deterministic serialization API in
|
||||||
|
CodedOutputStream::SetSerializationDeterministic(bool). See the notes about
|
||||||
|
deterministic serialization in the General section.
|
||||||
|
* Added google::protobuf::Map::swap() to swap two map fields.
|
||||||
|
* Fixed a memory leak when calling Reflection::ReleaseMessage() on a message
|
||||||
|
allocated on arena.
|
||||||
|
* Improved error reporting when parsing text format protos.
|
||||||
|
* JSON
|
||||||
|
- Added a new parser option to ignore unknown fields when parsing JSON.
|
||||||
|
- Added convenient methods for message to/from JSON conversion.
|
||||||
|
* Various performance optimizations.
|
||||||
|
|
||||||
|
Java (beta)
|
||||||
|
* File option "java_generate_equals_and_hash" is now deprecated. equals() and
|
||||||
|
hashCode() methods are generated by default.
|
||||||
|
* Added a new JSON printer option "omittingInsignificantWhitespace" to produce
|
||||||
|
a more compact JSON output. The printer will pretty-print by default.
|
||||||
|
* Updated Java runtime to be compatible with 2.5.0/2.6.1 generated protos.
|
||||||
|
|
||||||
|
Python (beta)
|
||||||
|
* Added support to pretty print Any messages in text format.
|
||||||
|
* Added a flag to ignore unknown fields when parsing JSON.
|
||||||
|
* Bugfix: "@type" field of a JSON Any message is now correctly put before
|
||||||
|
other fields.
|
||||||
|
|
||||||
|
Objective-C (beta)
|
||||||
|
* Updated the code to support compiling with more compiler warnings
|
||||||
|
enabled. (Issue 1616)
|
||||||
|
* Exposing more detailed errors for parsing failures. (PR 1623)
|
||||||
|
* Small (breaking) change to the naming of some methods on the support classes
|
||||||
|
for map<>. There were collisions with the system provided KVO support, so
|
||||||
|
the names were changed to avoid those issues. (PR 1699)
|
||||||
|
* Fixed for proper Swift bridging of error handling during parsing. (PR 1712)
|
||||||
|
* Complete support for generating sources that will go into a Framework and
|
||||||
|
depend on generated sources from other Frameworks. (Issue 1457)
|
||||||
|
|
||||||
|
C# (beta)
|
||||||
|
* RepeatedField optimizations.
|
||||||
|
* Support for .NET Core.
|
||||||
|
* Minor bug fixes.
|
||||||
|
* Ability to format a single value in JsonFormatter (advanced usage only).
|
||||||
|
* Modifications to attributes applied to generated code.
|
||||||
|
|
||||||
|
Javascript (alpha)
|
||||||
|
* Maps now have a real map API instead of being treated as repeated fields.
|
||||||
|
* Well-known types are now provided in the google-protobuf package, and the
|
||||||
|
code generator knows to require() them from that package.
|
||||||
|
* Bugfix: non-canonical varints are correctly decoded.
|
||||||
|
|
||||||
|
Ruby (alpha)
|
||||||
|
* Accessors for oneof fields now return default values instead of nil.
|
||||||
|
|
||||||
|
Java Lite
|
||||||
|
* Java lite support is removed from protocol compiler. It will be supported
|
||||||
|
as a protocol compiler plugin in a separate code branch.
|
||||||
|
|
||||||
2016-05-16 version 3.0.0-beta-3 (C++/Java/Python/Ruby/Nano/Objective-C/C#/JavaScript)
|
2016-05-16 version 3.0.0-beta-3 (C++/Java/Python/Ruby/Nano/Objective-C/C#/JavaScript)
|
||||||
General
|
General
|
||||||
* Supported Proto3 lite-runtime in C++/Java for mobile platforms.
|
* Supported Proto3 lite-runtime in C++/Java for mobile platforms.
|
||||||
|
@ -1077,7 +1489,7 @@
|
||||||
2008-09-29 version 2.0.2:
|
2008-09-29 version 2.0.2:
|
||||||
|
|
||||||
General
|
General
|
||||||
* License changed from Apache 2.0 to New BSD.
|
* License changed from Apache 2.0 to 3-Clause BSD.
|
||||||
* It is now possible to define custom "options", which are basically
|
* It is now possible to define custom "options", which are basically
|
||||||
annotations which may be placed on definitions in a .proto file.
|
annotations which may be placed on definitions in a .proto file.
|
||||||
For example, you might define a field option called "foo" like so:
|
For example, you might define a field option called "foo" like so:
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
Copyright 2008, Google Inc.
|
|
||||||
All rights reserved.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
Code generated by the Protocol Buffer compiler is owned by the owner
|
|
||||||
of the input file used when generating it. This code is not
|
|
||||||
standalone and requires a support library to be linked with it. This
|
|
||||||
support library is itself covered by the above license.
|
|
|
@ -1,3 +1,6 @@
|
||||||
skip_child_includes = [
|
skip_child_includes = [
|
||||||
|
'benchmarks',
|
||||||
|
'conformance',
|
||||||
'objectivec',
|
'objectivec',
|
||||||
|
'src',
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,237 +0,0 @@
|
||||||
This file contains detailed but generic information on building and
|
|
||||||
installing the C++ part of this project. For shorter instructions,
|
|
||||||
as well as instructions for compiling and installing the Java or
|
|
||||||
Python parts, see README.
|
|
||||||
|
|
||||||
======================================================================
|
|
||||||
|
|
||||||
Copyright 1994, 1995, 1996, 1999, 2000, 2001, 2002 Free Software
|
|
||||||
Foundation, Inc.
|
|
||||||
|
|
||||||
This file is free documentation; the Free Software Foundation gives
|
|
||||||
unlimited permission to copy, distribute and modify it.
|
|
||||||
|
|
||||||
|
|
||||||
Basic Installation
|
|
||||||
==================
|
|
||||||
|
|
||||||
These are generic installation instructions.
|
|
||||||
|
|
||||||
The `configure' shell script attempts to guess correct values for
|
|
||||||
various system-dependent variables used during compilation. It uses
|
|
||||||
those values to create a `Makefile' in each directory of the package.
|
|
||||||
It may also create one or more `.h' files containing system-dependent
|
|
||||||
definitions. Finally, it creates a shell script `config.status' that
|
|
||||||
you can run in the future to recreate the current configuration, and a
|
|
||||||
file `config.log' containing compiler output (useful mainly for
|
|
||||||
debugging `configure').
|
|
||||||
|
|
||||||
It can also use an optional file (typically called `config.cache'
|
|
||||||
and enabled with `--cache-file=config.cache' or simply `-C') that saves
|
|
||||||
the results of its tests to speed up reconfiguring. (Caching is
|
|
||||||
disabled by default to prevent problems with accidental use of stale
|
|
||||||
cache files.)
|
|
||||||
|
|
||||||
If you need to do unusual things to compile the package, please try
|
|
||||||
to figure out how `configure' could check whether to do them, and mail
|
|
||||||
diffs or instructions to the address given in the `README' so they can
|
|
||||||
be considered for the next release. If you are using the cache, and at
|
|
||||||
some point `config.cache' contains results you don't want to keep, you
|
|
||||||
may remove or edit it.
|
|
||||||
|
|
||||||
The file `configure.ac' (or `configure.in') is used to create
|
|
||||||
`configure' by a program called `autoconf'. You only need
|
|
||||||
`configure.ac' if you want to change it or regenerate `configure' using
|
|
||||||
a newer version of `autoconf'.
|
|
||||||
|
|
||||||
The simplest way to compile this package is:
|
|
||||||
|
|
||||||
1. `cd' to the directory containing the package's source code and type
|
|
||||||
`./configure' to configure the package for your system. If you're
|
|
||||||
using `csh' on an old version of System V, you might need to type
|
|
||||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
|
||||||
`configure' itself.
|
|
||||||
|
|
||||||
Running `configure' takes awhile. While running, it prints some
|
|
||||||
messages telling which features it is checking for.
|
|
||||||
|
|
||||||
2. Type `make' to compile the package.
|
|
||||||
|
|
||||||
3. Optionally, type `make check' to run any self-tests that come with
|
|
||||||
the package.
|
|
||||||
|
|
||||||
4. Type `make install' to install the programs and any data files and
|
|
||||||
documentation.
|
|
||||||
|
|
||||||
5. You can remove the program binaries and object files from the
|
|
||||||
source code directory by typing `make clean'. To also remove the
|
|
||||||
files that `configure' created (so you can compile the package for
|
|
||||||
a different kind of computer), type `make distclean'. There is
|
|
||||||
also a `make maintainer-clean' target, but that is intended mainly
|
|
||||||
for the package's developers. If you use it, you may have to get
|
|
||||||
all sorts of other programs in order to regenerate files that came
|
|
||||||
with the distribution.
|
|
||||||
|
|
||||||
Compilers and Options
|
|
||||||
=====================
|
|
||||||
|
|
||||||
Some systems require unusual options for compilation or linking that
|
|
||||||
the `configure' script does not know about. Run `./configure --help'
|
|
||||||
for details on some of the pertinent environment variables.
|
|
||||||
|
|
||||||
You can give `configure' initial values for configuration parameters
|
|
||||||
by setting variables in the command line or in the environment. Here
|
|
||||||
is an example:
|
|
||||||
|
|
||||||
./configure CC=c89 CFLAGS=-O2 LIBS=-lposix
|
|
||||||
|
|
||||||
*Note Defining Variables::, for more details.
|
|
||||||
|
|
||||||
Compiling For Multiple Architectures
|
|
||||||
====================================
|
|
||||||
|
|
||||||
You can compile the package for more than one kind of computer at the
|
|
||||||
same time, by placing the object files for each architecture in their
|
|
||||||
own directory. To do this, you must use a version of `make' that
|
|
||||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
|
||||||
directory where you want the object files and executables to go and run
|
|
||||||
the `configure' script. `configure' automatically checks for the
|
|
||||||
source code in the directory that `configure' is in and in `..'.
|
|
||||||
|
|
||||||
If you have to use a `make' that does not support the `VPATH'
|
|
||||||
variable, you have to compile the package for one architecture at a
|
|
||||||
time in the source code directory. After you have installed the
|
|
||||||
package for one architecture, use `make distclean' before reconfiguring
|
|
||||||
for another architecture.
|
|
||||||
|
|
||||||
Installation Names
|
|
||||||
==================
|
|
||||||
|
|
||||||
By default, `make install' will install the package's files in
|
|
||||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
|
||||||
installation prefix other than `/usr/local' by giving `configure' the
|
|
||||||
option `--prefix=PATH'.
|
|
||||||
|
|
||||||
You can specify separate installation prefixes for
|
|
||||||
architecture-specific files and architecture-independent files. If you
|
|
||||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
|
||||||
PATH as the prefix for installing programs and libraries.
|
|
||||||
Documentation and other data files will still use the regular prefix.
|
|
||||||
|
|
||||||
In addition, if you use an unusual directory layout you can give
|
|
||||||
options like `--bindir=PATH' to specify different values for particular
|
|
||||||
kinds of files. Run `configure --help' for a list of the directories
|
|
||||||
you can set and what kinds of files go in them.
|
|
||||||
|
|
||||||
If the package supports it, you can cause programs to be installed
|
|
||||||
with an extra prefix or suffix on their names by giving `configure' the
|
|
||||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
|
||||||
|
|
||||||
Optional Features
|
|
||||||
=================
|
|
||||||
|
|
||||||
Some packages pay attention to `--enable-FEATURE' options to
|
|
||||||
`configure', where FEATURE indicates an optional part of the package.
|
|
||||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
|
||||||
is something like `gnu-as' or `x' (for the X Window System). The
|
|
||||||
`README' should mention any `--enable-' and `--with-' options that the
|
|
||||||
package recognizes.
|
|
||||||
|
|
||||||
For packages that use the X Window System, `configure' can usually
|
|
||||||
find the X include and library files automatically, but if it doesn't,
|
|
||||||
you can use the `configure' options `--x-includes=DIR' and
|
|
||||||
`--x-libraries=DIR' to specify their locations.
|
|
||||||
|
|
||||||
Specifying the System Type
|
|
||||||
==========================
|
|
||||||
|
|
||||||
There may be some features `configure' cannot figure out
|
|
||||||
automatically, but needs to determine by the type of machine the package
|
|
||||||
will run on. Usually, assuming the package is built to be run on the
|
|
||||||
_same_ architectures, `configure' can figure that out, but if it prints
|
|
||||||
a message saying it cannot guess the machine type, give it the
|
|
||||||
`--build=TYPE' option. TYPE can either be a short name for the system
|
|
||||||
type, such as `sun4', or a canonical name which has the form:
|
|
||||||
|
|
||||||
CPU-COMPANY-SYSTEM
|
|
||||||
|
|
||||||
where SYSTEM can have one of these forms:
|
|
||||||
|
|
||||||
OS KERNEL-OS
|
|
||||||
|
|
||||||
See the file `config.sub' for the possible values of each field. If
|
|
||||||
`config.sub' isn't included in this package, then this package doesn't
|
|
||||||
need to know the machine type.
|
|
||||||
|
|
||||||
If you are _building_ compiler tools for cross-compiling, you should
|
|
||||||
use the `--target=TYPE' option to select the type of system they will
|
|
||||||
produce code for.
|
|
||||||
|
|
||||||
If you want to _use_ a cross compiler, that generates code for a
|
|
||||||
platform different from the build platform, you should specify the
|
|
||||||
"host" platform (i.e., that on which the generated programs will
|
|
||||||
eventually be run) with `--host=TYPE'.
|
|
||||||
|
|
||||||
Sharing Defaults
|
|
||||||
================
|
|
||||||
|
|
||||||
If you want to set default values for `configure' scripts to share,
|
|
||||||
you can create a site shell script called `config.site' that gives
|
|
||||||
default values for variables like `CC', `cache_file', and `prefix'.
|
|
||||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
|
||||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
|
||||||
`CONFIG_SITE' environment variable to the location of the site script.
|
|
||||||
A warning: not all `configure' scripts look for a site script.
|
|
||||||
|
|
||||||
Defining Variables
|
|
||||||
==================
|
|
||||||
|
|
||||||
Variables not defined in a site shell script can be set in the
|
|
||||||
environment passed to `configure'. However, some packages may run
|
|
||||||
configure again during the build, and the customized values of these
|
|
||||||
variables may be lost. In order to avoid this problem, you should set
|
|
||||||
them in the `configure' command line, using `VAR=value'. For example:
|
|
||||||
|
|
||||||
./configure CC=/usr/local2/bin/gcc
|
|
||||||
|
|
||||||
will cause the specified gcc to be used as the C compiler (unless it is
|
|
||||||
overridden in the site shell script).
|
|
||||||
|
|
||||||
`configure' Invocation
|
|
||||||
======================
|
|
||||||
|
|
||||||
`configure' recognizes the following options to control how it
|
|
||||||
operates.
|
|
||||||
|
|
||||||
`--help'
|
|
||||||
`-h'
|
|
||||||
Print a summary of the options to `configure', and exit.
|
|
||||||
|
|
||||||
`--version'
|
|
||||||
`-V'
|
|
||||||
Print the version of Autoconf used to generate the `configure'
|
|
||||||
script, and exit.
|
|
||||||
|
|
||||||
`--cache-file=FILE'
|
|
||||||
Enable the cache: use and save the results of the tests in FILE,
|
|
||||||
traditionally `config.cache'. FILE defaults to `/dev/null' to
|
|
||||||
disable caching.
|
|
||||||
|
|
||||||
`--config-cache'
|
|
||||||
`-C'
|
|
||||||
Alias for `--cache-file=config.cache'.
|
|
||||||
|
|
||||||
`--quiet'
|
|
||||||
`--silent'
|
|
||||||
`-q'
|
|
||||||
Do not print messages saying which checks are being made. To
|
|
||||||
suppress all normal output, redirect it to `/dev/null' (any error
|
|
||||||
messages will still be shown).
|
|
||||||
|
|
||||||
`--srcdir=DIR'
|
|
||||||
Look for the package's source code in directory DIR. Usually
|
|
||||||
`configure' can determine that directory automatically.
|
|
||||||
|
|
||||||
`configure' also accepts some other, not widely useful, options. Run
|
|
||||||
`configure --help' for more details.
|
|
||||||
|
|
|
@ -51,30 +51,29 @@ pkgconfig_DATA = protobuf.pc protobuf-lite.pc
|
||||||
csharp_EXTRA_DIST= \
|
csharp_EXTRA_DIST= \
|
||||||
csharp/.gitignore \
|
csharp/.gitignore \
|
||||||
csharp/CHANGES.txt \
|
csharp/CHANGES.txt \
|
||||||
|
csharp/Google.Protobuf.Tools.nuspec \
|
||||||
csharp/README.md \
|
csharp/README.md \
|
||||||
csharp/build_packages.bat \
|
csharp/build_packages.bat \
|
||||||
|
csharp/build_tools.sh \
|
||||||
csharp/buildall.sh \
|
csharp/buildall.sh \
|
||||||
csharp/generate_protos.sh \
|
csharp/generate_protos.sh \
|
||||||
|
csharp/global.json \
|
||||||
csharp/keys/Google.Protobuf.public.snk \
|
csharp/keys/Google.Protobuf.public.snk \
|
||||||
|
csharp/keys/Google.Protobuf.snk \
|
||||||
csharp/keys/README.md \
|
csharp/keys/README.md \
|
||||||
|
csharp/protos/unittest_custom_options_proto3.proto \
|
||||||
csharp/protos/unittest_issues.proto \
|
csharp/protos/unittest_issues.proto \
|
||||||
csharp/src/AddressBook/AddPerson.cs \
|
csharp/src/AddressBook/AddPerson.cs \
|
||||||
csharp/src/AddressBook/AddressBook.csproj \
|
|
||||||
csharp/src/AddressBook/Addressbook.cs \
|
csharp/src/AddressBook/Addressbook.cs \
|
||||||
|
csharp/src/AddressBook/AddressBook.csproj \
|
||||||
csharp/src/AddressBook/ListPeople.cs \
|
csharp/src/AddressBook/ListPeople.cs \
|
||||||
csharp/src/AddressBook/Program.cs \
|
csharp/src/AddressBook/Program.cs \
|
||||||
csharp/src/AddressBook/Properties/AssemblyInfo.cs \
|
|
||||||
csharp/src/AddressBook/SampleUsage.cs \
|
csharp/src/AddressBook/SampleUsage.cs \
|
||||||
csharp/src/AddressBook/app.config \
|
|
||||||
csharp/src/Google.Protobuf.Conformance/App.config \
|
|
||||||
csharp/src/Google.Protobuf.Conformance/Conformance.cs \
|
csharp/src/Google.Protobuf.Conformance/Conformance.cs \
|
||||||
csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj \
|
csharp/src/Google.Protobuf.Conformance/Google.Protobuf.Conformance.csproj \
|
||||||
csharp/src/Google.Protobuf.Conformance/Program.cs \
|
csharp/src/Google.Protobuf.Conformance/Program.cs \
|
||||||
csharp/src/Google.Protobuf.Conformance/Properties/AssemblyInfo.cs \
|
|
||||||
csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj \
|
csharp/src/Google.Protobuf.JsonDump/Google.Protobuf.JsonDump.csproj \
|
||||||
csharp/src/Google.Protobuf.JsonDump/Program.cs \
|
csharp/src/Google.Protobuf.JsonDump/Program.cs \
|
||||||
csharp/src/Google.Protobuf.JsonDump/Properties/AssemblyInfo.cs \
|
|
||||||
csharp/src/Google.Protobuf.JsonDump/app.config \
|
|
||||||
csharp/src/Google.Protobuf.Test/ByteStringTest.cs \
|
csharp/src/Google.Protobuf.Test/ByteStringTest.cs \
|
||||||
csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs \
|
csharp/src/Google.Protobuf.Test/CodedInputStreamExtensions.cs \
|
||||||
csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs \
|
csharp/src/Google.Protobuf.Test/CodedInputStreamTest.cs \
|
||||||
|
@ -82,6 +81,7 @@ csharp_EXTRA_DIST= \
|
||||||
csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs \
|
csharp/src/Google.Protobuf.Test/Collections/MapFieldTest.cs \
|
||||||
csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs \
|
csharp/src/Google.Protobuf.Test/Collections/RepeatedFieldTest.cs \
|
||||||
csharp/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs \
|
csharp/src/Google.Protobuf.Test/Compatibility/PropertyInfoExtensionsTest.cs \
|
||||||
|
csharp/src/Google.Protobuf.Test/Compatibility/StreamExtensionsTest.cs \
|
||||||
csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs \
|
csharp/src/Google.Protobuf.Test/Compatibility/TypeExtensionsTest.cs \
|
||||||
csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs \
|
csharp/src/Google.Protobuf.Test/DeprecatedMemberTest.cs \
|
||||||
csharp/src/Google.Protobuf.Test/EqualityTester.cs \
|
csharp/src/Google.Protobuf.Test/EqualityTester.cs \
|
||||||
|
@ -92,15 +92,18 @@ csharp_EXTRA_DIST= \
|
||||||
csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs \
|
csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs \
|
||||||
csharp/src/Google.Protobuf.Test/JsonParserTest.cs \
|
csharp/src/Google.Protobuf.Test/JsonParserTest.cs \
|
||||||
csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs \
|
csharp/src/Google.Protobuf.Test/JsonTokenizerTest.cs \
|
||||||
csharp/src/Google.Protobuf.Test/Properties/AppManifest.xml \
|
csharp/src/Google.Protobuf.Test/Program.cs \
|
||||||
csharp/src/Google.Protobuf.Test/Properties/AssemblyInfo.cs \
|
csharp/src/Google.Protobuf.Test/Reflection/CustomOptionsTest.cs \
|
||||||
csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs \
|
csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs \
|
||||||
csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs \
|
csharp/src/Google.Protobuf.Test/Reflection/FieldAccessTest.cs \
|
||||||
csharp/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs \
|
csharp/src/Google.Protobuf.Test/Reflection/TypeRegistryTest.cs \
|
||||||
csharp/src/Google.Protobuf.Test/SampleEnum.cs \
|
csharp/src/Google.Protobuf.Test/SampleEnum.cs \
|
||||||
csharp/src/Google.Protobuf.Test/SampleMessages.cs \
|
csharp/src/Google.Protobuf.Test/SampleMessages.cs \
|
||||||
csharp/src/Google.Protobuf.Test/TestCornerCases.cs \
|
csharp/src/Google.Protobuf.Test/TestCornerCases.cs \
|
||||||
|
csharp/src/Google.Protobuf.Test/TestProtos/ForeignMessagePartial.cs \
|
||||||
csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs \
|
csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs \
|
||||||
|
csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs \
|
||||||
|
csharp/src/Google.Protobuf.Test/TestProtos/UnittestCustomOptionsProto3.cs \
|
||||||
csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs \
|
csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs \
|
||||||
csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs \
|
csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs \
|
||||||
csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs \
|
csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs \
|
||||||
|
@ -108,9 +111,9 @@ csharp_EXTRA_DIST= \
|
||||||
csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs \
|
csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs \
|
||||||
csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs \
|
csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs \
|
||||||
csharp/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs \
|
csharp/src/Google.Protobuf.Test/WellKnownTypes/DurationTest.cs \
|
||||||
|
csharp/src/Google.Protobuf.Test/WellKnownTypes/FieldMaskTest.cs \
|
||||||
csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs \
|
csharp/src/Google.Protobuf.Test/WellKnownTypes/TimestampTest.cs \
|
||||||
csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs \
|
csharp/src/Google.Protobuf.Test/WellKnownTypes/WrappersTest.cs \
|
||||||
csharp/src/Google.Protobuf.Test/packages.config \
|
|
||||||
csharp/src/Google.Protobuf.sln \
|
csharp/src/Google.Protobuf.sln \
|
||||||
csharp/src/Google.Protobuf/ByteArray.cs \
|
csharp/src/Google.Protobuf/ByteArray.cs \
|
||||||
csharp/src/Google.Protobuf/ByteString.cs \
|
csharp/src/Google.Protobuf/ByteString.cs \
|
||||||
|
@ -121,11 +124,12 @@ csharp_EXTRA_DIST= \
|
||||||
csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs \
|
csharp/src/Google.Protobuf/Collections/ReadOnlyDictionary.cs \
|
||||||
csharp/src/Google.Protobuf/Collections/RepeatedField.cs \
|
csharp/src/Google.Protobuf/Collections/RepeatedField.cs \
|
||||||
csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs \
|
csharp/src/Google.Protobuf/Compatibility/PropertyInfoExtensions.cs \
|
||||||
|
csharp/src/Google.Protobuf/Compatibility/StreamExtensions.cs \
|
||||||
csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs \
|
csharp/src/Google.Protobuf/Compatibility/TypeExtensions.cs \
|
||||||
csharp/src/Google.Protobuf/FieldCodec.cs \
|
csharp/src/Google.Protobuf/FieldCodec.cs \
|
||||||
csharp/src/Google.Protobuf/FrameworkPortability.cs \
|
csharp/src/Google.Protobuf/FrameworkPortability.cs \
|
||||||
csharp/src/Google.Protobuf/Google.Protobuf.csproj \
|
csharp/src/Google.Protobuf/Google.Protobuf.csproj \
|
||||||
csharp/src/Google.Protobuf/Google.Protobuf.nuspec \
|
csharp/src/Google.Protobuf/ICustomDiagnosticMessage.cs \
|
||||||
csharp/src/Google.Protobuf/IDeepCloneable.cs \
|
csharp/src/Google.Protobuf/IDeepCloneable.cs \
|
||||||
csharp/src/Google.Protobuf/IMessage.cs \
|
csharp/src/Google.Protobuf/IMessage.cs \
|
||||||
csharp/src/Google.Protobuf/InvalidJsonException.cs \
|
csharp/src/Google.Protobuf/InvalidJsonException.cs \
|
||||||
|
@ -139,6 +143,7 @@ csharp_EXTRA_DIST= \
|
||||||
csharp/src/Google.Protobuf/MessageParser.cs \
|
csharp/src/Google.Protobuf/MessageParser.cs \
|
||||||
csharp/src/Google.Protobuf/ProtoPreconditions.cs \
|
csharp/src/Google.Protobuf/ProtoPreconditions.cs \
|
||||||
csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs \
|
csharp/src/Google.Protobuf/Properties/AssemblyInfo.cs \
|
||||||
|
csharp/src/Google.Protobuf/Reflection/CustomOptions.cs \
|
||||||
csharp/src/Google.Protobuf/Reflection/Descriptor.cs \
|
csharp/src/Google.Protobuf/Reflection/Descriptor.cs \
|
||||||
csharp/src/Google.Protobuf/Reflection/DescriptorBase.cs \
|
csharp/src/Google.Protobuf/Reflection/DescriptorBase.cs \
|
||||||
csharp/src/Google.Protobuf/Reflection/DescriptorPool.cs \
|
csharp/src/Google.Protobuf/Reflection/DescriptorPool.cs \
|
||||||
|
@ -173,6 +178,7 @@ csharp_EXTRA_DIST= \
|
||||||
csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs \
|
csharp/src/Google.Protobuf/WellKnownTypes/DurationPartial.cs \
|
||||||
csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs \
|
csharp/src/Google.Protobuf/WellKnownTypes/Empty.cs \
|
||||||
csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs \
|
csharp/src/Google.Protobuf/WellKnownTypes/FieldMask.cs \
|
||||||
|
csharp/src/Google.Protobuf/WellKnownTypes/FieldMaskPartial.cs \
|
||||||
csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs \
|
csharp/src/Google.Protobuf/WellKnownTypes/SourceContext.cs \
|
||||||
csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs \
|
csharp/src/Google.Protobuf/WellKnownTypes/Struct.cs \
|
||||||
csharp/src/Google.Protobuf/WellKnownTypes/TimeExtensions.cs \
|
csharp/src/Google.Protobuf/WellKnownTypes/TimeExtensions.cs \
|
||||||
|
@ -182,9 +188,7 @@ csharp_EXTRA_DIST= \
|
||||||
csharp/src/Google.Protobuf/WellKnownTypes/ValuePartial.cs \
|
csharp/src/Google.Protobuf/WellKnownTypes/ValuePartial.cs \
|
||||||
csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs \
|
csharp/src/Google.Protobuf/WellKnownTypes/Wrappers.cs \
|
||||||
csharp/src/Google.Protobuf/WellKnownTypes/WrappersPartial.cs \
|
csharp/src/Google.Protobuf/WellKnownTypes/WrappersPartial.cs \
|
||||||
csharp/src/Google.Protobuf/WireFormat.cs \
|
csharp/src/Google.Protobuf/WireFormat.cs
|
||||||
csharp/src/Google.Protobuf/packages.config \
|
|
||||||
csharp/src/packages/repositories.config
|
|
||||||
|
|
||||||
java_EXTRA_DIST= \
|
java_EXTRA_DIST= \
|
||||||
java/README.md \
|
java/README.md \
|
||||||
|
@ -206,14 +210,17 @@ java_EXTRA_DIST=
|
||||||
java/core/src/main/java/com/google/protobuf/Descriptors.java \
|
java/core/src/main/java/com/google/protobuf/Descriptors.java \
|
||||||
java/core/src/main/java/com/google/protobuf/DoubleArrayList.java \
|
java/core/src/main/java/com/google/protobuf/DoubleArrayList.java \
|
||||||
java/core/src/main/java/com/google/protobuf/DynamicMessage.java \
|
java/core/src/main/java/com/google/protobuf/DynamicMessage.java \
|
||||||
|
java/core/src/main/java/com/google/protobuf/ExperimentalApi.java \
|
||||||
java/core/src/main/java/com/google/protobuf/Extension.java \
|
java/core/src/main/java/com/google/protobuf/Extension.java \
|
||||||
java/core/src/main/java/com/google/protobuf/ExtensionLite.java \
|
java/core/src/main/java/com/google/protobuf/ExtensionLite.java \
|
||||||
java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java \
|
java/core/src/main/java/com/google/protobuf/ExtensionRegistry.java \
|
||||||
|
java/core/src/main/java/com/google/protobuf/ExtensionRegistryFactory.java \
|
||||||
java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java \
|
java/core/src/main/java/com/google/protobuf/ExtensionRegistryLite.java \
|
||||||
java/core/src/main/java/com/google/protobuf/FieldSet.java \
|
java/core/src/main/java/com/google/protobuf/FieldSet.java \
|
||||||
java/core/src/main/java/com/google/protobuf/FloatArrayList.java \
|
java/core/src/main/java/com/google/protobuf/FloatArrayList.java \
|
||||||
java/core/src/main/java/com/google/protobuf/GeneratedMessage.java \
|
java/core/src/main/java/com/google/protobuf/GeneratedMessage.java \
|
||||||
java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java \
|
java/core/src/main/java/com/google/protobuf/GeneratedMessageLite.java \
|
||||||
|
java/core/src/main/java/com/google/protobuf/GeneratedMessageV3.java \
|
||||||
java/core/src/main/java/com/google/protobuf/IntArrayList.java \
|
java/core/src/main/java/com/google/protobuf/IntArrayList.java \
|
||||||
java/core/src/main/java/com/google/protobuf/Internal.java \
|
java/core/src/main/java/com/google/protobuf/Internal.java \
|
||||||
java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java \
|
java/core/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java \
|
||||||
|
@ -235,10 +242,12 @@ java_EXTRA_DIST=
|
||||||
java/core/src/main/java/com/google/protobuf/MutabilityOracle.java \
|
java/core/src/main/java/com/google/protobuf/MutabilityOracle.java \
|
||||||
java/core/src/main/java/com/google/protobuf/NioByteString.java \
|
java/core/src/main/java/com/google/protobuf/NioByteString.java \
|
||||||
java/core/src/main/java/com/google/protobuf/Parser.java \
|
java/core/src/main/java/com/google/protobuf/Parser.java \
|
||||||
|
java/core/src/main/java/com/google/protobuf/PrimitiveNonBoxingCollection.java \
|
||||||
java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java \
|
java/core/src/main/java/com/google/protobuf/ProtobufArrayList.java \
|
||||||
java/core/src/main/java/com/google/protobuf/ProtocolMessageEnum.java \
|
java/core/src/main/java/com/google/protobuf/ProtocolMessageEnum.java \
|
||||||
java/core/src/main/java/com/google/protobuf/ProtocolStringList.java \
|
java/core/src/main/java/com/google/protobuf/ProtocolStringList.java \
|
||||||
java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java \
|
java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java \
|
||||||
|
java/core/src/main/java/com/google/protobuf/RepeatedFieldBuilderV3.java \
|
||||||
java/core/src/main/java/com/google/protobuf/RopeByteString.java \
|
java/core/src/main/java/com/google/protobuf/RopeByteString.java \
|
||||||
java/core/src/main/java/com/google/protobuf/RpcCallback.java \
|
java/core/src/main/java/com/google/protobuf/RpcCallback.java \
|
||||||
java/core/src/main/java/com/google/protobuf/RpcChannel.java \
|
java/core/src/main/java/com/google/protobuf/RpcChannel.java \
|
||||||
|
@ -247,6 +256,7 @@ java_EXTRA_DIST=
|
||||||
java/core/src/main/java/com/google/protobuf/Service.java \
|
java/core/src/main/java/com/google/protobuf/Service.java \
|
||||||
java/core/src/main/java/com/google/protobuf/ServiceException.java \
|
java/core/src/main/java/com/google/protobuf/ServiceException.java \
|
||||||
java/core/src/main/java/com/google/protobuf/SingleFieldBuilder.java \
|
java/core/src/main/java/com/google/protobuf/SingleFieldBuilder.java \
|
||||||
|
java/core/src/main/java/com/google/protobuf/SingleFieldBuilderV3.java \
|
||||||
java/core/src/main/java/com/google/protobuf/SmallSortedMap.java \
|
java/core/src/main/java/com/google/protobuf/SmallSortedMap.java \
|
||||||
java/core/src/main/java/com/google/protobuf/TextFormat.java \
|
java/core/src/main/java/com/google/protobuf/TextFormat.java \
|
||||||
java/core/src/main/java/com/google/protobuf/TextFormatEscaper.java \
|
java/core/src/main/java/com/google/protobuf/TextFormatEscaper.java \
|
||||||
|
@ -257,6 +267,7 @@ java_EXTRA_DIST=
|
||||||
java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java \
|
java/core/src/main/java/com/google/protobuf/UnknownFieldSetLite.java \
|
||||||
java/core/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java \
|
java/core/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java \
|
||||||
java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java \
|
java/core/src/main/java/com/google/protobuf/UnsafeByteOperations.java \
|
||||||
|
java/core/src/main/java/com/google/protobuf/UnsafeUtil.java \
|
||||||
java/core/src/main/java/com/google/protobuf/Utf8.java \
|
java/core/src/main/java/com/google/protobuf/Utf8.java \
|
||||||
java/core/src/main/java/com/google/protobuf/WireFormat.java \
|
java/core/src/main/java/com/google/protobuf/WireFormat.java \
|
||||||
java/core/src/test/java/com/google/protobuf/AbstractMessageTest.java \
|
java/core/src/test/java/com/google/protobuf/AbstractMessageTest.java \
|
||||||
|
@ -273,6 +284,7 @@ java_EXTRA_DIST=
|
||||||
java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java \
|
java/core/src/test/java/com/google/protobuf/DoubleArrayListTest.java \
|
||||||
java/core/src/test/java/com/google/protobuf/DynamicMessageTest.java \
|
java/core/src/test/java/com/google/protobuf/DynamicMessageTest.java \
|
||||||
java/core/src/test/java/com/google/protobuf/EnumTest.java \
|
java/core/src/test/java/com/google/protobuf/EnumTest.java \
|
||||||
|
java/core/src/test/java/com/google/protobuf/ExtensionRegistryFactoryTest.java \
|
||||||
java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java \
|
java/core/src/test/java/com/google/protobuf/FieldPresenceTest.java \
|
||||||
java/core/src/test/java/com/google/protobuf/FloatArrayListTest.java \
|
java/core/src/test/java/com/google/protobuf/FloatArrayListTest.java \
|
||||||
java/core/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java \
|
java/core/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java \
|
||||||
|
@ -295,16 +307,18 @@ java_EXTRA_DIST=
|
||||||
java/core/src/test/java/com/google/protobuf/MessageTest.java \
|
java/core/src/test/java/com/google/protobuf/MessageTest.java \
|
||||||
java/core/src/test/java/com/google/protobuf/NestedBuildersTest.java \
|
java/core/src/test/java/com/google/protobuf/NestedBuildersTest.java \
|
||||||
java/core/src/test/java/com/google/protobuf/NioByteStringTest.java \
|
java/core/src/test/java/com/google/protobuf/NioByteStringTest.java \
|
||||||
|
java/core/src/test/java/com/google/protobuf/ParseExceptionsTest.java \
|
||||||
java/core/src/test/java/com/google/protobuf/ParserTest.java \
|
java/core/src/test/java/com/google/protobuf/ParserTest.java \
|
||||||
java/core/src/test/java/com/google/protobuf/ProtobufArrayListTest.java \
|
java/core/src/test/java/com/google/protobuf/ProtobufArrayListTest.java \
|
||||||
java/core/src/test/java/com/google/protobuf/RepeatedFieldBuilderTest.java \
|
java/core/src/test/java/com/google/protobuf/RepeatedFieldBuilderV3Test.java \
|
||||||
java/core/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java \
|
java/core/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java \
|
||||||
java/core/src/test/java/com/google/protobuf/RopeByteStringTest.java \
|
java/core/src/test/java/com/google/protobuf/RopeByteStringTest.java \
|
||||||
java/core/src/test/java/com/google/protobuf/ServiceTest.java \
|
java/core/src/test/java/com/google/protobuf/ServiceTest.java \
|
||||||
java/core/src/test/java/com/google/protobuf/SingleFieldBuilderTest.java \
|
java/core/src/test/java/com/google/protobuf/SingleFieldBuilderV3Test.java \
|
||||||
java/core/src/test/java/com/google/protobuf/SmallSortedMapTest.java \
|
java/core/src/test/java/com/google/protobuf/SmallSortedMapTest.java \
|
||||||
java/core/src/test/java/com/google/protobuf/TestBadIdentifiers.java \
|
java/core/src/test/java/com/google/protobuf/TestBadIdentifiers.java \
|
||||||
java/core/src/test/java/com/google/protobuf/TestUtil.java \
|
java/core/src/test/java/com/google/protobuf/TestUtil.java \
|
||||||
|
java/core/src/test/java/com/google/protobuf/TestUtilLite.java \
|
||||||
java/core/src/test/java/com/google/protobuf/TextFormatParseInfoTreeTest.java \
|
java/core/src/test/java/com/google/protobuf/TextFormatParseInfoTreeTest.java \
|
||||||
java/core/src/test/java/com/google/protobuf/TextFormatParseLocationTest.java \
|
java/core/src/test/java/com/google/protobuf/TextFormatParseLocationTest.java \
|
||||||
java/core/src/test/java/com/google/protobuf/TextFormatTest.java \
|
java/core/src/test/java/com/google/protobuf/TextFormatTest.java \
|
||||||
|
@ -336,13 +350,17 @@ java_EXTRA_DIST=
|
||||||
java/core/src/test/proto/com/google/protobuf/test_check_utf8_size.proto \
|
java/core/src/test/proto/com/google/protobuf/test_check_utf8_size.proto \
|
||||||
java/core/src/test/proto/com/google/protobuf/test_custom_options.proto \
|
java/core/src/test/proto/com/google/protobuf/test_custom_options.proto \
|
||||||
java/core/src/test/proto/com/google/protobuf/test_extra_interfaces.proto \
|
java/core/src/test/proto/com/google/protobuf/test_extra_interfaces.proto \
|
||||||
|
java/lite/generate-sources-build.xml \
|
||||||
|
java/lite/generate-test-sources-build.xml \
|
||||||
java/lite/pom.xml \
|
java/lite/pom.xml \
|
||||||
java/pom.xml \
|
java/pom.xml \
|
||||||
java/util/pom.xml \
|
java/util/pom.xml \
|
||||||
|
java/util/src/main/java/com/google/protobuf/util/Durations.java \
|
||||||
java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java \
|
java/util/src/main/java/com/google/protobuf/util/FieldMaskTree.java \
|
||||||
java/util/src/main/java/com/google/protobuf/util/FieldMaskUtil.java \
|
java/util/src/main/java/com/google/protobuf/util/FieldMaskUtil.java \
|
||||||
java/util/src/main/java/com/google/protobuf/util/JsonFormat.java \
|
java/util/src/main/java/com/google/protobuf/util/JsonFormat.java \
|
||||||
java/util/src/main/java/com/google/protobuf/util/TimeUtil.java \
|
java/util/src/main/java/com/google/protobuf/util/TimeUtil.java \
|
||||||
|
java/util/src/main/java/com/google/protobuf/util/Timestamps.java \
|
||||||
java/util/src/test/java/com/google/protobuf/util/FieldMaskTreeTest.java \
|
java/util/src/test/java/com/google/protobuf/util/FieldMaskTreeTest.java \
|
||||||
java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java \
|
java/util/src/test/java/com/google/protobuf/util/FieldMaskUtilTest.java \
|
||||||
java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java \
|
java/util/src/test/java/com/google/protobuf/util/JsonFormatTest.java \
|
||||||
|
@ -461,8 +479,6 @@ objectivec_EXTRA_DIST= \
|
||||||
objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj \
|
objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj \
|
||||||
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata \
|
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/contents.xcworkspacedata \
|
||||||
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings \
|
objectivec/ProtocolBuffers_iOS.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings \
|
||||||
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/FFE465CA-0E74-40E8-9F09-500B66B7DCB2.plist \
|
|
||||||
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcbaselines/8BBEA4A5147C727100C4ADB7.xcbaseline/Info.plist \
|
|
||||||
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \
|
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \
|
||||||
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \
|
objectivec/ProtocolBuffers_iOS.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \
|
||||||
objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj \
|
objectivec/ProtocolBuffers_OSX.xcodeproj/project.pbxproj \
|
||||||
|
@ -471,6 +487,33 @@ objectivec_EXTRA_DIST= \
|
||||||
objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \
|
objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/PerformanceTests.xcscheme \
|
||||||
objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \
|
objectivec/ProtocolBuffers_OSX.xcodeproj/xcshareddata/xcschemes/ProtocolBuffers.xcscheme \
|
||||||
objectivec/README.md \
|
objectivec/README.md \
|
||||||
|
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.pbxproj \
|
||||||
|
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata \
|
||||||
|
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/OSXCocoaPodsTester.xcscheme \
|
||||||
|
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.h \
|
||||||
|
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/AppDelegate.m \
|
||||||
|
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json \
|
||||||
|
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Base.lproj/MainMenu.xib \
|
||||||
|
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/Info.plist \
|
||||||
|
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/OSXCocoaPodsTester/main.m \
|
||||||
|
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-framework \
|
||||||
|
objectivec/Tests/CocoaPods/OSXCocoaPodsTester/Podfile-static \
|
||||||
|
objectivec/Tests/CocoaPods/README.md \
|
||||||
|
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-framework \
|
||||||
|
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/Podfile-static \
|
||||||
|
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.pbxproj \
|
||||||
|
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/project.xcworkspace/contents.xcworkspacedata \
|
||||||
|
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester.xcodeproj/xcshareddata/xcschemes/iOSCocoaPodsTester.xcscheme \
|
||||||
|
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.h \
|
||||||
|
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/AppDelegate.m \
|
||||||
|
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Assets.xcassets/AppIcon.appiconset/Contents.json \
|
||||||
|
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/LaunchScreen.storyboard \
|
||||||
|
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Base.lproj/Main.storyboard \
|
||||||
|
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/Info.plist \
|
||||||
|
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.h \
|
||||||
|
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/ViewController.m \
|
||||||
|
objectivec/Tests/CocoaPods/iOSCocoaPodsTester/iOSCocoaPodsTester/main.m \
|
||||||
|
objectivec/Tests/CocoaPods/run_tests.sh \
|
||||||
objectivec/Tests/golden_message \
|
objectivec/Tests/golden_message \
|
||||||
objectivec/Tests/golden_packed_fields_message \
|
objectivec/Tests/golden_packed_fields_message \
|
||||||
objectivec/Tests/GPBARCUnittestProtos.m \
|
objectivec/Tests/GPBARCUnittestProtos.m \
|
||||||
|
@ -485,7 +528,9 @@ objectivec_EXTRA_DIST= \
|
||||||
objectivec/Tests/GPBDictionaryTests+String.m \
|
objectivec/Tests/GPBDictionaryTests+String.m \
|
||||||
objectivec/Tests/GPBDictionaryTests+UInt32.m \
|
objectivec/Tests/GPBDictionaryTests+UInt32.m \
|
||||||
objectivec/Tests/GPBDictionaryTests+UInt64.m \
|
objectivec/Tests/GPBDictionaryTests+UInt64.m \
|
||||||
|
objectivec/Tests/GPBDictionaryTests.m \
|
||||||
objectivec/Tests/GPBDictionaryTests.pddm \
|
objectivec/Tests/GPBDictionaryTests.pddm \
|
||||||
|
objectivec/Tests/GPBExtensionRegistryTest.m \
|
||||||
objectivec/Tests/GPBMessageTests+Merge.m \
|
objectivec/Tests/GPBMessageTests+Merge.m \
|
||||||
objectivec/Tests/GPBMessageTests+Runtime.m \
|
objectivec/Tests/GPBMessageTests+Runtime.m \
|
||||||
objectivec/Tests/GPBMessageTests+Serialization.m \
|
objectivec/Tests/GPBMessageTests+Serialization.m \
|
||||||
|
@ -496,6 +541,7 @@ objectivec_EXTRA_DIST= \
|
||||||
objectivec/Tests/GPBTestUtilities.h \
|
objectivec/Tests/GPBTestUtilities.h \
|
||||||
objectivec/Tests/GPBTestUtilities.m \
|
objectivec/Tests/GPBTestUtilities.m \
|
||||||
objectivec/Tests/GPBUnittestProtos.m \
|
objectivec/Tests/GPBUnittestProtos.m \
|
||||||
|
objectivec/Tests/GPBUnittestProtos2.m \
|
||||||
objectivec/Tests/GPBUnknownFieldSetTest.m \
|
objectivec/Tests/GPBUnknownFieldSetTest.m \
|
||||||
objectivec/Tests/GPBUtilitiesTests.m \
|
objectivec/Tests/GPBUtilitiesTests.m \
|
||||||
objectivec/Tests/GPBWellKnownTypesTest.m \
|
objectivec/Tests/GPBWellKnownTypesTest.m \
|
||||||
|
@ -517,6 +563,15 @@ objectivec_EXTRA_DIST= \
|
||||||
objectivec/Tests/text_format_map_unittest_data.txt \
|
objectivec/Tests/text_format_map_unittest_data.txt \
|
||||||
objectivec/Tests/text_format_unittest_data.txt \
|
objectivec/Tests/text_format_unittest_data.txt \
|
||||||
objectivec/Tests/unittest_cycle.proto \
|
objectivec/Tests/unittest_cycle.proto \
|
||||||
|
objectivec/Tests/unittest_deprecated.proto \
|
||||||
|
objectivec/Tests/unittest_deprecated_file.proto \
|
||||||
|
objectivec/Tests/unittest_extension_chain_a.proto \
|
||||||
|
objectivec/Tests/unittest_extension_chain_b.proto \
|
||||||
|
objectivec/Tests/unittest_extension_chain_c.proto \
|
||||||
|
objectivec/Tests/unittest_extension_chain_d.proto \
|
||||||
|
objectivec/Tests/unittest_extension_chain_e.proto \
|
||||||
|
objectivec/Tests/unittest_extension_chain_f.proto \
|
||||||
|
objectivec/Tests/unittest_extension_chain_g.proto \
|
||||||
objectivec/Tests/unittest_objc.proto \
|
objectivec/Tests/unittest_objc.proto \
|
||||||
objectivec/Tests/unittest_objc_startup.proto \
|
objectivec/Tests/unittest_objc_startup.proto \
|
||||||
objectivec/Tests/unittest_runtime_proto2.proto \
|
objectivec/Tests/unittest_runtime_proto2.proto \
|
||||||
|
@ -525,6 +580,112 @@ objectivec_EXTRA_DIST= \
|
||||||
objectivec/Tests/UnitTests-Info.plist \
|
objectivec/Tests/UnitTests-Info.plist \
|
||||||
Protobuf.podspec
|
Protobuf.podspec
|
||||||
|
|
||||||
|
php_EXTRA_DIST= \
|
||||||
|
php/ext/google/protobuf/utf8.h \
|
||||||
|
php/ext/google/protobuf/message.c \
|
||||||
|
php/ext/google/protobuf/utf8.c \
|
||||||
|
php/ext/google/protobuf/package.xml \
|
||||||
|
php/ext/google/protobuf/upb.h \
|
||||||
|
php/ext/google/protobuf/array.c \
|
||||||
|
php/ext/google/protobuf/encode_decode.c \
|
||||||
|
php/ext/google/protobuf/protobuf.h \
|
||||||
|
php/ext/google/protobuf/type_check.c \
|
||||||
|
php/ext/google/protobuf/def.c \
|
||||||
|
php/ext/google/protobuf/storage.c \
|
||||||
|
php/ext/google/protobuf/map.c \
|
||||||
|
php/ext/google/protobuf/config.m4 \
|
||||||
|
php/ext/google/protobuf/upb.c \
|
||||||
|
php/ext/google/protobuf/protobuf.c \
|
||||||
|
php/src/phpdoc.dist.xml \
|
||||||
|
php/src/Google/Protobuf/Internal/CodedInputStream.php \
|
||||||
|
php/src/Google/Protobuf/Internal/CodedOutputStream.php \
|
||||||
|
php/src/Google/Protobuf/Internal/DescriptorPool.php \
|
||||||
|
php/src/Google/Protobuf/Internal/DescriptorProto_ExtensionRange.php \
|
||||||
|
php/src/Google/Protobuf/Internal/DescriptorProto_ReservedRange.php \
|
||||||
|
php/src/Google/Protobuf/Internal/DescriptorProto.php \
|
||||||
|
php/src/Google/Protobuf/Internal/Descriptor.php \
|
||||||
|
php/src/Google/Protobuf/Internal/EnumBuilderContext.php \
|
||||||
|
php/src/Google/Protobuf/Internal/EnumDescriptor.php \
|
||||||
|
php/src/Google/Protobuf/Internal/EnumDescriptorProto.php \
|
||||||
|
php/src/Google/Protobuf/Internal/EnumOptions.php \
|
||||||
|
php/src/Google/Protobuf/Internal/EnumValueDescriptorProto.php \
|
||||||
|
php/src/Google/Protobuf/Internal/EnumValueDescriptor.php \
|
||||||
|
php/src/Google/Protobuf/Internal/EnumValueOptions.php \
|
||||||
|
php/src/Google/Protobuf/Internal/FieldDescriptorProto_Label.php \
|
||||||
|
php/src/Google/Protobuf/Internal/FieldDescriptorProto.php \
|
||||||
|
php/src/Google/Protobuf/Internal/FieldDescriptor.php \
|
||||||
|
php/src/Google/Protobuf/Internal/FieldDescriptorProto_Type.php \
|
||||||
|
php/src/Google/Protobuf/Internal/FieldOptions_CType.php \
|
||||||
|
php/src/Google/Protobuf/Internal/FieldOptions_JSType.php \
|
||||||
|
php/src/Google/Protobuf/Internal/FieldOptions.php \
|
||||||
|
php/src/Google/Protobuf/Internal/FileDescriptorProto.php \
|
||||||
|
php/src/Google/Protobuf/Internal/FileDescriptorSet.php \
|
||||||
|
php/src/Google/Protobuf/Internal/FileDescriptor.php \
|
||||||
|
php/src/Google/Protobuf/Internal/FileOptions_OptimizeMode.php \
|
||||||
|
php/src/Google/Protobuf/Internal/FileOptions.php \
|
||||||
|
php/src/Google/Protobuf/Internal/GeneratedCodeInfo_Annotation.php \
|
||||||
|
php/src/Google/Protobuf/Internal/GeneratedCodeInfo.php \
|
||||||
|
php/src/Google/Protobuf/Internal/GPBDecodeException.php \
|
||||||
|
php/src/Google/Protobuf/Internal/GPBJsonWire.php \
|
||||||
|
php/src/Google/Protobuf/Internal/GPBLabel.php \
|
||||||
|
php/src/Google/Protobuf/Internal/GPBType.php \
|
||||||
|
php/src/Google/Protobuf/Internal/GPBUtil.php \
|
||||||
|
php/src/Google/Protobuf/Internal/GPBWireType.php \
|
||||||
|
php/src/Google/Protobuf/Internal/GPBWire.php \
|
||||||
|
php/src/Google/Protobuf/Internal/MapEntry.php \
|
||||||
|
php/src/Google/Protobuf/Internal/MapFieldIter.php \
|
||||||
|
php/src/Google/Protobuf/Internal/MapField.php \
|
||||||
|
php/src/Google/Protobuf/Internal/MessageBuilderContext.php \
|
||||||
|
php/src/Google/Protobuf/Internal/MessageOptions.php \
|
||||||
|
php/src/Google/Protobuf/Internal/Message.php \
|
||||||
|
php/src/Google/Protobuf/Internal/MethodDescriptorProto.php \
|
||||||
|
php/src/Google/Protobuf/Internal/MethodOptions_IdempotencyLevel.php \
|
||||||
|
php/src/Google/Protobuf/Internal/MethodOptions.php \
|
||||||
|
php/src/Google/Protobuf/Internal/OneofDescriptorProto.php \
|
||||||
|
php/src/Google/Protobuf/Internal/OneofDescriptor.php \
|
||||||
|
php/src/Google/Protobuf/Internal/OneofField.php \
|
||||||
|
php/src/Google/Protobuf/Internal/OneofOptions.php \
|
||||||
|
php/src/Google/Protobuf/Internal/RawInputStream.php \
|
||||||
|
php/src/Google/Protobuf/Internal/RepeatedFieldIter.php \
|
||||||
|
php/src/Google/Protobuf/Internal/RepeatedField.php \
|
||||||
|
php/src/Google/Protobuf/Internal/ServiceDescriptorProto.php \
|
||||||
|
php/src/Google/Protobuf/Internal/ServiceOptions.php \
|
||||||
|
php/src/Google/Protobuf/Internal/SourceCodeInfo_Location.php \
|
||||||
|
php/src/Google/Protobuf/Internal/SourceCodeInfo.php \
|
||||||
|
php/src/Google/Protobuf/Internal/UninterpretedOption_NamePart.php \
|
||||||
|
php/src/Google/Protobuf/Internal/UninterpretedOption.php \
|
||||||
|
php/src/GPBMetadata/Google/Protobuf/Internal/Descriptor.php \
|
||||||
|
php/tests/array_test.php \
|
||||||
|
php/tests/autoload.php \
|
||||||
|
php/tests/compatibility_test.sh \
|
||||||
|
php/tests/encode_decode_test.php \
|
||||||
|
php/tests/gdb_test.sh \
|
||||||
|
php/tests/generated_class_test.php \
|
||||||
|
php/tests/generated_phpdoc_test.php \
|
||||||
|
php/tests/generated_service_test.php \
|
||||||
|
php/tests/map_field_test.php \
|
||||||
|
php/tests/memory_leak_test.php \
|
||||||
|
php/tests/php_implementation_test.php \
|
||||||
|
php/tests/proto/test_empty_php_namespace.proto \
|
||||||
|
php/tests/proto/test_import_descriptor_proto.proto \
|
||||||
|
php/tests/proto/test_include.proto \
|
||||||
|
php/tests/proto/test.proto \
|
||||||
|
php/tests/proto/test_no_namespace.proto \
|
||||||
|
php/tests/proto/test_php_namespace.proto \
|
||||||
|
php/tests/proto/test_prefix.proto \
|
||||||
|
php/tests/proto/test_service.proto \
|
||||||
|
php/tests/proto/test_service_namespace.proto \
|
||||||
|
php/tests/test.sh \
|
||||||
|
php/tests/test_base.php \
|
||||||
|
php/tests/test_util.php \
|
||||||
|
php/tests/well_known_test.php \
|
||||||
|
php/tests/undefined_test.php \
|
||||||
|
php/README.md \
|
||||||
|
php/composer.json \
|
||||||
|
php/generate_descriptor_protos.sh \
|
||||||
|
php/phpunit.xml \
|
||||||
|
composer.json
|
||||||
|
|
||||||
python_EXTRA_DIST= \
|
python_EXTRA_DIST= \
|
||||||
python/MANIFEST.in \
|
python/MANIFEST.in \
|
||||||
python/google/__init__.py \
|
python/google/__init__.py \
|
||||||
|
@ -549,6 +710,7 @@ python_EXTRA_DIST= \
|
||||||
python/google/protobuf/internal/enum_type_wrapper.py \
|
python/google/protobuf/internal/enum_type_wrapper.py \
|
||||||
python/google/protobuf/internal/factory_test1.proto \
|
python/google/protobuf/internal/factory_test1.proto \
|
||||||
python/google/protobuf/internal/factory_test2.proto \
|
python/google/protobuf/internal/factory_test2.proto \
|
||||||
|
python/google/protobuf/internal/file_options_test.proto \
|
||||||
python/google/protobuf/internal/generator_test.py \
|
python/google/protobuf/internal/generator_test.py \
|
||||||
python/google/protobuf/internal/import_test_package/__init__.py \
|
python/google/protobuf/internal/import_test_package/__init__.py \
|
||||||
python/google/protobuf/internal/import_test_package/inner.proto \
|
python/google/protobuf/internal/import_test_package/inner.proto \
|
||||||
|
@ -565,11 +727,13 @@ python_EXTRA_DIST= \
|
||||||
python/google/protobuf/internal/packed_field_test.proto \
|
python/google/protobuf/internal/packed_field_test.proto \
|
||||||
python/google/protobuf/internal/proto_builder_test.py \
|
python/google/protobuf/internal/proto_builder_test.py \
|
||||||
python/google/protobuf/internal/python_message.py \
|
python/google/protobuf/internal/python_message.py \
|
||||||
|
python/google/protobuf/internal/python_protobuf.cc \
|
||||||
python/google/protobuf/internal/reflection_test.py \
|
python/google/protobuf/internal/reflection_test.py \
|
||||||
python/google/protobuf/internal/service_reflection_test.py \
|
python/google/protobuf/internal/service_reflection_test.py \
|
||||||
python/google/protobuf/internal/symbol_database_test.py \
|
python/google/protobuf/internal/symbol_database_test.py \
|
||||||
python/google/protobuf/internal/test_bad_identifiers.proto \
|
python/google/protobuf/internal/test_bad_identifiers.proto \
|
||||||
python/google/protobuf/internal/test_util.py \
|
python/google/protobuf/internal/test_util.py \
|
||||||
|
python/google/protobuf/internal/testing_refleaks.py \
|
||||||
python/google/protobuf/internal/text_encoding_test.py \
|
python/google/protobuf/internal/text_encoding_test.py \
|
||||||
python/google/protobuf/internal/text_format_test.py \
|
python/google/protobuf/internal/text_format_test.py \
|
||||||
python/google/protobuf/internal/type_checkers.py \
|
python/google/protobuf/internal/type_checkers.py \
|
||||||
|
@ -601,14 +765,18 @@ python_EXTRA_DIST= \
|
||||||
python/google/protobuf/pyext/map_container.h \
|
python/google/protobuf/pyext/map_container.h \
|
||||||
python/google/protobuf/pyext/message.cc \
|
python/google/protobuf/pyext/message.cc \
|
||||||
python/google/protobuf/pyext/message.h \
|
python/google/protobuf/pyext/message.h \
|
||||||
|
python/google/protobuf/pyext/message_factory.cc \
|
||||||
|
python/google/protobuf/pyext/message_factory.h \
|
||||||
|
python/google/protobuf/pyext/message_module.cc \
|
||||||
python/google/protobuf/pyext/proto2_api_test.proto \
|
python/google/protobuf/pyext/proto2_api_test.proto \
|
||||||
python/google/protobuf/pyext/python.proto \
|
python/google/protobuf/pyext/python.proto \
|
||||||
python/google/protobuf/pyext/python_protobuf.h \
|
|
||||||
python/google/protobuf/pyext/repeated_composite_container.cc \
|
python/google/protobuf/pyext/repeated_composite_container.cc \
|
||||||
python/google/protobuf/pyext/repeated_composite_container.h \
|
python/google/protobuf/pyext/repeated_composite_container.h \
|
||||||
python/google/protobuf/pyext/repeated_scalar_container.cc \
|
python/google/protobuf/pyext/repeated_scalar_container.cc \
|
||||||
python/google/protobuf/pyext/repeated_scalar_container.h \
|
python/google/protobuf/pyext/repeated_scalar_container.h \
|
||||||
|
python/google/protobuf/pyext/safe_numerics.h \
|
||||||
python/google/protobuf/pyext/scoped_pyobject_ptr.h \
|
python/google/protobuf/pyext/scoped_pyobject_ptr.h \
|
||||||
|
python/google/protobuf/python_protobuf.h \
|
||||||
python/google/protobuf/reflection.py \
|
python/google/protobuf/reflection.py \
|
||||||
python/google/protobuf/service.py \
|
python/google/protobuf/service.py \
|
||||||
python/google/protobuf/service_reflection.py \
|
python/google/protobuf/service_reflection.py \
|
||||||
|
@ -616,6 +784,7 @@ python_EXTRA_DIST= \
|
||||||
python/google/protobuf/text_encoding.py \
|
python/google/protobuf/text_encoding.py \
|
||||||
python/google/protobuf/text_format.py \
|
python/google/protobuf/text_format.py \
|
||||||
python/mox.py \
|
python/mox.py \
|
||||||
|
python/setup.cfg \
|
||||||
python/setup.py \
|
python/setup.py \
|
||||||
python/stubout.py \
|
python/stubout.py \
|
||||||
python/tox.ini \
|
python/tox.ini \
|
||||||
|
@ -623,10 +792,18 @@ python_EXTRA_DIST= \
|
||||||
|
|
||||||
ruby_EXTRA_DIST= \
|
ruby_EXTRA_DIST= \
|
||||||
ruby/Gemfile \
|
ruby/Gemfile \
|
||||||
ruby/Gemfile.lock \
|
|
||||||
ruby/.gitignore \
|
ruby/.gitignore \
|
||||||
ruby/README.md \
|
ruby/README.md \
|
||||||
ruby/Rakefile \
|
ruby/Rakefile \
|
||||||
|
ruby/compatibility_tests/v3.0.0/tests/test_import.proto \
|
||||||
|
ruby/compatibility_tests/v3.0.0/tests/stress.rb \
|
||||||
|
ruby/compatibility_tests/v3.0.0/tests/repeated_field_test.rb \
|
||||||
|
ruby/compatibility_tests/v3.0.0/tests/generated_code_test.rb \
|
||||||
|
ruby/compatibility_tests/v3.0.0/tests/generated_code.proto \
|
||||||
|
ruby/compatibility_tests/v3.0.0/tests/basic.rb \
|
||||||
|
ruby/compatibility_tests/v3.0.0/test.sh \
|
||||||
|
ruby/compatibility_tests/v3.0.0/Rakefile \
|
||||||
|
ruby/compatibility_tests/v3.0.0/README.md \
|
||||||
ruby/ext/google/protobuf_c/defs.c \
|
ruby/ext/google/protobuf_c/defs.c \
|
||||||
ruby/ext/google/protobuf_c/encode_decode.c \
|
ruby/ext/google/protobuf_c/encode_decode.c \
|
||||||
ruby/ext/google/protobuf_c/extconf.rb \
|
ruby/ext/google/protobuf_c/extconf.rb \
|
||||||
|
@ -638,9 +815,11 @@ ruby_EXTRA_DIST= \
|
||||||
ruby/ext/google/protobuf_c/storage.c \
|
ruby/ext/google/protobuf_c/storage.c \
|
||||||
ruby/ext/google/protobuf_c/upb.c \
|
ruby/ext/google/protobuf_c/upb.c \
|
||||||
ruby/ext/google/protobuf_c/upb.h \
|
ruby/ext/google/protobuf_c/upb.h \
|
||||||
|
ruby/ext/google/protobuf_c/wrap_memcpy.c \
|
||||||
ruby/google-protobuf.gemspec \
|
ruby/google-protobuf.gemspec \
|
||||||
ruby/lib/google/protobuf/message_exts.rb \
|
ruby/lib/google/protobuf/message_exts.rb \
|
||||||
ruby/lib/google/protobuf/repeated_field.rb \
|
ruby/lib/google/protobuf/repeated_field.rb \
|
||||||
|
ruby/lib/google/protobuf/well_known_types.rb \
|
||||||
ruby/lib/google/protobuf.rb \
|
ruby/lib/google/protobuf.rb \
|
||||||
ruby/pom.xml \
|
ruby/pom.xml \
|
||||||
ruby/src/main/java/com/google/protobuf/jruby/RubyBuilder.java \
|
ruby/src/main/java/com/google/protobuf/jruby/RubyBuilder.java \
|
||||||
|
@ -665,44 +844,88 @@ ruby_EXTRA_DIST= \
|
||||||
ruby/tests/repeated_field_test.rb \
|
ruby/tests/repeated_field_test.rb \
|
||||||
ruby/tests/stress.rb \
|
ruby/tests/stress.rb \
|
||||||
ruby/tests/generated_code.proto \
|
ruby/tests/generated_code.proto \
|
||||||
|
ruby/tests/test_import.proto \
|
||||||
ruby/tests/generated_code_test.rb \
|
ruby/tests/generated_code_test.rb \
|
||||||
|
ruby/tests/well_known_types_test.rb \
|
||||||
ruby/travis-test.sh
|
ruby/travis-test.sh
|
||||||
|
|
||||||
js_EXTRA_DIST= \
|
js_EXTRA_DIST= \
|
||||||
js/README.md \
|
js/README.md \
|
||||||
js/binary/arith.js \
|
js/binary/arith.js \
|
||||||
js/binary/arith_test.js \
|
js/binary/arith_test.js \
|
||||||
js/binary/constants.js \
|
js/binary/constants.js \
|
||||||
js/binary/decoder.js \
|
js/binary/decoder.js \
|
||||||
js/binary/decoder_test.js \
|
js/binary/decoder_test.js \
|
||||||
js/binary/proto_test.js \
|
js/binary/encoder.js \
|
||||||
js/binary/reader.js \
|
js/binary/message_test.js \
|
||||||
js/binary/reader_test.js \
|
js/binary/proto_test.js \
|
||||||
js/binary/utils.js \
|
js/binary/reader.js \
|
||||||
js/binary/utils_test.js \
|
js/binary/reader_test.js \
|
||||||
js/binary/writer.js \
|
js/binary/utils.js \
|
||||||
js/binary/writer_test.js \
|
js/binary/utils_test.js \
|
||||||
js/data.proto \
|
js/binary/writer.js \
|
||||||
js/debug.js \
|
js/binary/writer_test.js \
|
||||||
js/debug_test.js \
|
js/commonjs/export.js \
|
||||||
js/gulpfile.js \
|
js/commonjs/export_asserts.js \
|
||||||
js/jasmine.json \
|
js/commonjs/export_testdeps.js \
|
||||||
js/message.js \
|
js/commonjs/import_test.js \
|
||||||
js/message_test.js \
|
js/commonjs/jasmine.json \
|
||||||
js/node_loader.js \
|
js/commonjs/rewrite_tests_for_commonjs.js \
|
||||||
js/package.json \
|
js/commonjs/test6/test6.proto \
|
||||||
js/proto3_test.js \
|
js/commonjs/test7/test7.proto \
|
||||||
js/proto3_test.proto \
|
js/compatibility_tests/v3.0.0/binary/arith_test.js \
|
||||||
js/test.proto \
|
js/compatibility_tests/v3.0.0/binary/decoder_test.js \
|
||||||
js/test2.proto \
|
js/compatibility_tests/v3.0.0/binary/proto_test.js \
|
||||||
js/test3.proto \
|
js/compatibility_tests/v3.0.0/binary/reader_test.js \
|
||||||
js/test4.proto \
|
js/compatibility_tests/v3.0.0/binary/utils_test.js \
|
||||||
js/test5.proto \
|
js/compatibility_tests/v3.0.0/binary/writer_test.js \
|
||||||
js/test_bootstrap.js \
|
js/compatibility_tests/v3.0.0/commonjs/export_asserts.js \
|
||||||
js/testbinary.proto \
|
js/compatibility_tests/v3.0.0/commonjs/export_testdeps.js \
|
||||||
|
js/compatibility_tests/v3.0.0/commonjs/import_test.js \
|
||||||
|
js/compatibility_tests/v3.0.0/commonjs/jasmine.json \
|
||||||
|
js/compatibility_tests/v3.0.0/commonjs/rewrite_tests_for_commonjs.js \
|
||||||
|
js/compatibility_tests/v3.0.0/commonjs/test6/test6.proto \
|
||||||
|
js/compatibility_tests/v3.0.0/commonjs/test7/test7.proto \
|
||||||
|
js/compatibility_tests/v3.0.0/data.proto \
|
||||||
|
js/compatibility_tests/v3.0.0/debug_test.js \
|
||||||
|
js/compatibility_tests/v3.0.0/jasmine1.json \
|
||||||
|
js/compatibility_tests/v3.0.0/jasmine2.json \
|
||||||
|
js/compatibility_tests/v3.0.0/jasmine3.json \
|
||||||
|
js/compatibility_tests/v3.0.0/message_test.js \
|
||||||
|
js/compatibility_tests/v3.0.0/proto3_test.js \
|
||||||
|
js/compatibility_tests/v3.0.0/proto3_test.proto \
|
||||||
|
js/compatibility_tests/v3.0.0/test2.proto \
|
||||||
|
js/compatibility_tests/v3.0.0/test3.proto \
|
||||||
|
js/compatibility_tests/v3.0.0/test4.proto \
|
||||||
|
js/compatibility_tests/v3.0.0/test5.proto \
|
||||||
|
js/compatibility_tests/v3.0.0/testbinary.proto \
|
||||||
|
js/compatibility_tests/v3.0.0/testempty.proto \
|
||||||
|
js/compatibility_tests/v3.0.0/test.proto \
|
||||||
|
js/compatibility_tests/v3.0.0/test.sh \
|
||||||
|
js/data.proto \
|
||||||
|
js/debug.js \
|
||||||
|
js/debug_test.js \
|
||||||
|
js/gulpfile.js \
|
||||||
|
js/jasmine.json \
|
||||||
|
js/map.js \
|
||||||
|
js/maps_test.js \
|
||||||
|
js/message.js \
|
||||||
|
js/message_test.js \
|
||||||
|
js/node_loader.js \
|
||||||
|
js/package.json \
|
||||||
|
js/proto3_test.js \
|
||||||
|
js/proto3_test.proto \
|
||||||
|
js/test.proto \
|
||||||
|
js/test2.proto \
|
||||||
|
js/test3.proto \
|
||||||
|
js/test4.proto \
|
||||||
|
js/test5.proto \
|
||||||
|
js/test8.proto \
|
||||||
|
js/test_bootstrap.js \
|
||||||
|
js/testbinary.proto \
|
||||||
js/testempty.proto
|
js/testempty.proto
|
||||||
|
|
||||||
all_EXTRA_DIST=$(csharp_EXTRA_DIST) $(java_EXTRA_DIST) $(javanano_EXTRA_DIST) $(objectivec_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST) $(js_EXTRA_DIST)
|
all_EXTRA_DIST=$(csharp_EXTRA_DIST) $(java_EXTRA_DIST) $(javanano_EXTRA_DIST) $(objectivec_EXTRA_DIST) $(php_EXTRA_DIST) $(python_EXTRA_DIST) $(ruby_EXTRA_DIST) $(js_EXTRA_DIST)
|
||||||
|
|
||||||
EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
|
EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
|
||||||
autogen.sh \
|
autogen.sh \
|
||||||
|
@ -717,6 +940,7 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
|
||||||
WORKSPACE \
|
WORKSPACE \
|
||||||
cmake/CMakeLists.txt \
|
cmake/CMakeLists.txt \
|
||||||
cmake/README.md \
|
cmake/README.md \
|
||||||
|
cmake/examples.cmake \
|
||||||
cmake/extract_includes.bat.in \
|
cmake/extract_includes.bat.in \
|
||||||
cmake/install.cmake \
|
cmake/install.cmake \
|
||||||
cmake/libprotobuf.cmake \
|
cmake/libprotobuf.cmake \
|
||||||
|
@ -725,11 +949,13 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
|
||||||
cmake/protobuf-config-version.cmake.in \
|
cmake/protobuf-config-version.cmake.in \
|
||||||
cmake/protobuf-config.cmake.in \
|
cmake/protobuf-config.cmake.in \
|
||||||
cmake/protobuf-module.cmake.in \
|
cmake/protobuf-module.cmake.in \
|
||||||
|
cmake/protobuf-options.cmake \
|
||||||
cmake/protoc.cmake \
|
cmake/protoc.cmake \
|
||||||
cmake/tests.cmake \
|
cmake/tests.cmake \
|
||||||
editors/README.txt \
|
editors/README.txt \
|
||||||
editors/proto.vim \
|
editors/proto.vim \
|
||||||
editors/protobuf-mode.el \
|
editors/protobuf-mode.el \
|
||||||
|
examples/CMakeLists.txt \
|
||||||
examples/README.txt \
|
examples/README.txt \
|
||||||
examples/Makefile \
|
examples/Makefile \
|
||||||
examples/addressbook.proto \
|
examples/addressbook.proto \
|
||||||
|
@ -739,14 +965,20 @@ EXTRA_DIST = $(@DIST_LANG@_EXTRA_DIST) \
|
||||||
examples/list_people.cc \
|
examples/list_people.cc \
|
||||||
examples/list_people.go \
|
examples/list_people.go \
|
||||||
examples/AddPerson.java \
|
examples/AddPerson.java \
|
||||||
|
examples/CMakeLists.txt \
|
||||||
examples/ListPeople.java \
|
examples/ListPeople.java \
|
||||||
examples/add_person.py \
|
examples/add_person.py \
|
||||||
examples/list_people.py \
|
examples/list_people.py \
|
||||||
examples/list_people_test.go \
|
examples/list_people_test.go \
|
||||||
protobuf.bzl \
|
protobuf.bzl \
|
||||||
|
python/release/wheel/build_wheel_manylinux.sh \
|
||||||
|
python/release/wheel/Dockerfile \
|
||||||
|
python/release/wheel/protobuf_optimized_pip.sh \
|
||||||
|
python/release/wheel/README.md \
|
||||||
six.BUILD \
|
six.BUILD \
|
||||||
util/python/BUILD
|
util/python/BUILD
|
||||||
|
|
||||||
|
|
||||||
# Deletes all the files generated by autogen.sh.
|
# Deletes all the files generated by autogen.sh.
|
||||||
MAINTAINERCLEANFILES = \
|
MAINTAINERCLEANFILES = \
|
||||||
aclocal.m4 \
|
aclocal.m4 \
|
||||||
|
|
|
@ -1,2 +1,4 @@
|
||||||
pkasting@chromium.org
|
pkasting@chromium.org
|
||||||
xyzzyz@chromium.org
|
xyzzyz@chromium.org
|
||||||
|
|
||||||
|
# COMPONENT: Internals
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
# dependent projects use the :git notation to refer to the library.
|
# dependent projects use the :git notation to refer to the library.
|
||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = 'Protobuf'
|
s.name = 'Protobuf'
|
||||||
s.version = '3.0.0-beta-2'
|
s.version = '3.3.2'
|
||||||
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
|
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
|
||||||
s.homepage = 'https://github.com/google/protobuf'
|
s.homepage = 'https://github.com/google/protobuf'
|
||||||
s.license = 'New BSD'
|
s.license = '3-Clause BSD License'
|
||||||
s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' }
|
s.authors = { 'The Protocol Buffers contributors' => 'protobuf@googlegroups.com' }
|
||||||
|
s.cocoapods_version = '>= 1.0'
|
||||||
|
|
||||||
s.source = { :git => 'https://github.com/google/protobuf.git',
|
s.source = { :git => 'https://github.com/google/protobuf.git',
|
||||||
:tag => "v#{s.version}" }
|
:tag => "v#{s.version}" }
|
||||||
|
@ -17,24 +18,25 @@ Pod::Spec.new do |s|
|
||||||
s.source_files = 'objectivec/*.{h,m}',
|
s.source_files = 'objectivec/*.{h,m}',
|
||||||
'objectivec/google/protobuf/Any.pbobjc.{h,m}',
|
'objectivec/google/protobuf/Any.pbobjc.{h,m}',
|
||||||
'objectivec/google/protobuf/Api.pbobjc.{h,m}',
|
'objectivec/google/protobuf/Api.pbobjc.{h,m}',
|
||||||
'objectivec/google/protobuf/Duration.pbobjc.h',
|
'objectivec/google/protobuf/Duration.pbobjc.{h,m}',
|
||||||
'objectivec/google/protobuf/Empty.pbobjc.{h,m}',
|
'objectivec/google/protobuf/Empty.pbobjc.{h,m}',
|
||||||
'objectivec/google/protobuf/FieldMask.pbobjc.{h,m}',
|
'objectivec/google/protobuf/FieldMask.pbobjc.{h,m}',
|
||||||
'objectivec/google/protobuf/SourceContext.pbobjc.{h,m}',
|
'objectivec/google/protobuf/SourceContext.pbobjc.{h,m}',
|
||||||
'objectivec/google/protobuf/Struct.pbobjc.{h,m}',
|
'objectivec/google/protobuf/Struct.pbobjc.{h,m}',
|
||||||
'objectivec/google/protobuf/Timestamp.pbobjc.h',
|
'objectivec/google/protobuf/Timestamp.pbobjc.{h,m}',
|
||||||
'objectivec/google/protobuf/Type.pbobjc.{h,m}',
|
'objectivec/google/protobuf/Type.pbobjc.{h,m}',
|
||||||
'objectivec/google/protobuf/Wrappers.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
|
# The following would cause duplicate symbol definitions. GPBProtocolBuffers is expected to be
|
||||||
# left out, as it's an umbrella implementation file.
|
# left out, as it's an umbrella implementation file.
|
||||||
s.exclude_files = 'objectivec/GPBProtocolBuffers.m'
|
s.exclude_files = 'objectivec/GPBProtocolBuffers.m'
|
||||||
s.header_mappings_dir = 'objectivec'
|
|
||||||
|
|
||||||
s.ios.deployment_target = '7.1'
|
# Set a CPP symbol so the code knows to use framework imports.
|
||||||
|
s.user_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1' }
|
||||||
|
s.pod_target_xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => '$(inherited) GPB_USE_PROTOBUF_FRAMEWORK_IMPORTS=1' }
|
||||||
|
|
||||||
|
s.ios.deployment_target = '7.0'
|
||||||
s.osx.deployment_target = '10.9'
|
s.osx.deployment_target = '10.9'
|
||||||
|
s.tvos.deployment_target = '9.0'
|
||||||
|
s.watchos.deployment_target = '2.0'
|
||||||
s.requires_arc = false
|
s.requires_arc = false
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,14 +3,13 @@ Short Name: protobuf
|
||||||
URL: https://github.com/google/protobuf
|
URL: https://github.com/google/protobuf
|
||||||
License: BSD
|
License: BSD
|
||||||
License File: LICENSE
|
License File: LICENSE
|
||||||
Version: 3.0.0-beta-3
|
Version: 3.3.0
|
||||||
Revision: 3470b6895aa659b7559ed678e029a5338e535f14
|
Revision: 040f56e61b379e92dfdf107b12244a7580f60823
|
||||||
Security Critical: yes
|
Security Critical: yes
|
||||||
|
|
||||||
Steps used to create the current version:
|
Steps used to create the current version:
|
||||||
1. Pull the release from https://github.com/google/protobuf/releases
|
1. Pull the release from https://github.com/google/protobuf/releases
|
||||||
2. Add build files (BUILD.gn, proto_library.gni, protobuf.gyp,
|
2. Add build files (BUILD.gn, proto_library.gni).
|
||||||
protobuf_lite.gypi, protobuf_nacl.gyp).
|
|
||||||
|
|
||||||
Be sure to update the list of source files, as additional .cc files and
|
Be sure to update the list of source files, as additional .cc files and
|
||||||
headers might have been added -- you need to find the transitive closure of
|
headers might have been added -- you need to find the transitive closure of
|
||||||
|
@ -18,40 +17,49 @@ Steps used to create the current version:
|
||||||
|
|
||||||
Other things to care about are defines required by protobuf on various
|
Other things to care about are defines required by protobuf on various
|
||||||
platforms, warnings generated by compilers, and new dependencies introduced.
|
platforms, warnings generated by compilers, and new dependencies introduced.
|
||||||
3. Get open-source library six.py from https://pypi.python.org/pypi/six/ and add
|
3. Add DEPS and OWNERS.
|
||||||
|
4. Add mirclient.cc and mirclient.map.
|
||||||
|
5. Get open-source library six.py from https://pypi.python.org/pypi/six/ and add
|
||||||
it to protobuf/third_party/six/six.py.
|
it to protobuf/third_party/six/six.py.
|
||||||
4. Apply patches in patches/ (see the description below):
|
6. Apply patches in patches/ (see the description below):
|
||||||
|
|
||||||
$ for patch in patches/*; do patch -s -p1 < $patch; done
|
$ for patch in patches/*; do patch -s -p1 < $patch; done
|
||||||
|
|
||||||
For future releases, it will be worth looking into which patches still need
|
For future releases, it will be worth looking into which patches still need
|
||||||
to be applied.
|
to be applied. In case of conflict, update those patches accordingly and save
|
||||||
5. Generate descriptor_pb2.py using something like the following steps. Make
|
them back in place (i.e. in patches directory).
|
||||||
sure you've regenerated your buildfiles and will build protoc from the
|
7. Generate well_known_types_embed.cc and descriptor_pb2.py using something like
|
||||||
newly-modified sources above.
|
the following steps. Make sure you've regenerated your buildfiles and will
|
||||||
|
build js_embed then protoc from the newly-modified sources above.
|
||||||
|
|
||||||
|
$ cd $SRC_DIR
|
||||||
|
$ gn gen out/Debug
|
||||||
|
$ ninja -C out/Debug js_embed
|
||||||
|
$ cd third_party/protobuf/src/google/protobuf/compiler/js
|
||||||
|
$ $SRC_DIR/out/Debug/js_embed \
|
||||||
|
./well_known_types/any.js ./well_known_types/struct.js \
|
||||||
|
./well_known_types/timestamp.js > well_known_types_embed.cc
|
||||||
$ cd $SRC_DIR
|
$ cd $SRC_DIR
|
||||||
$ ninja -C out/Debug protoc
|
$ ninja -C out/Debug protoc
|
||||||
$ cd third_party/protobuf/src
|
$ cd third_party/protobuf/src
|
||||||
$ ../../../out/Debug/protoc --python_out=../python google/protobuf/descriptor.proto
|
$ $SRC_DIR/out/Debug/protoc --python_out=../python google/protobuf/descriptor.proto
|
||||||
|
|
||||||
6. Add an __init__.py to protobuf/ that adds third_party/six/ to Python path.
|
8. Add an __init__.py to protobuf/ that adds third_party/six/ to Python path.
|
||||||
7. Update README.chromium.
|
9. Update README.chromium.
|
||||||
|
|
||||||
|
Note about libmirclient:
|
||||||
|
|
||||||
|
On Ubuntu, Chromium has an indirect dependency on the system
|
||||||
|
libprotobuf-lite through libmirclient (through GTK). The symbols in
|
||||||
|
the system library conflict with Chromium's libprotobuf-lite used on
|
||||||
|
component builds.
|
||||||
|
|
||||||
|
mirclient.* are added to stub out libmirclient.so.9 to prevent loading
|
||||||
|
the system libprotobuf-lite. Chromium's replacement libmirclient will
|
||||||
|
get loaded, but its symbols will never be used directly or indirectly.
|
||||||
|
|
||||||
Description of the patches:
|
Description of the patches:
|
||||||
|
|
||||||
- 0001-ignore-option-retain-unknown-fields.patch
|
|
||||||
|
|
||||||
Previous versions of protobuf in Chromium carried a local patch that retained
|
|
||||||
unknown fields in protobuf_lite mode. It was enabled by setting option
|
|
||||||
retain_unknown_fields = true in .proto file. Now that it is enabled by
|
|
||||||
default, this option is no longer recognized by protobuf, and so I had to
|
|
||||||
patch it so that I don't have to fix all .proto files in Chromium in a single
|
|
||||||
CL.
|
|
||||||
|
|
||||||
I plan to remove those occurences, and then this patch will no longer be
|
|
||||||
necessary.
|
|
||||||
|
|
||||||
- 0003-remove-static-initializers.patch
|
- 0003-remove-static-initializers.patch
|
||||||
|
|
||||||
This patch removes all static initializers from Chromium. The change in Status
|
This patch removes all static initializers from Chromium. The change in Status
|
||||||
|
@ -67,13 +75,6 @@ Description of the patches:
|
||||||
protobuf symbols in Linux .so libraries, so that protobuf can be built as a
|
protobuf symbols in Linux .so libraries, so that protobuf can be built as a
|
||||||
component (see http://crrev.com/179806).
|
component (see http://crrev.com/179806).
|
||||||
|
|
||||||
- 0005-fix-include-js-generator.protobuf
|
|
||||||
|
|
||||||
During merge with internal branch, the <> in one of the #includes were
|
|
||||||
accidentally replaced with "", which results in a failure in checkdeps.
|
|
||||||
|
|
||||||
Fixed in https://github.com/google/protobuf/pull/1547.
|
|
||||||
|
|
||||||
- 0007-uninline_googleonce.patch
|
- 0007-uninline_googleonce.patch
|
||||||
- 0008-uninline_get_empty_string.patch
|
- 0008-uninline_get_empty_string.patch
|
||||||
- 0009-uninline-arenastring.patch
|
- 0009-uninline-arenastring.patch
|
||||||
|
@ -82,9 +83,42 @@ Description of the patches:
|
||||||
These patches uninline some functions, resulting in a significant reduction
|
These patches uninline some functions, resulting in a significant reduction
|
||||||
(somewhere between 500 KB and 1 MB) of binary size.
|
(somewhere between 500 KB and 1 MB) of binary size.
|
||||||
|
|
||||||
- 0011-libprotobuf_export.patch
|
- 0012-fixes-for-js-embed-cc.patch
|
||||||
|
|
||||||
During merge with internal branch, the dll export attribute was accidentally
|
|
||||||
removed in C++11 mode.
|
|
||||||
|
|
||||||
Fixed in https://github.com/google/protobuf/pull/1549
|
Fixed in https://github.com/google/protobuf/pull/1549
|
||||||
|
|
||||||
|
- 0013-fixes-expansion-to-defined.patch
|
||||||
|
|
||||||
|
Fixes a macro whose expansion has a defined() in it. This is
|
||||||
|
results in undefined behavior and some compilers will warn/error
|
||||||
|
when seeing this.
|
||||||
|
|
||||||
|
- 0014-truncate-uint8-constants.patch
|
||||||
|
|
||||||
|
Fixed upstream in CL 161573822
|
||||||
|
|
||||||
|
- 0015-fixes-forcing-value-to-bool.patch
|
||||||
|
|
||||||
|
Fixes an MSVC error that forbids conversion from int to bool. Needs
|
||||||
|
to be upstreamed.
|
||||||
|
|
||||||
|
- 0014-truncate-uint8-constants.patch
|
||||||
|
|
||||||
|
Fixed upstream in CL 163270735
|
||||||
|
|
||||||
|
- 0017-constexpr-for-vs-2017.patch
|
||||||
|
|
||||||
|
Define PROTOBUF_CONSTEXPR_VAR as constexpr for VS 2017, also landed upstream
|
||||||
|
as https://github.com/google/protobuf/commit/210be267fd81d5aafdc049d197d57cb45b75f3ba
|
||||||
|
|
||||||
|
- 0018-fallthrough.patch
|
||||||
|
|
||||||
|
Cherry-picks upstream https://github.com/google/protobuf/commit/b8e47830d
|
||||||
|
|
||||||
|
- 0019-rename-a-shadowed-variable.patch
|
||||||
|
|
||||||
|
Cherry-picks upstream https://github.com/google/protobuf/commit/af3813cd7
|
||||||
|
|
||||||
|
- 0020-Add-support-for-libc-on-Windows.patch
|
||||||
|
|
||||||
|
Cherry-picks upstream https://github.com/google/protobuf/commit/3ba21cd5f
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Protocol Buffers - Google's data interchange format
|
Protocol Buffers - Google's data interchange format
|
||||||
===================================================
|
===================================================
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf) [![Build status](https://ci.appveyor.com/api/projects/status/73ctee6ua4w2ruin?svg=true)](https://ci.appveyor.com/project/protobuf/protobuf)
|
[![Build Status](https://travis-ci.org/google/protobuf.svg?branch=master)](https://travis-ci.org/google/protobuf) [![Build status](https://ci.appveyor.com/api/projects/status/73ctee6ua4w2ruin?svg=true)](https://ci.appveyor.com/project/protobuf/protobuf) [![Build Status](https://grpc-testing.appspot.com/buildStatus/icon?job=protobuf_branch)](https://grpc-testing.appspot.com/job/protobuf_branch) [![Build Status](https://grpc-testing.appspot.com/job/protobuf_branch_32/badge/icon)](https://grpc-testing.appspot.com/job/protobuf_branch_32) [![Build Status](http://ci.bazel.io/buildStatus/icon?job=protobuf)](http://ci.bazel.io/job/protobuf/)
|
||||||
|
|
||||||
Copyright 2008 Google Inc.
|
Copyright 2008 Google Inc.
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ as well as a set of standard .proto files distributed along with protobuf.
|
||||||
If you are looking for an old version that is not available in the release
|
If you are looking for an old version that is not available in the release
|
||||||
page, check out the maven repo here:
|
page, check out the maven repo here:
|
||||||
|
|
||||||
[http://repo1.maven.org/maven2/com/google/protobuf/protoc/](http://repo1.maven.org/maven2/com/google/protobuf/protoc/)
|
[https://repo1.maven.org/maven2/com/google/protobuf/protoc/](https://repo1.maven.org/maven2/com/google/protobuf/protoc/)
|
||||||
|
|
||||||
These pre-built binaries are only provided for released versions. If you want
|
These pre-built binaries are only provided for released versions. If you want
|
||||||
to use the github master version at HEAD, or you need to modify protobuf code,
|
to use the github master version at HEAD, or you need to modify protobuf code,
|
||||||
|
@ -54,18 +54,19 @@ Protobuf supports several different programming languages. For each programming
|
||||||
language, you can find instructions in the corresponding source directory about
|
language, you can find instructions in the corresponding source directory about
|
||||||
how to install protobuf runtime for that specific language:
|
how to install protobuf runtime for that specific language:
|
||||||
|
|
||||||
| Language | Source |
|
| Language | Source |
|
||||||
|--------------------------------------|-------------------------------------------------------|
|
|--------------------------------------|-------------------------------------------------------------|
|
||||||
| C++ (include C++ runtime and protoc) | [src](src) |
|
| C++ (include C++ runtime and protoc) | [src](src) |
|
||||||
| Java | [java](java) |
|
| Java | [java](java) |
|
||||||
| Python | [python](python) |
|
| Python | [python](python) |
|
||||||
| Objective-C | [objectivec](objectivec) |
|
| Objective-C | [objectivec](objectivec) |
|
||||||
| C# | [csharp](csharp) |
|
| C# | [csharp](csharp) |
|
||||||
| JavaNano | [javanano](javanano) |
|
| JavaNano | [javanano](javanano) |
|
||||||
| JavaScript | [js](js) |
|
| JavaScript | [js](js) |
|
||||||
| Ruby | [ruby](ruby) |
|
| Ruby | [ruby](ruby) |
|
||||||
| Go | [golang/protobuf](https://github.com/golang/protobuf) |
|
| Go | [golang/protobuf](https://github.com/golang/protobuf) |
|
||||||
| PHP | TBD |
|
| PHP | [php](php) |
|
||||||
|
| Dart | [dart-lang/protobuf](https://github.com/dart-lang/protobuf) |
|
||||||
|
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
|
@ -74,4 +75,4 @@ Usage
|
||||||
The complete documentation for Protocol Buffers is available via the
|
The complete documentation for Protocol Buffers is available via the
|
||||||
web at:
|
web at:
|
||||||
|
|
||||||
https://developers.google.com/protocol-buffers/
|
https://developers.google.com/protocol-buffers/
|
||||||
|
|
|
@ -1,152 +0,0 @@
|
||||||
Protocol Buffers - Google's data interchange format
|
|
||||||
Copyright 2008 Google Inc.
|
|
||||||
http://code.google.com/apis/protocolbuffers/
|
|
||||||
|
|
||||||
C++ Installation - Unix
|
|
||||||
=======================
|
|
||||||
|
|
||||||
To build and install the C++ Protocol Buffer runtime and the Protocol
|
|
||||||
Buffer compiler (protoc) execute the following:
|
|
||||||
|
|
||||||
$ ./configure
|
|
||||||
$ make
|
|
||||||
$ make check
|
|
||||||
$ make install
|
|
||||||
|
|
||||||
If "make check" fails, you can still install, but it is likely that
|
|
||||||
some features of this library will not work correctly on your system.
|
|
||||||
Proceed at your own risk.
|
|
||||||
|
|
||||||
"make install" may require superuser privileges.
|
|
||||||
|
|
||||||
For advanced usage information on configure and make, see INSTALL.txt.
|
|
||||||
|
|
||||||
** Hint on install location **
|
|
||||||
|
|
||||||
By default, the package will be installed to /usr/local. However,
|
|
||||||
on many platforms, /usr/local/lib is not part of LD_LIBRARY_PATH.
|
|
||||||
You can add it, but it may be easier to just install to /usr
|
|
||||||
instead. To do this, invoke configure as follows:
|
|
||||||
|
|
||||||
./configure --prefix=/usr
|
|
||||||
|
|
||||||
If you already built the package with a different prefix, make sure
|
|
||||||
to run "make clean" before building again.
|
|
||||||
|
|
||||||
** Compiling dependent packages **
|
|
||||||
|
|
||||||
To compile a package that uses Protocol Buffers, you need to pass
|
|
||||||
various flags to your compiler and linker. As of version 2.2.0,
|
|
||||||
Protocol Buffers integrates with pkg-config to manage this. If you
|
|
||||||
have pkg-config installed, then you can invoke it to get a list of
|
|
||||||
flags like so:
|
|
||||||
|
|
||||||
pkg-config --cflags protobuf # print compiler flags
|
|
||||||
pkg-config --libs protobuf # print linker flags
|
|
||||||
pkg-config --cflags --libs protobuf # print both
|
|
||||||
|
|
||||||
For example:
|
|
||||||
|
|
||||||
c++ my_program.cc my_proto.pb.cc `pkg-config --cflags --libs protobuf`
|
|
||||||
|
|
||||||
Note that packages written prior to the 2.2.0 release of Protocol
|
|
||||||
Buffers may not yet integrate with pkg-config to get flags, and may
|
|
||||||
not pass the correct set of flags to correctly link against
|
|
||||||
libprotobuf. If the package in question uses autoconf, you can
|
|
||||||
often fix the problem by invoking its configure script like:
|
|
||||||
|
|
||||||
configure CXXFLAGS="$(pkg-config --cflags protobuf)" \
|
|
||||||
LIBS="$(pkg-config --libs protobuf)"
|
|
||||||
|
|
||||||
This will force it to use the correct flags.
|
|
||||||
|
|
||||||
If you are writing an autoconf-based package that uses Protocol
|
|
||||||
Buffers, you should probably use the PKG_CHECK_MODULES macro in your
|
|
||||||
configure script like:
|
|
||||||
|
|
||||||
PKG_CHECK_MODULES([protobuf], [protobuf])
|
|
||||||
|
|
||||||
See the pkg-config man page for more info.
|
|
||||||
|
|
||||||
If you only want protobuf-lite, substitute "protobuf-lite" in place
|
|
||||||
of "protobuf" in these examples.
|
|
||||||
|
|
||||||
** Note for cross-compiling **
|
|
||||||
|
|
||||||
The makefiles normally invoke the protoc executable that they just
|
|
||||||
built in order to build tests. When cross-compiling, the protoc
|
|
||||||
executable may not be executable on the host machine. In this case,
|
|
||||||
you must build a copy of protoc for the host machine first, then use
|
|
||||||
the --with-protoc option to tell configure to use it instead. For
|
|
||||||
example:
|
|
||||||
|
|
||||||
./configure --with-protoc=protoc
|
|
||||||
|
|
||||||
This will use the installed protoc (found in your $PATH) instead of
|
|
||||||
trying to execute the one built during the build process. You can
|
|
||||||
also use an executable that hasn't been installed. For example, if
|
|
||||||
you built the protobuf package for your host machine in ../host,
|
|
||||||
you might do:
|
|
||||||
|
|
||||||
./configure --with-protoc=../host/src/protoc
|
|
||||||
|
|
||||||
Either way, you must make sure that the protoc executable you use
|
|
||||||
has the same version as the protobuf source code you are trying to
|
|
||||||
use it with.
|
|
||||||
|
|
||||||
** Note for Solaris users **
|
|
||||||
|
|
||||||
Solaris 10 x86 has a bug that will make linking fail, complaining
|
|
||||||
about libstdc++.la being invalid. We have included a work-around
|
|
||||||
in this package. To use the work-around, run configure as follows:
|
|
||||||
|
|
||||||
./configure LDFLAGS=-L$PWD/src/solaris
|
|
||||||
|
|
||||||
See src/solaris/libstdc++.la for more info on this bug.
|
|
||||||
|
|
||||||
** Note for HP C++ Tru64 users **
|
|
||||||
|
|
||||||
To compile invoke configure as follows:
|
|
||||||
|
|
||||||
./configure CXXFLAGS="-O -std ansi -ieee -D__USE_STD_IOSTREAM"
|
|
||||||
|
|
||||||
Also, you will need to use gmake instead of make.
|
|
||||||
|
|
||||||
C++ Installation - Windows
|
|
||||||
==========================
|
|
||||||
|
|
||||||
If you are using Microsoft Visual C++, see vsprojects/readme.txt.
|
|
||||||
|
|
||||||
If you are using Cygwin or MinGW, follow the Unix installation
|
|
||||||
instructions, above.
|
|
||||||
|
|
||||||
Binary Compatibility Warning
|
|
||||||
============================
|
|
||||||
|
|
||||||
Due to the nature of C++, it is unlikely that any two versions of the
|
|
||||||
Protocol Buffers C++ runtime libraries will have compatible ABIs.
|
|
||||||
That is, if you linked an executable against an older version of
|
|
||||||
libprotobuf, it is unlikely to work with a newer version without
|
|
||||||
re-compiling. This problem, when it occurs, will normally be detected
|
|
||||||
immediately on startup of your app. Still, you may want to consider
|
|
||||||
using static linkage. You can configure this package to install
|
|
||||||
static libraries only using:
|
|
||||||
|
|
||||||
./configure --disable-shared
|
|
||||||
|
|
||||||
Java and Python Installation
|
|
||||||
============================
|
|
||||||
|
|
||||||
The Java and Python runtime libraries for Protocol Buffers are located
|
|
||||||
in the java and python directories. See the README file in each
|
|
||||||
directory for more information on how to compile and install them.
|
|
||||||
Note that both of them require you to first install the Protocol
|
|
||||||
Buffer compiler (protoc), which is part of the C++ package.
|
|
||||||
|
|
||||||
Usage
|
|
||||||
=====
|
|
||||||
|
|
||||||
The complete documentation for Protocol Buffers is available via the
|
|
||||||
web at:
|
|
||||||
|
|
||||||
http://code.google.com/apis/protocolbuffers/
|
|
|
@ -1,15 +1,15 @@
|
||||||
new_http_archive(
|
new_git_repository(
|
||||||
name = "gmock_archive",
|
name = "googletest",
|
||||||
url = "https://googlemock.googlecode.com/files/gmock-1.7.0.zip",
|
|
||||||
sha256 = "26fcbb5925b74ad5fc8c26b0495dfc96353f4d553492eb97e85a8a6d2f43095b",
|
|
||||||
build_file = "gmock.BUILD",
|
build_file = "gmock.BUILD",
|
||||||
|
remote = "https://github.com/google/googletest",
|
||||||
|
tag = "release-1.8.0",
|
||||||
)
|
)
|
||||||
|
|
||||||
new_http_archive(
|
new_http_archive(
|
||||||
name = "six_archive",
|
name = "six_archive",
|
||||||
url = "https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55",
|
|
||||||
sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a",
|
|
||||||
build_file = "six.BUILD",
|
build_file = "six.BUILD",
|
||||||
|
sha256 = "105f8d68616f8248e24bf0e9372ef04d3cc10104f1980f54d57b2ce73a5ad56a",
|
||||||
|
url = "https://pypi.python.org/packages/source/s/six/six-1.10.0.tar.gz#md5=34eed507548117b2ab523ab14b2f8b55",
|
||||||
)
|
)
|
||||||
|
|
||||||
bind(
|
bind(
|
||||||
|
@ -19,12 +19,12 @@ bind(
|
||||||
|
|
||||||
bind(
|
bind(
|
||||||
name = "gtest",
|
name = "gtest",
|
||||||
actual = "@gmock_archive//:gtest",
|
actual = "@googletest//:gtest",
|
||||||
)
|
)
|
||||||
|
|
||||||
bind(
|
bind(
|
||||||
name = "gtest_main",
|
name = "gtest_main",
|
||||||
actual = "@gmock_archive//:gtest_main",
|
actual = "@googletest//:gtest_main",
|
||||||
)
|
)
|
||||||
|
|
||||||
bind(
|
bind(
|
||||||
|
@ -33,8 +33,8 @@ bind(
|
||||||
)
|
)
|
||||||
|
|
||||||
maven_jar(
|
maven_jar(
|
||||||
name = "guava_maven",
|
name = "guava_maven",
|
||||||
artifact = "com.google.guava:guava:18.0",
|
artifact = "com.google.guava:guava:18.0",
|
||||||
)
|
)
|
||||||
|
|
||||||
bind(
|
bind(
|
||||||
|
@ -43,8 +43,8 @@ bind(
|
||||||
)
|
)
|
||||||
|
|
||||||
maven_jar(
|
maven_jar(
|
||||||
name = "gson_maven",
|
name = "gson_maven",
|
||||||
artifact = "com.google.code.gson:gson:2.3",
|
artifact = "com.google.code.gson:gson:2.7",
|
||||||
)
|
)
|
||||||
|
|
||||||
bind(
|
bind(
|
||||||
|
|
|
@ -10,7 +10,7 @@ goto :error
|
||||||
echo Building C++
|
echo Building C++
|
||||||
mkdir build_msvc
|
mkdir build_msvc
|
||||||
cd build_msvc
|
cd build_msvc
|
||||||
cmake -G "%generator%" -Dprotobuf_BUILD_SHARED_LIBS=%BUILD_DLL% ../cmake
|
cmake -G "%generator%" -Dprotobuf_BUILD_SHARED_LIBS=%BUILD_DLL% -Dprotobuf_UNICODE=%UNICODE% ../cmake
|
||||||
msbuild protobuf.sln /p:Platform=%vcplatform% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" || goto error
|
msbuild protobuf.sln /p:Platform=%vcplatform% /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" || goto error
|
||||||
cd %configuration%
|
cd %configuration%
|
||||||
tests.exe || goto error
|
tests.exe || goto error
|
||||||
|
@ -19,9 +19,16 @@ goto :EOF
|
||||||
:build_csharp
|
:build_csharp
|
||||||
echo Building C#
|
echo Building C#
|
||||||
cd csharp\src
|
cd csharp\src
|
||||||
nuget restore
|
REM The platform environment variable is implicitly used by msbuild;
|
||||||
msbuild Google.Protobuf.sln /p:Platform="Any CPU" /logger:"C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll" || goto error
|
REM we don't want it.
|
||||||
nunit-console Google.Protobuf.Test\bin\%configuration%\Google.Protobuf.Test.dll || goto error
|
set platform=
|
||||||
|
dotnet restore
|
||||||
|
dotnet build -c %configuration% || goto error
|
||||||
|
|
||||||
|
echo Testing C#
|
||||||
|
dotnet run -c %configuration% -f netcoreapp1.0 -p Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error
|
||||||
|
dotnet run -c %configuration% -f net451 -p Google.Protobuf.Test\Google.Protobuf.Test.csproj || goto error
|
||||||
|
|
||||||
goto :EOF
|
goto :EOF
|
||||||
|
|
||||||
:error
|
:error
|
||||||
|
|
|
@ -11,13 +11,25 @@ environment:
|
||||||
matrix:
|
matrix:
|
||||||
- language: cpp
|
- language: cpp
|
||||||
BUILD_DLL: ON
|
BUILD_DLL: ON
|
||||||
|
UNICODE: ON
|
||||||
|
|
||||||
- language: csharp
|
- language: csharp
|
||||||
|
image: Visual Studio 2017
|
||||||
|
|
||||||
|
# Our build scripts run tests automatically; we don't want AppVeyor
|
||||||
|
# to try to detect them itself.
|
||||||
|
test: off
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- ps: Start-FileDownload https://googlemock.googlecode.com/files/gmock-1.7.0.zip
|
- curl -L -o release-1.7.0.zip https://github.com/google/googlemock/archive/release-1.7.0.zip
|
||||||
- 7z x gmock-1.7.0.zip
|
- 7z x release-1.7.0.zip
|
||||||
- rename gmock-1.7.0 gmock
|
- del /Q release-1.7.0.zip
|
||||||
|
- rename googlemock-release-1.7.0 gmock
|
||||||
|
- curl -L -o release-1.7.0.zip "https://github.com/google/googletest/archive/release-1.7.0.zip"
|
||||||
|
- 7z x release-1.7.0.zip
|
||||||
|
- del /Q release-1.7.0.zip
|
||||||
|
- rename googletest-release-1.7.0 gtest
|
||||||
|
- move gtest gmock
|
||||||
|
|
||||||
before_build:
|
before_build:
|
||||||
- if %platform%==Win32 set generator=Visual Studio 12
|
- if %platform%==Win32 set generator=Visual Studio 12
|
||||||
|
|
|
@ -31,10 +31,15 @@ fi
|
||||||
# directory is set up as an SVN external.
|
# directory is set up as an SVN external.
|
||||||
if test ! -e gmock; then
|
if test ! -e gmock; then
|
||||||
echo "Google Mock not present. Fetching gmock-1.7.0 from the web..."
|
echo "Google Mock not present. Fetching gmock-1.7.0 from the web..."
|
||||||
curl $curlopts -O https://googlemock.googlecode.com/files/gmock-1.7.0.zip
|
curl $curlopts -L -O https://github.com/google/googlemock/archive/release-1.7.0.zip
|
||||||
unzip -q gmock-1.7.0.zip
|
unzip -q release-1.7.0.zip
|
||||||
rm gmock-1.7.0.zip
|
rm release-1.7.0.zip
|
||||||
mv gmock-1.7.0 gmock
|
mv googlemock-release-1.7.0 gmock
|
||||||
|
|
||||||
|
curl $curlopts -L -O https://github.com/google/googletest/archive/release-1.7.0.zip
|
||||||
|
unzip -q release-1.7.0.zip
|
||||||
|
rm release-1.7.0.zip
|
||||||
|
mv googletest-release-1.7.0 gmock/gtest
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
|
@ -16,7 +16,9 @@ benchmarks_protoc_outputs_proto2 = \
|
||||||
benchmark_messages_proto2.pb.cc \
|
benchmark_messages_proto2.pb.cc \
|
||||||
benchmark_messages_proto2.pb.h
|
benchmark_messages_proto2.pb.h
|
||||||
|
|
||||||
bin_PROGRAMS = generate-datasets
|
AM_CXXFLAGS = $(NO_OPT_CXXFLAGS) $(PROTOBUF_OPT_FLAG) -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare
|
||||||
|
|
||||||
|
bin_PROGRAMS = generate-datasets cpp-benchmark
|
||||||
|
|
||||||
generate_datasets_LDADD = $(top_srcdir)/src/libprotobuf.la
|
generate_datasets_LDADD = $(top_srcdir)/src/libprotobuf.la
|
||||||
generate_datasets_SOURCES = generate_datasets.cc
|
generate_datasets_SOURCES = generate_datasets.cc
|
||||||
|
@ -30,6 +32,13 @@ nodist_generate_datasets_SOURCES = \
|
||||||
# See: https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html#Recording-Dependencies-manually
|
# See: https://www.gnu.org/software/automake/manual/html_node/Built-Sources-Example.html#Recording-Dependencies-manually
|
||||||
generate_datasets-generate_datasets.$(OBJEXT): benchmarks.pb.h
|
generate_datasets-generate_datasets.$(OBJEXT): benchmarks.pb.h
|
||||||
|
|
||||||
|
cpp_benchmark_LDADD = $(top_srcdir)/src/libprotobuf.la $(top_srcdir)/third_party/benchmark/src/libbenchmark.a
|
||||||
|
cpp_benchmark_SOURCES = cpp_benchmark.cc
|
||||||
|
cpp_benchmark_CPPFLAGS = -I$(top_srcdir)/src -I$(srcdir) -I$(top_srcdir)/third_party/benchmark/include
|
||||||
|
nodist_cpp_benchmark_SOURCES = \
|
||||||
|
$(benchmarks_protoc_outputs) \
|
||||||
|
$(benchmarks_protoc_outputs_proto2)
|
||||||
|
|
||||||
$(benchmarks_protoc_outputs): protoc_middleman
|
$(benchmarks_protoc_outputs): protoc_middleman
|
||||||
$(benchmarks_protoc_outputs_proto2): protoc_middleman2
|
$(benchmarks_protoc_outputs_proto2): protoc_middleman2
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,8 @@ option java_package = "com.google.protobuf.benchmarks";
|
||||||
// This is the default, but we specify it here explicitly.
|
// This is the default, but we specify it here explicitly.
|
||||||
option optimize_for = SPEED;
|
option optimize_for = SPEED;
|
||||||
|
|
||||||
|
option cc_enable_arenas = true;
|
||||||
|
|
||||||
message GoogleMessage1 {
|
message GoogleMessage1 {
|
||||||
required string field1 = 1;
|
required string field1 = 1;
|
||||||
optional string field9 = 9;
|
optional string field9 = 9;
|
||||||
|
|
|
@ -8,6 +8,8 @@ option java_package = "com.google.protobuf.benchmarks";
|
||||||
// This is the default, but we specify it here explicitly.
|
// This is the default, but we specify it here explicitly.
|
||||||
option optimize_for = SPEED;
|
option optimize_for = SPEED;
|
||||||
|
|
||||||
|
option cc_enable_arenas = true;
|
||||||
|
|
||||||
message GoogleMessage1 {
|
message GoogleMessage1 {
|
||||||
string field1 = 1;
|
string field1 = 1;
|
||||||
string field9 = 9;
|
string field9 = 9;
|
||||||
|
|
|
@ -0,0 +1,242 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
#include <glob.h>
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include "benchmark/benchmark_api.h"
|
||||||
|
#include "benchmarks.pb.h"
|
||||||
|
#include "benchmark_messages_proto2.pb.h"
|
||||||
|
#include "benchmark_messages_proto3.pb.h"
|
||||||
|
|
||||||
|
#define PREFIX "dataset."
|
||||||
|
#define SUFFIX ".pb"
|
||||||
|
|
||||||
|
using benchmarks::BenchmarkDataset;
|
||||||
|
using google::protobuf::Arena;
|
||||||
|
using google::protobuf::Descriptor;
|
||||||
|
using google::protobuf::DescriptorPool;
|
||||||
|
using google::protobuf::Message;
|
||||||
|
using google::protobuf::MessageFactory;
|
||||||
|
|
||||||
|
class Fixture : public benchmark::Fixture {
|
||||||
|
public:
|
||||||
|
Fixture(const BenchmarkDataset& dataset, const std::string& suffix) {
|
||||||
|
for (int i = 0; i < dataset.payload_size(); i++) {
|
||||||
|
payloads_.push_back(dataset.payload(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
const Descriptor* d =
|
||||||
|
DescriptorPool::generated_pool()->FindMessageTypeByName(
|
||||||
|
dataset.message_name());
|
||||||
|
|
||||||
|
if (!d) {
|
||||||
|
std::cerr << "Couldn't find message named '" << dataset.message_name()
|
||||||
|
<< "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
prototype_ = MessageFactory::generated_factory()->GetPrototype(d);
|
||||||
|
SetName((dataset.name() + suffix).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::vector<std::string> payloads_;
|
||||||
|
const Message* prototype_;
|
||||||
|
};
|
||||||
|
|
||||||
|
class WrappingCounter {
|
||||||
|
public:
|
||||||
|
WrappingCounter(size_t limit) : value_(0), limit_(limit) {}
|
||||||
|
|
||||||
|
size_t Next() {
|
||||||
|
size_t ret = value_;
|
||||||
|
if (++value_ == limit_) {
|
||||||
|
value_ = 0;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
size_t value_;
|
||||||
|
size_t limit_;
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class ParseNewFixture : public Fixture {
|
||||||
|
public:
|
||||||
|
ParseNewFixture(const BenchmarkDataset& dataset)
|
||||||
|
: Fixture(dataset, "_parse_new") {}
|
||||||
|
|
||||||
|
virtual void BenchmarkCase(benchmark::State& state) {
|
||||||
|
WrappingCounter i(payloads_.size());
|
||||||
|
size_t total = 0;
|
||||||
|
|
||||||
|
while (state.KeepRunning()) {
|
||||||
|
T m;
|
||||||
|
const std::string& payload = payloads_[i.Next()];
|
||||||
|
total += payload.size();
|
||||||
|
m.ParseFromString(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
state.SetBytesProcessed(total);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class ParseNewArenaFixture : public Fixture {
|
||||||
|
public:
|
||||||
|
ParseNewArenaFixture(const BenchmarkDataset& dataset)
|
||||||
|
: Fixture(dataset, "_parse_newarena") {}
|
||||||
|
|
||||||
|
virtual void BenchmarkCase(benchmark::State& state) {
|
||||||
|
WrappingCounter i(payloads_.size());
|
||||||
|
size_t total = 0;
|
||||||
|
|
||||||
|
while (state.KeepRunning()) {
|
||||||
|
Arena arena;
|
||||||
|
Message* m = Arena::CreateMessage<T>(&arena);
|
||||||
|
const std::string& payload = payloads_[i.Next()];
|
||||||
|
total += payload.size();
|
||||||
|
m->ParseFromString(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
state.SetBytesProcessed(total);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class ParseReuseFixture : public Fixture {
|
||||||
|
public:
|
||||||
|
ParseReuseFixture(const BenchmarkDataset& dataset)
|
||||||
|
: Fixture(dataset, "_parse_reuse") {}
|
||||||
|
|
||||||
|
virtual void BenchmarkCase(benchmark::State& state) {
|
||||||
|
T m;
|
||||||
|
WrappingCounter i(payloads_.size());
|
||||||
|
size_t total = 0;
|
||||||
|
|
||||||
|
while (state.KeepRunning()) {
|
||||||
|
const std::string& payload = payloads_[i.Next()];
|
||||||
|
total += payload.size();
|
||||||
|
m.ParseFromString(payload);
|
||||||
|
}
|
||||||
|
|
||||||
|
state.SetBytesProcessed(total);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
class SerializeFixture : public Fixture {
|
||||||
|
public:
|
||||||
|
SerializeFixture(const BenchmarkDataset& dataset)
|
||||||
|
: Fixture(dataset, "_serialize") {
|
||||||
|
for (size_t i = 0; i < payloads_.size(); i++) {
|
||||||
|
message_.push_back(new T);
|
||||||
|
message_.back()->ParseFromString(payloads_[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
~SerializeFixture() {
|
||||||
|
for (size_t i = 0; i < message_.size(); i++) {
|
||||||
|
delete message_[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual void BenchmarkCase(benchmark::State& state) {
|
||||||
|
size_t total = 0;
|
||||||
|
std::string str;
|
||||||
|
WrappingCounter i(payloads_.size());
|
||||||
|
|
||||||
|
while (state.KeepRunning()) {
|
||||||
|
str.clear();
|
||||||
|
message_[i.Next()]->SerializeToString(&str);
|
||||||
|
total += str.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
state.SetBytesProcessed(total);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::vector<T*> message_;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::string ReadFile(const std::string& name) {
|
||||||
|
std::ifstream file(name.c_str());
|
||||||
|
GOOGLE_CHECK(file.is_open()) << "Couldn't find file '" << name <<
|
||||||
|
"', please make sure you are running "
|
||||||
|
"this command from the benchmarks/ "
|
||||||
|
"directory.\n";
|
||||||
|
return std::string((std::istreambuf_iterator<char>(file)),
|
||||||
|
std::istreambuf_iterator<char>());
|
||||||
|
}
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
void RegisterBenchmarksForType(const BenchmarkDataset& dataset) {
|
||||||
|
::benchmark::internal::RegisterBenchmarkInternal(
|
||||||
|
new ParseNewFixture<T>(dataset));
|
||||||
|
::benchmark::internal::RegisterBenchmarkInternal(
|
||||||
|
new ParseReuseFixture<T>(dataset));
|
||||||
|
::benchmark::internal::RegisterBenchmarkInternal(
|
||||||
|
new ParseNewArenaFixture<T>(dataset));
|
||||||
|
::benchmark::internal::RegisterBenchmarkInternal(
|
||||||
|
new SerializeFixture<T>(dataset));
|
||||||
|
}
|
||||||
|
|
||||||
|
void RegisterBenchmarks(const std::string& dataset_bytes) {
|
||||||
|
BenchmarkDataset dataset;
|
||||||
|
GOOGLE_CHECK(dataset.ParseFromString(dataset_bytes));
|
||||||
|
|
||||||
|
if (dataset.message_name() == "benchmarks.proto3.GoogleMessage1") {
|
||||||
|
RegisterBenchmarksForType<benchmarks::proto3::GoogleMessage1>(dataset);
|
||||||
|
} else if (dataset.message_name() == "benchmarks.proto2.GoogleMessage1") {
|
||||||
|
RegisterBenchmarksForType<benchmarks::proto2::GoogleMessage1>(dataset);
|
||||||
|
} else if (dataset.message_name() == "benchmarks.proto2.GoogleMessage2") {
|
||||||
|
RegisterBenchmarksForType<benchmarks::proto2::GoogleMessage2>(dataset);
|
||||||
|
} else {
|
||||||
|
std::cerr << "Unknown message type: " << dataset.message_name();
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
glob_t glob_result;
|
||||||
|
if (glob("dataset.*.pb", 0, NULL, &glob_result) != 0) {
|
||||||
|
fprintf(stderr, "No dataset files found.\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < glob_result.gl_pathc; i++) {
|
||||||
|
fprintf(stderr, "Found input dataset: %s\n", glob_result.gl_pathv[i]);
|
||||||
|
RegisterBenchmarks(ReadFile(glob_result.gl_pathv[i]));
|
||||||
|
}
|
||||||
|
|
||||||
|
::benchmark::Initialize(&argc, argv);
|
||||||
|
::benchmark::RunSpecifiedBenchmarks();
|
||||||
|
}
|
|
@ -22,29 +22,25 @@ Running a benchmark (Java)
|
||||||
$ javac -d tmp -cp protobuf.jar ProtoBench.java
|
$ javac -d tmp -cp protobuf.jar ProtoBench.java
|
||||||
|
|
||||||
3) Generate code for the relevant benchmark protocol buffer, e.g.
|
3) Generate code for the relevant benchmark protocol buffer, e.g.
|
||||||
$ protoc --java_out=tmp google_size.proto google_speed.proto
|
$ protoc --java_out=tmp google_size.proto
|
||||||
|
|
||||||
4) Build the generated code, e.g.
|
4) Build the generated code, e.g.
|
||||||
$ cd tmp
|
$ javac -d tmp -cp protobuf.jar tmp/benchmarks/*.java
|
||||||
$ javac -d . -cp ../protobuf.jar benchmarks/*.java
|
|
||||||
|
|
||||||
5) Run the test. Arguments are given in pairs - the first argument
|
5) Run the test. Arguments are given in pairs - the first argument
|
||||||
is the descriptor type; the second is the filename. For example:
|
is the descriptor type; the second is the filename. For example:
|
||||||
$ java -cp .;../protobuf.jar com.google.protocolbuffers.ProtoBench
|
$ java -cp tmp:protobuf.jar com.google.protocolbuffers.ProtoBench \
|
||||||
benchmarks.GoogleSize$SizeMessage1 ../google_message1.dat
|
'benchmarks.GoogleSize$SizeMessage1' google_message1.dat \
|
||||||
benchmarks.GoogleSpeed$SpeedMessage1 ../google_message1.dat
|
'benchmarks.GoogleSize$SizeMessage2' google_message2.dat
|
||||||
benchmarks.GoogleSize$SizeMessage2 ../google_message2.dat
|
|
||||||
benchmarks.GoogleSpeed$SpeedMessage2 ../google_message2.dat
|
|
||||||
|
|
||||||
6) Wait! Each test runs for around 30 seconds, and there are 6 tests
|
6) Wait! Each test runs for around 30 seconds, and there are 8 tests
|
||||||
per class/data combination. The above command would therefore take
|
per class/data combination. The above command would therefore take
|
||||||
about 12 minutes to run.
|
about 8 minutes to run.
|
||||||
|
|
||||||
|
|
||||||
Benchmarks available
|
Benchmarks available
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
From Google:
|
From Google:
|
||||||
google_size.proto and google_speed.proto, messages
|
google_size.proto,
|
||||||
google_message1.dat and google_message2.dat. The proto files are
|
messages google_message1.dat and google_message2.dat.
|
||||||
equivalent, but optimized differently.
|
|
||||||
|
|
|
@ -1,22 +1,28 @@
|
||||||
# Minimum CMake required
|
# Minimum CMake required
|
||||||
cmake_minimum_required(VERSION 2.8)
|
cmake_minimum_required(VERSION 2.8.12)
|
||||||
|
|
||||||
# Project
|
if(protobuf_VERBOSE)
|
||||||
project(protobuf C CXX)
|
message(STATUS "Protocol Buffers Configuring...")
|
||||||
|
endif()
|
||||||
|
|
||||||
# CMake policies
|
# CMake policies
|
||||||
cmake_policy(SET CMP0022 NEW)
|
cmake_policy(SET CMP0022 NEW)
|
||||||
|
|
||||||
|
# Project
|
||||||
|
project(protobuf C CXX)
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
option(protobuf_VERBOSE "Enable for verbose output" OFF)
|
|
||||||
option(protobuf_BUILD_TESTS "Build tests" ON)
|
option(protobuf_BUILD_TESTS "Build tests" ON)
|
||||||
|
option(protobuf_BUILD_EXAMPLES "Build examples" OFF)
|
||||||
if (BUILD_SHARED_LIBS)
|
if (BUILD_SHARED_LIBS)
|
||||||
set(protobuf_BUILD_SHARED_LIBS_DEFAULT ON)
|
set(protobuf_BUILD_SHARED_LIBS_DEFAULT ON)
|
||||||
else (BUILD_SHARED_LIBS)
|
else (BUILD_SHARED_LIBS)
|
||||||
set(protobuf_BUILD_SHARED_LIBS_DEFAULT OFF)
|
set(protobuf_BUILD_SHARED_LIBS_DEFAULT OFF)
|
||||||
endif (BUILD_SHARED_LIBS)
|
endif (BUILD_SHARED_LIBS)
|
||||||
option(protobuf_BUILD_SHARED_LIBS "Build Shared Libraries" ${protobuf_BUILD_SHARED_LIBS_DEFAULT})
|
option(protobuf_BUILD_SHARED_LIBS "Build Shared Libraries" ${protobuf_BUILD_SHARED_LIBS_DEFAULT})
|
||||||
option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON)
|
include(CMakeDependentOption)
|
||||||
|
cmake_dependent_option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON
|
||||||
|
"NOT protobuf_BUILD_SHARED_LIBS" OFF)
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
set(protobuf_WITH_ZLIB_DEFAULT OFF)
|
set(protobuf_WITH_ZLIB_DEFAULT OFF)
|
||||||
else (MSVC)
|
else (MSVC)
|
||||||
|
@ -25,6 +31,9 @@ endif (MSVC)
|
||||||
option(protobuf_WITH_ZLIB "Build with zlib support" ${protobuf_WITH_ZLIB_DEFAULT})
|
option(protobuf_WITH_ZLIB "Build with zlib support" ${protobuf_WITH_ZLIB_DEFAULT})
|
||||||
set(protobuf_DEBUG_POSTFIX "d"
|
set(protobuf_DEBUG_POSTFIX "d"
|
||||||
CACHE STRING "Default debug postfix")
|
CACHE STRING "Default debug postfix")
|
||||||
|
mark_as_advanced(protobuf_DEBUG_POSTFIX)
|
||||||
|
# User options
|
||||||
|
include(protobuf-options.cmake)
|
||||||
|
|
||||||
# Path to main configure script
|
# Path to main configure script
|
||||||
set(protobuf_CONFIGURE_SCRIPT "../configure.ac")
|
set(protobuf_CONFIGURE_SCRIPT "../configure.ac")
|
||||||
|
@ -44,17 +53,24 @@ string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\2"
|
||||||
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\3"
|
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\3"
|
||||||
protobuf_CONTACT "${protobuf_AC_INIT_LINE}")
|
protobuf_CONTACT "${protobuf_AC_INIT_LINE}")
|
||||||
# Parse version tweaks
|
# Parse version tweaks
|
||||||
set(protobuf_VERSION_REGEX "^([0-9]+)\\.([0-9]+)\\.([0-9]+).*$")
|
set(protobuf_VERSION_REGEX "^([0-9]+)\\.([0-9]+)\\.([0-9]+)-?(.*)$")
|
||||||
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\1"
|
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\1"
|
||||||
protobuf_VERSION_MAJOR "${protobuf_VERSION_STRING}")
|
protobuf_VERSION_MAJOR "${protobuf_VERSION_STRING}")
|
||||||
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\2"
|
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\2"
|
||||||
protobuf_VERSION_MINOR "${protobuf_VERSION_STRING}")
|
protobuf_VERSION_MINOR "${protobuf_VERSION_STRING}")
|
||||||
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\3"
|
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\3"
|
||||||
protobuf_VERSION_PATCH "${protobuf_VERSION_STRING}")
|
protobuf_VERSION_PATCH "${protobuf_VERSION_STRING}")
|
||||||
|
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\4"
|
||||||
|
protobuf_VERSION_PRERELEASE "${protobuf_VERSION_STRING}")
|
||||||
|
|
||||||
# Package version
|
# Package version
|
||||||
set(protobuf_VERSION
|
set(protobuf_VERSION
|
||||||
"${protobuf_VERSION_MAJOR}.${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}")
|
"${protobuf_VERSION_MAJOR}.${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}")
|
||||||
|
|
||||||
|
if(protobuf_VERSION_PRERELEASE)
|
||||||
|
set(protobuf_VERSION "${protobuf_VERSION}-${protobuf_VERSION_PRERELEASE}")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(protobuf_VERBOSE)
|
if(protobuf_VERBOSE)
|
||||||
message(STATUS "Configuration script parsing status [")
|
message(STATUS "Configuration script parsing status [")
|
||||||
message(STATUS " Description : ${protobuf_DESCRIPTION}")
|
message(STATUS " Description : ${protobuf_DESCRIPTION}")
|
||||||
|
@ -70,6 +86,7 @@ if (CMAKE_USE_PTHREADS_INIT)
|
||||||
add_definitions(-DHAVE_PTHREAD)
|
add_definitions(-DHAVE_PTHREAD)
|
||||||
endif (CMAKE_USE_PTHREADS_INIT)
|
endif (CMAKE_USE_PTHREADS_INIT)
|
||||||
|
|
||||||
|
set(_protobuf_FIND_ZLIB)
|
||||||
if (protobuf_WITH_ZLIB)
|
if (protobuf_WITH_ZLIB)
|
||||||
find_package(ZLIB)
|
find_package(ZLIB)
|
||||||
if (ZLIB_FOUND)
|
if (ZLIB_FOUND)
|
||||||
|
@ -80,6 +97,7 @@ if (protobuf_WITH_ZLIB)
|
||||||
# Using imported target if exists
|
# Using imported target if exists
|
||||||
if (TARGET ZLIB::ZLIB)
|
if (TARGET ZLIB::ZLIB)
|
||||||
set(ZLIB_LIBRARIES ZLIB::ZLIB)
|
set(ZLIB_LIBRARIES ZLIB::ZLIB)
|
||||||
|
set(_protobuf_FIND_ZLIB "if(NOT ZLIB_FOUND)\n find_package(ZLIB)\nendif()")
|
||||||
endif (TARGET ZLIB::ZLIB)
|
endif (TARGET ZLIB::ZLIB)
|
||||||
else (ZLIB_FOUND)
|
else (ZLIB_FOUND)
|
||||||
set(HAVE_ZLIB 0)
|
set(HAVE_ZLIB 0)
|
||||||
|
@ -117,7 +135,7 @@ endif (protobuf_BUILD_SHARED_LIBS)
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
# Build with multiple processes
|
# Build with multiple processes
|
||||||
add_definitions(/MP)
|
add_definitions(/MP)
|
||||||
add_definitions(/wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305)
|
add_definitions(/wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 /wd4305 /wd4309)
|
||||||
# Allow big object
|
# Allow big object
|
||||||
add_definitions(/bigobj)
|
add_definitions(/bigobj)
|
||||||
string(REPLACE "/" "\\" PROTOBUF_SOURCE_WIN32_PATH ${protobuf_SOURCE_DIR})
|
string(REPLACE "/" "\\" PROTOBUF_SOURCE_WIN32_PATH ${protobuf_SOURCE_DIR})
|
||||||
|
@ -141,6 +159,10 @@ else (MSVC)
|
||||||
set(LIB_PREFIX)
|
set(LIB_PREFIX)
|
||||||
endif (MSVC)
|
endif (MSVC)
|
||||||
|
|
||||||
|
if (protobuf_UNICODE)
|
||||||
|
add_definitions(-DUNICODE -D_UNICODE)
|
||||||
|
endif (protobuf_UNICODE)
|
||||||
|
|
||||||
include(libprotobuf-lite.cmake)
|
include(libprotobuf-lite.cmake)
|
||||||
include(libprotobuf.cmake)
|
include(libprotobuf.cmake)
|
||||||
include(libprotoc.cmake)
|
include(libprotoc.cmake)
|
||||||
|
@ -151,3 +173,11 @@ if (protobuf_BUILD_TESTS)
|
||||||
endif (protobuf_BUILD_TESTS)
|
endif (protobuf_BUILD_TESTS)
|
||||||
|
|
||||||
include(install.cmake)
|
include(install.cmake)
|
||||||
|
|
||||||
|
if (protobuf_BUILD_EXAMPLES)
|
||||||
|
include(examples.cmake)
|
||||||
|
endif (protobuf_BUILD_EXAMPLES)
|
||||||
|
|
||||||
|
if(protobuf_VERBOSE)
|
||||||
|
message(STATUS "Protocol Buffers Configuring done")
|
||||||
|
endif()
|
||||||
|
|
|
@ -0,0 +1,57 @@
|
||||||
|
if(protobuf_VERBOSE)
|
||||||
|
message(STATUS "Protocol Buffers Examples Configuring...")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
get_filename_component(examples_dir "../examples" ABSOLUTE)
|
||||||
|
|
||||||
|
if(protobuf_VERBOSE)
|
||||||
|
message(STATUS "Protocol Buffers Examples Configuring done")
|
||||||
|
endif()
|
||||||
|
include(ExternalProject)
|
||||||
|
|
||||||
|
# Internal utility function: Create a custom target representing a build of examples with custom options.
|
||||||
|
function(add_examples_build NAME)
|
||||||
|
|
||||||
|
ExternalProject_Add(${NAME}
|
||||||
|
PREFIX ${NAME}
|
||||||
|
SOURCE_DIR "${examples_dir}"
|
||||||
|
BINARY_DIR ${NAME}
|
||||||
|
STAMP_DIR ${NAME}/logs
|
||||||
|
INSTALL_COMMAND "" #Skip
|
||||||
|
LOG_CONFIGURE 1
|
||||||
|
CMAKE_CACHE_ARGS "-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}"
|
||||||
|
"-Dprotobuf_VERBOSE:BOOL=${protobuf_VERBOSE}"
|
||||||
|
${ARGN}
|
||||||
|
)
|
||||||
|
set_property(TARGET ${NAME} PROPERTY FOLDER "Examples")
|
||||||
|
set_property(TARGET ${NAME} PROPERTY EXCLUDE_FROM_ALL TRUE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Add examples as an external project.
|
||||||
|
# sub_directory cannot be used because the find_package(protobuf) call would cause failures with redefined targets.
|
||||||
|
add_examples_build(examples "-Dprotobuf_DIR:PATH=${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}")
|
||||||
|
add_dependencies(examples libprotobuf protoc)
|
||||||
|
|
||||||
|
option(protobuf_BUILD_EXAMPLES_MULTITEST "Build Examples in multiple configurations. Useful for testing." OFF)
|
||||||
|
mark_as_advanced(protobuf_BUILD_EXAMPLES_MULTITEST)
|
||||||
|
if(protobuf_BUILD_EXAMPLES_MULTITEST)
|
||||||
|
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
|
||||||
|
|
||||||
|
#Build using the legacy compatibility module.
|
||||||
|
add_examples_build(examples-legacy
|
||||||
|
"-Dprotobuf_DIR:PATH=${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}"
|
||||||
|
"-Dprotobuf_MODULE_COMPATIBLE:BOOL=TRUE"
|
||||||
|
)
|
||||||
|
add_dependencies(examples-legacy libprotobuf protoc)
|
||||||
|
|
||||||
|
#Build using the installed library.
|
||||||
|
add_examples_build(examples-installed
|
||||||
|
"-Dprotobuf_DIR:PATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_CMAKEDIR}"
|
||||||
|
)
|
||||||
|
|
||||||
|
#Build using the installed library in legacy compatibility mode.
|
||||||
|
add_examples_build(examples-installed-legacy
|
||||||
|
"-Dprotobuf_DIR:PATH=${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_CMAKEDIR}"
|
||||||
|
"-Dprotobuf_MODULE_COMPATIBLE:BOOL=TRUE"
|
||||||
|
)
|
||||||
|
endif()
|
|
@ -8,117 +8,125 @@ mkdir include\google\protobuf\compiler\java
|
||||||
mkdir include\google\protobuf\compiler\javanano
|
mkdir include\google\protobuf\compiler\javanano
|
||||||
mkdir include\google\protobuf\compiler\js
|
mkdir include\google\protobuf\compiler\js
|
||||||
mkdir include\google\protobuf\compiler\objectivec
|
mkdir include\google\protobuf\compiler\objectivec
|
||||||
|
mkdir include\google\protobuf\compiler\php
|
||||||
mkdir include\google\protobuf\compiler\python
|
mkdir include\google\protobuf\compiler\python
|
||||||
mkdir include\google\protobuf\compiler\ruby
|
mkdir include\google\protobuf\compiler\ruby
|
||||||
mkdir include\google\protobuf\io
|
mkdir include\google\protobuf\io
|
||||||
mkdir include\google\protobuf\stubs
|
mkdir include\google\protobuf\stubs
|
||||||
mkdir include\google\protobuf\util
|
mkdir include\google\protobuf\util
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.h include\google\protobuf\any.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.h" include\google\protobuf\any.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.pb.h include\google\protobuf\any.pb.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\any.pb.h" include\google\protobuf\any.pb.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\api.pb.h include\google\protobuf\api.pb.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\api.pb.h" include\google\protobuf\api.pb.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arena.h include\google\protobuf\arena.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arena.h" include\google\protobuf\arena.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arenastring.h include\google\protobuf\arenastring.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\arenastring.h" include\google\protobuf\arenastring.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\code_generator.h include\google\protobuf\compiler\code_generator.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\code_generator.h" include\google\protobuf\compiler\code_generator.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\command_line_interface.h include\google\protobuf\compiler\command_line_interface.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\command_line_interface.h" include\google\protobuf\compiler\command_line_interface.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\cpp_generator.h include\google\protobuf\compiler\cpp\cpp_generator.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\cpp\cpp_generator.h" include\google\protobuf\compiler\cpp\cpp_generator.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_generator.h include\google\protobuf\compiler\csharp\csharp_generator.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_generator.h" include\google\protobuf\compiler\csharp\csharp_generator.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_names.h include\google\protobuf\compiler\csharp\csharp_names.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\csharp\csharp_names.h" include\google\protobuf\compiler\csharp\csharp_names.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\importer.h include\google\protobuf\compiler\importer.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\importer.h" include\google\protobuf\compiler\importer.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_generator.h include\google\protobuf\compiler\java\java_generator.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_generator.h" include\google\protobuf\compiler\java\java_generator.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_names.h include\google\protobuf\compiler\java\java_names.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\java\java_names.h" include\google\protobuf\compiler\java\java_names.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\javanano\javanano_generator.h include\google\protobuf\compiler\javanano\javanano_generator.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\javanano\javanano_generator.h" include\google\protobuf\compiler\javanano\javanano_generator.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\js\js_generator.h include\google\protobuf\compiler\js\js_generator.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\js\js_generator.h" include\google\protobuf\compiler\js\js_generator.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_generator.h include\google\protobuf\compiler\objectivec\objectivec_generator.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\js\well_known_types_embed.h" include\google\protobuf\compiler\js\well_known_types_embed.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_helpers.h include\google\protobuf\compiler\objectivec\objectivec_helpers.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_generator.h" include\google\protobuf\compiler\objectivec\objectivec_generator.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\parser.h include\google\protobuf\compiler\parser.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\objectivec\objectivec_helpers.h" include\google\protobuf\compiler\objectivec\objectivec_helpers.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.h include\google\protobuf\compiler\plugin.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\parser.h" include\google\protobuf\compiler\parser.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.pb.h include\google\protobuf\compiler\plugin.pb.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\php\php_generator.h" include\google\protobuf\compiler\php\php_generator.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\python\python_generator.h include\google\protobuf\compiler\python\python_generator.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.h" include\google\protobuf\compiler\plugin.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\ruby\ruby_generator.h include\google\protobuf\compiler\ruby\ruby_generator.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\plugin.pb.h" include\google\protobuf\compiler\plugin.pb.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.h include\google\protobuf\descriptor.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\profile.pb.h" include\google\protobuf\compiler\profile.pb.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.pb.h include\google\protobuf\descriptor.pb.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\python\python_generator.h" include\google\protobuf\compiler\python\python_generator.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor_database.h include\google\protobuf\descriptor_database.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\compiler\ruby\ruby_generator.h" include\google\protobuf\compiler\ruby\ruby_generator.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\duration.pb.h include\google\protobuf\duration.pb.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.h" include\google\protobuf\descriptor.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\dynamic_message.h include\google\protobuf\dynamic_message.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor.pb.h" include\google\protobuf\descriptor.pb.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\empty.pb.h include\google\protobuf\empty.pb.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\descriptor_database.h" include\google\protobuf\descriptor_database.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\extension_set.h include\google\protobuf\extension_set.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\duration.pb.h" include\google\protobuf\duration.pb.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\field_mask.pb.h include\google\protobuf\field_mask.pb.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\dynamic_message.h" include\google\protobuf\dynamic_message.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_reflection.h include\google\protobuf\generated_enum_reflection.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\empty.pb.h" include\google\protobuf\empty.pb.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_util.h include\google\protobuf\generated_enum_util.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\extension_set.h" include\google\protobuf\extension_set.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_reflection.h include\google\protobuf\generated_message_reflection.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\field_mask.pb.h" include\google\protobuf\field_mask.pb.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_util.h include\google\protobuf\generated_message_util.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_reflection.h" include\google\protobuf\generated_enum_reflection.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\coded_stream.h include\google\protobuf\io\coded_stream.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_enum_util.h" include\google\protobuf\generated_enum_util.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\gzip_stream.h include\google\protobuf\io\gzip_stream.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_reflection.h" include\google\protobuf\generated_message_reflection.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\printer.h include\google\protobuf\io\printer.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_table_driven.h" include\google\protobuf\generated_message_table_driven.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\strtod.h include\google\protobuf\io\strtod.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_util.h" include\google\protobuf\generated_message_util.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\tokenizer.h include\google\protobuf\io\tokenizer.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\generated_message_table_driven.h" include\google\protobuf\generated_message_table_driven.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream.h include\google\protobuf\io\zero_copy_stream.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\has_bits.h" include\google\protobuf\has_bits.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream_impl.h include\google\protobuf\io\zero_copy_stream_impl.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\coded_stream.h" include\google\protobuf\io\coded_stream.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream_impl_lite.h include\google\protobuf\io\zero_copy_stream_impl_lite.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\gzip_stream.h" include\google\protobuf\io\gzip_stream.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map.h include\google\protobuf\map.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\printer.h" include\google\protobuf\io\printer.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_entry.h include\google\protobuf\map_entry.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\strtod.h" include\google\protobuf\io\strtod.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_entry_lite.h include\google\protobuf\map_entry_lite.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\tokenizer.h" include\google\protobuf\io\tokenizer.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field.h include\google\protobuf\map_field.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream.h" include\google\protobuf\io\zero_copy_stream.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field_inl.h include\google\protobuf\map_field_inl.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream_impl.h" include\google\protobuf\io\zero_copy_stream_impl.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field_lite.h include\google\protobuf\map_field_lite.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\io\zero_copy_stream_impl_lite.h" include\google\protobuf\io\zero_copy_stream_impl_lite.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_type_handler.h include\google\protobuf\map_type_handler.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map.h" include\google\protobuf\map.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\message.h include\google\protobuf\message.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_entry.h" include\google\protobuf\map_entry.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\message_lite.h include\google\protobuf\message_lite.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_entry_lite.h" include\google\protobuf\map_entry_lite.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\metadata.h include\google\protobuf\metadata.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field.h" include\google\protobuf\map_field.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\reflection.h include\google\protobuf\reflection.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field_inl.h" include\google\protobuf\map_field_inl.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\reflection_ops.h include\google\protobuf\reflection_ops.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_field_lite.h" include\google\protobuf\map_field_lite.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\repeated_field.h include\google\protobuf\repeated_field.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\map_type_handler.h" include\google\protobuf\map_type_handler.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\repeated_field_reflection.h include\google\protobuf\repeated_field_reflection.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\message.h" include\google\protobuf\message.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\service.h include\google\protobuf\service.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\message_lite.h" include\google\protobuf\message_lite.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\source_context.pb.h include\google\protobuf\source_context.pb.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\metadata.h" include\google\protobuf\metadata.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\struct.pb.h include\google\protobuf\struct.pb.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\metadata_lite.h" include\google\protobuf\metadata_lite.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomic_sequence_num.h include\google\protobuf\stubs\atomic_sequence_num.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\reflection.h" include\google\protobuf\reflection.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops.h include\google\protobuf\stubs\atomicops.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\reflection_ops.h" include\google\protobuf\reflection_ops.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm64_gcc.h include\google\protobuf\stubs\atomicops_internals_arm64_gcc.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\repeated_field.h" include\google\protobuf\repeated_field.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm_gcc.h include\google\protobuf\stubs\atomicops_internals_arm_gcc.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\service.h" include\google\protobuf\service.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm_qnx.h include\google\protobuf\stubs\atomicops_internals_arm_qnx.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\source_context.pb.h" include\google\protobuf\source_context.pb.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_atomicword_compat.h include\google\protobuf\stubs\atomicops_internals_atomicword_compat.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\struct.pb.h" include\google\protobuf\struct.pb.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_generic_gcc.h include\google\protobuf\stubs\atomicops_internals_generic_gcc.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomic_sequence_num.h" include\google\protobuf\stubs\atomic_sequence_num.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_macosx.h include\google\protobuf\stubs\atomicops_internals_macosx.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops.h" include\google\protobuf\stubs\atomicops.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_mips_gcc.h include\google\protobuf\stubs\atomicops_internals_mips_gcc.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm64_gcc.h" include\google\protobuf\stubs\atomicops_internals_arm64_gcc.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_pnacl.h include\google\protobuf\stubs\atomicops_internals_pnacl.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm_gcc.h" include\google\protobuf\stubs\atomicops_internals_arm_gcc.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_power.h include\google\protobuf\stubs\atomicops_internals_power.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_arm_qnx.h" include\google\protobuf\stubs\atomicops_internals_arm_qnx.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_solaris.h include\google\protobuf\stubs\atomicops_internals_solaris.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_atomicword_compat.h" include\google\protobuf\stubs\atomicops_internals_atomicword_compat.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_tsan.h include\google\protobuf\stubs\atomicops_internals_tsan.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_generic_c11_atomic.h" include\google\protobuf\stubs\atomicops_internals_generic_c11_atomic.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_x86_gcc.h include\google\protobuf\stubs\atomicops_internals_x86_gcc.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_generic_gcc.h" include\google\protobuf\stubs\atomicops_internals_generic_gcc.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_x86_msvc.h include\google\protobuf\stubs\atomicops_internals_x86_msvc.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_mips_gcc.h" include\google\protobuf\stubs\atomicops_internals_mips_gcc.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\bytestream.h include\google\protobuf\stubs\bytestream.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_power.h" include\google\protobuf\stubs\atomicops_internals_power.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\callback.h include\google\protobuf\stubs\callback.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_ppc_gcc.h" include\google\protobuf\stubs\atomicops_internals_ppc_gcc.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\casts.h include\google\protobuf\stubs\casts.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_solaris.h" include\google\protobuf\stubs\atomicops_internals_solaris.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\common.h include\google\protobuf\stubs\common.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_tsan.h" include\google\protobuf\stubs\atomicops_internals_tsan.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\atomicops_internals_x86_gcc.h" include\google\protobuf\stubs\atomicops_internals_x86_gcc.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\atomicops_internals_x86_msvc.h" include\google\protobuf\stubs\atomicops_internals_x86_msvc.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\logging.h include\google\protobuf\stubs\logging.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\bytestream.h" include\google\protobuf\stubs\bytestream.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\macros.h include\google\protobuf\stubs\macros.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\callback.h" include\google\protobuf\stubs\callback.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\mutex.h include\google\protobuf\stubs\mutex.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\casts.h" include\google\protobuf\stubs\casts.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\common.h" include\google\protobuf\stubs\common.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\fastmem.h" include\google\protobuf\stubs\fastmem.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\port.h include\google\protobuf\stubs\port.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\scoped_ptr.h include\google\protobuf\stubs\scoped_ptr.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\logging.h" include\google\protobuf\stubs\logging.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\macros.h" include\google\protobuf\stubs\macros.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\mutex.h" include\google\protobuf\stubs\mutex.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\status.h include\google\protobuf\stubs\status.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\stl_util.h include\google\protobuf\stubs\stl_util.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\stringpiece.h include\google\protobuf\stubs\stringpiece.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\port.h" include\google\protobuf\stubs\port.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\template_util.h include\google\protobuf\stubs\template_util.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\scoped_ptr.h" include\google\protobuf\stubs\scoped_ptr.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\type_traits.h include\google\protobuf\stubs\type_traits.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\text_format.h include\google\protobuf\text_format.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\timestamp.pb.h include\google\protobuf\timestamp.pb.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\status.h" include\google\protobuf\stubs\status.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\type.pb.h include\google\protobuf\type.pb.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\stl_util.h" include\google\protobuf\stubs\stl_util.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\unknown_field_set.h include\google\protobuf\unknown_field_set.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\stringpiece.h" include\google\protobuf\stubs\stringpiece.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\field_comparator.h include\google\protobuf\util\field_comparator.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\template_util.h" include\google\protobuf\stubs\template_util.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\field_mask_util.h include\google\protobuf\util\field_mask_util.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\type_traits.h" include\google\protobuf\stubs\type_traits.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\json_util.h include\google\protobuf\util\json_util.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\text_format.h" include\google\protobuf\text_format.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\message_differencer.h include\google\protobuf\util\message_differencer.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\timestamp.pb.h" include\google\protobuf\timestamp.pb.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\time_util.h include\google\protobuf\util\time_util.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\type.pb.h" include\google\protobuf\type.pb.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\type_resolver.h include\google\protobuf\util\type_resolver.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\unknown_field_set.h" include\google\protobuf\unknown_field_set.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\type_resolver_util.h include\google\protobuf\util\type_resolver_util.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\delimited_message_util.h" include\google\protobuf\util\delimited_message_util.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format.h include\google\protobuf\wire_format.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\field_comparator.h" include\google\protobuf\util\field_comparator.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format_lite.h include\google\protobuf\wire_format_lite.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\field_mask_util.h" include\google\protobuf\util\field_mask_util.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format_lite_inl.h include\google\protobuf\wire_format_lite_inl.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\json_util.h" include\google\protobuf\util\json_util.h
|
||||||
copy ${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wrappers.pb.h include\google\protobuf\wrappers.pb.h
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\message_differencer.h" include\google\protobuf\util\message_differencer.h
|
||||||
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\time_util.h" include\google\protobuf\util\time_util.h
|
||||||
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\type_resolver.h" include\google\protobuf\util\type_resolver.h
|
||||||
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\util\type_resolver_util.h" include\google\protobuf\util\type_resolver_util.h
|
||||||
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format.h" include\google\protobuf\wire_format.h
|
||||||
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format_lite.h" include\google\protobuf\wire_format_lite.h
|
||||||
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wire_format_lite_inl.h" include\google\protobuf\wire_format_lite_inl.h
|
||||||
|
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\wrappers.pb.h" include\google\protobuf\wrappers.pb.h
|
||||||
|
|
|
@ -6,6 +6,7 @@ foreach(_library
|
||||||
libprotoc)
|
libprotoc)
|
||||||
set_property(TARGET ${_library}
|
set_property(TARGET ${_library}
|
||||||
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
|
||||||
|
$<BUILD_INTERFACE:${protobuf_source_dir}/src>
|
||||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||||
install(TARGETS ${_library} EXPORT protobuf-targets
|
install(TARGETS ${_library} EXPORT protobuf-targets
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${_library}
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${_library}
|
||||||
|
@ -16,34 +17,26 @@ endforeach()
|
||||||
install(TARGETS protoc EXPORT protobuf-targets
|
install(TARGETS protoc EXPORT protobuf-targets
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc)
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc)
|
||||||
|
|
||||||
if(TRUE)
|
file(STRINGS extract_includes.bat.in _extract_strings
|
||||||
file(STRINGS extract_includes.bat.in _extract_strings
|
REGEX "^copy")
|
||||||
REGEX "^copy")
|
foreach(_extract_string ${_extract_strings})
|
||||||
foreach(_extract_string ${_extract_strings})
|
string(REGEX REPLACE "^.* .+ include\\\\(.+)$" "\\1"
|
||||||
string(REPLACE "copy \${PROTOBUF_SOURCE_WIN32_PATH}\\" ""
|
_header ${_extract_string})
|
||||||
_extract_string ${_extract_string})
|
string(REPLACE "\\" "/" _header ${_header})
|
||||||
string(REPLACE "\\" "/" _extract_string ${_extract_string})
|
get_filename_component(_extract_from "${protobuf_SOURCE_DIR}/../src/${_header}" ABSOLUTE)
|
||||||
string(REGEX MATCH "^[^ ]+"
|
get_filename_component(_extract_name ${_header} NAME)
|
||||||
_extract_from ${_extract_string})
|
get_filename_component(_extract_to "${CMAKE_INSTALL_INCLUDEDIR}/${_header}" PATH)
|
||||||
string(REGEX REPLACE "^${_extract_from} ([^$]+)" "\\1"
|
if(EXISTS "${_extract_from}")
|
||||||
_extract_to ${_extract_string})
|
install(FILES "${_extract_from}"
|
||||||
get_filename_component(_extract_from "${protobuf_SOURCE_DIR}/${_extract_from}" ABSOLUTE)
|
DESTINATION "${_extract_to}"
|
||||||
get_filename_component(_extract_name ${_extract_to} NAME)
|
COMPONENT protobuf-headers
|
||||||
get_filename_component(_extract_to ${_extract_to} PATH)
|
RENAME "${_extract_name}")
|
||||||
string(REPLACE "include/" "${CMAKE_INSTALL_INCLUDEDIR}/"
|
else()
|
||||||
_extract_to "${_extract_to}")
|
message(AUTHOR_WARNING "The file \"${_extract_from}\" is listed in "
|
||||||
if(EXISTS "${_extract_from}")
|
"\"${protobuf_SOURCE_DIR}/cmake/extract_includes.bat.in\" "
|
||||||
install(FILES "${_extract_from}"
|
"but there not exists. The file will not be installed.")
|
||||||
DESTINATION "${_extract_to}"
|
endif()
|
||||||
COMPONENT protobuf-headers
|
endforeach()
|
||||||
RENAME "${_extract_name}")
|
|
||||||
else()
|
|
||||||
message(AUTHOR_WARNING "The file \"${_extract_from}\" is listed in "
|
|
||||||
"\"${protobuf_SOURCE_DIR}/cmake/extract_includes.bat.in\" "
|
|
||||||
"but there not exists. The file will not be installed.")
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Internal function for parsing auto tools scripts
|
# Internal function for parsing auto tools scripts
|
||||||
function(_protobuf_auto_list FILE_NAME VARIABLE)
|
function(_protobuf_auto_list FILE_NAME VARIABLE)
|
||||||
|
@ -82,22 +75,43 @@ foreach(_file ${nobase_dist_proto_DATA})
|
||||||
endif()
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
# Export configuration
|
# Install configuration
|
||||||
|
set(_cmakedir_desc "Directory relative to CMAKE_INSTALL to install the cmake configuration files")
|
||||||
install(EXPORT protobuf-targets
|
if(NOT MSVC)
|
||||||
DESTINATION "lib/cmake/protobuf"
|
set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/protobuf" CACHE STRING "${_cmakedir_desc}")
|
||||||
COMPONENT protobuf-export)
|
else()
|
||||||
|
set(CMAKE_INSTALL_CMAKEDIR "cmake" CACHE STRING "${_cmakedir_desc}")
|
||||||
|
endif()
|
||||||
|
mark_as_advanced(CMAKE_INSTALL_CMAKEDIR)
|
||||||
|
|
||||||
configure_file(protobuf-config.cmake.in
|
configure_file(protobuf-config.cmake.in
|
||||||
protobuf-config.cmake @ONLY)
|
${CMAKE_INSTALL_CMAKEDIR}/protobuf-config.cmake @ONLY)
|
||||||
configure_file(protobuf-config-version.cmake.in
|
configure_file(protobuf-config-version.cmake.in
|
||||||
protobuf-config-version.cmake @ONLY)
|
${CMAKE_INSTALL_CMAKEDIR}/protobuf-config-version.cmake @ONLY)
|
||||||
configure_file(protobuf-module.cmake.in
|
configure_file(protobuf-module.cmake.in
|
||||||
protobuf-module.cmake @ONLY)
|
${CMAKE_INSTALL_CMAKEDIR}/protobuf-module.cmake @ONLY)
|
||||||
|
configure_file(protobuf-options.cmake
|
||||||
|
${CMAKE_INSTALL_CMAKEDIR}/protobuf-options.cmake @ONLY)
|
||||||
|
|
||||||
install(FILES
|
# Allows the build directory to be used as a find directory.
|
||||||
"${protobuf_BINARY_DIR}/protobuf-config.cmake"
|
export(TARGETS libprotobuf-lite libprotobuf libprotoc protoc
|
||||||
"${protobuf_BINARY_DIR}/protobuf-config-version.cmake"
|
NAMESPACE protobuf::
|
||||||
"${protobuf_BINARY_DIR}/protobuf-module.cmake"
|
FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
|
||||||
DESTINATION "lib/cmake/protobuf"
|
)
|
||||||
|
|
||||||
|
install(EXPORT protobuf-targets
|
||||||
|
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
|
||||||
|
NAMESPACE protobuf::
|
||||||
COMPONENT protobuf-export)
|
COMPONENT protobuf-export)
|
||||||
|
|
||||||
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_CMAKEDIR}/
|
||||||
|
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
|
||||||
|
COMPONENT protobuf-export
|
||||||
|
PATTERN protobuf-targets.cmake EXCLUDE
|
||||||
|
)
|
||||||
|
|
||||||
|
option(protobuf_INSTALL_EXAMPLES "Install the examples folder" OFF)
|
||||||
|
if(protobuf_INSTALL_EXAMPLES)
|
||||||
|
install(DIRECTORY ../examples/ DESTINATION examples
|
||||||
|
COMPONENT protobuf-examples)
|
||||||
|
endif()
|
||||||
|
|
|
@ -24,8 +24,32 @@ set(libprotobuf_lite_files
|
||||||
${protobuf_source_dir}/src/google/protobuf/wire_format_lite.cc
|
${protobuf_source_dir}/src/google/protobuf/wire_format_lite.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(libprotobuf_lite_includes
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/arena.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/arenastring.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/extension_set.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/generated_message_util.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/io/coded_stream.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl_lite.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/message_lite.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/repeated_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/stubs/bytestream.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/stubs/common.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/stubs/int128.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/stubs/once.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/stubs/status.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/stubs/statusor.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/stubs/stringpiece.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/stubs/stringprintf.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/stubs/strutil.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/stubs/time.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/wire_format_lite.h
|
||||||
|
)
|
||||||
|
|
||||||
add_library(libprotobuf-lite ${protobuf_SHARED_OR_STATIC}
|
add_library(libprotobuf-lite ${protobuf_SHARED_OR_STATIC}
|
||||||
${libprotobuf_lite_files})
|
${libprotobuf_lite_files} ${libprotobuf_lite_includes})
|
||||||
target_link_libraries(libprotobuf-lite ${CMAKE_THREAD_LIBS_INIT})
|
target_link_libraries(libprotobuf-lite ${CMAKE_THREAD_LIBS_INIT})
|
||||||
target_include_directories(libprotobuf-lite PUBLIC ${protobuf_source_dir}/src)
|
target_include_directories(libprotobuf-lite PUBLIC ${protobuf_source_dir}/src)
|
||||||
if(MSVC AND protobuf_BUILD_SHARED_LIBS)
|
if(MSVC AND protobuf_BUILD_SHARED_LIBS)
|
||||||
|
|
|
@ -13,6 +13,7 @@ set(libprotobuf_files
|
||||||
${protobuf_source_dir}/src/google/protobuf/extension_set_heavy.cc
|
${protobuf_source_dir}/src/google/protobuf/extension_set_heavy.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/field_mask.pb.cc
|
${protobuf_source_dir}/src/google/protobuf/field_mask.pb.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/generated_message_reflection.cc
|
${protobuf_source_dir}/src/google/protobuf/generated_message_reflection.cc
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/generated_message_table_driven.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/io/gzip_stream.cc
|
${protobuf_source_dir}/src/google/protobuf/io/gzip_stream.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/io/printer.cc
|
${protobuf_source_dir}/src/google/protobuf/io/printer.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/io/strtod.cc
|
${protobuf_source_dir}/src/google/protobuf/io/strtod.cc
|
||||||
|
@ -30,6 +31,7 @@ set(libprotobuf_files
|
||||||
${protobuf_source_dir}/src/google/protobuf/timestamp.pb.cc
|
${protobuf_source_dir}/src/google/protobuf/timestamp.pb.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/type.pb.cc
|
${protobuf_source_dir}/src/google/protobuf/type.pb.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/unknown_field_set.cc
|
${protobuf_source_dir}/src/google/protobuf/unknown_field_set.cc
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/delimited_message_util.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/util/field_comparator.cc
|
${protobuf_source_dir}/src/google/protobuf/util/field_comparator.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/util/field_mask_util.cc
|
${protobuf_source_dir}/src/google/protobuf/util/field_mask_util.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/util/internal/datapiece.cc
|
${protobuf_source_dir}/src/google/protobuf/util/internal/datapiece.cc
|
||||||
|
@ -54,9 +56,68 @@ set(libprotobuf_files
|
||||||
${protobuf_source_dir}/src/google/protobuf/wrappers.pb.cc
|
${protobuf_source_dir}/src/google/protobuf/wrappers.pb.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(libprotobuf_includes
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/any.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/any.pb.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/api.pb.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/importer.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/parser.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/descriptor.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/descriptor.pb.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/descriptor_database.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/duration.pb.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/dynamic_message.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/empty.pb.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/field_mask.pb.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/generated_message_reflection.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/io/gzip_stream.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/io/printer.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/io/strtod.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/io/tokenizer.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/io/zero_copy_stream_impl.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/map_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/message.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/reflection_ops.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/service.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/source_context.pb.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/struct.pb.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/stubs/mathlimits.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/stubs/substitute.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/text_format.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/timestamp.pb.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/type.pb.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/unknown_field_set.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/delimited_message_util.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/field_comparator.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/field_mask_util.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/internal/datapiece.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/internal/default_value_objectwriter.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/internal/error_listener.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/internal/field_mask_utility.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/internal/json_escaping.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/internal/json_objectwriter.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/internal/json_stream_parser.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/internal/object_writer.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/internal/proto_writer.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectsource.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/internal/protostream_objectwriter.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/internal/type_info.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/internal/type_info_test_helper.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/internal/utility.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/json_util.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/message_differencer.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/time_util.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/type_resolver_util.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/wire_format.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/wrappers.pb.h
|
||||||
|
)
|
||||||
|
|
||||||
add_library(libprotobuf ${protobuf_SHARED_OR_STATIC}
|
add_library(libprotobuf ${protobuf_SHARED_OR_STATIC}
|
||||||
${libprotobuf_lite_files} ${libprotobuf_files})
|
${libprotobuf_lite_files} ${libprotobuf_files} ${libprotobuf_includes})
|
||||||
target_link_libraries(libprotobuf ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES})
|
target_link_libraries(libprotobuf ${CMAKE_THREAD_LIBS_INIT})
|
||||||
|
if(protobuf_WITH_ZLIB)
|
||||||
|
target_link_libraries(libprotobuf ${ZLIB_LIBRARIES})
|
||||||
|
endif()
|
||||||
target_include_directories(libprotobuf PUBLIC ${protobuf_source_dir}/src)
|
target_include_directories(libprotobuf PUBLIC ${protobuf_source_dir}/src)
|
||||||
if(MSVC AND protobuf_BUILD_SHARED_LIBS)
|
if(MSVC AND protobuf_BUILD_SHARED_LIBS)
|
||||||
target_compile_definitions(libprotobuf
|
target_compile_definitions(libprotobuf
|
||||||
|
|
|
@ -72,6 +72,7 @@ set(libprotoc_files
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_message_field.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_message_field.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_primitive_field.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/js/js_generator.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/js/js_generator.cc
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types_embed.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_extension.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_extension.cc
|
||||||
|
@ -84,16 +85,139 @@ set(libprotoc_files
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/php/php_generator.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/plugin.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/plugin.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/plugin.pb.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/plugin.pb.cc
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/profile.pb.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/python/python_generator.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/python/python_generator.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/ruby/ruby_generator.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/ruby/ruby_generator.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/subprocess.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/subprocess.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/zip_writer.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/zip_writer.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(libprotoc_headers
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/code_generator.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/command_line_interface.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/importer.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/mock_code_generator.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/package_info.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/parser.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/plugin.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/plugin.pb.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/profile.pb.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/subprocess.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/zip_writer.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_enum.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_enum_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_extension.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_file.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_generator.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_helpers.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_map_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_message_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_options.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_primitive_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_service.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_string_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_unittest.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_doc_comment.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_enum.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_enum_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_field_base.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_generator.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_helpers.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_map_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_message.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_message_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_names.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_options.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_primitive_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_reflection_class.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_source_generator_base.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_wrapper_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_context.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_field_lite.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_enum_lite.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_extension.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_extension_lite.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_file.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_generator.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_generator_factory.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_helpers.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_lazy_message_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_lazy_message_field_lite.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_map_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_map_field_lite.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_builder.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_builder_lite.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_field_lite.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_message_lite.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_names.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_name_resolver.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_options.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_primitive_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_primitive_field_lite.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_service.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_shared_code_generator.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_string_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_string_field_lite.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_enum.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_enum_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_extension.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_file.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_generator.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_helpers.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_map_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_message.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_message_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_params.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/javanano/javanano_primitive_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/js/js_generator.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types_embed.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_enum_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_extension.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_file.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_generator.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_helpers.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_map_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_message_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_oneof.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/php/php_generator.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/python/python_generator.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/ruby/ruby_generator.h
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/plugin.pb.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set(js_well_known_types_sources
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types/any.js
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types/struct.js
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types/timestamp.js
|
||||||
|
)
|
||||||
|
add_executable(js_embed ${protobuf_source_dir}/src/google/protobuf/compiler/js/embed.cc)
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types_embed.cc
|
||||||
|
DEPENDS js_embed ${js_well_known_types_sources}
|
||||||
|
COMMAND js_embed ${js_well_known_types_sources} > ${protobuf_source_dir}/src/google/protobuf/compiler/js/well_known_types_embed.cc
|
||||||
|
)
|
||||||
|
|
||||||
add_library(libprotoc ${protobuf_SHARED_OR_STATIC}
|
add_library(libprotoc ${protobuf_SHARED_OR_STATIC}
|
||||||
${libprotoc_files})
|
${libprotoc_files} ${libprotoc_headers})
|
||||||
target_link_libraries(libprotoc libprotobuf)
|
target_link_libraries(libprotoc libprotobuf)
|
||||||
if(MSVC AND protobuf_BUILD_SHARED_LIBS)
|
if(MSVC AND protobuf_BUILD_SHARED_LIBS)
|
||||||
target_compile_definitions(libprotoc
|
target_compile_definitions(libprotoc
|
||||||
|
|
|
@ -1 +1,60 @@
|
||||||
set(PACKAGE_VERSION @protobuf_VERSION@)
|
set(PACKAGE_VERSION "@protobuf_VERSION@")
|
||||||
|
set(${PACKAGE_FIND_NAME}_VERSION_PRERELEASE "@protobuf_VERSION_PRERELEASE@" PARENT_SCOPE)
|
||||||
|
|
||||||
|
# Prerelease versions cannot be passed in directly via the find_package command,
|
||||||
|
# so we allow users to specify it in a variable
|
||||||
|
if(NOT DEFINED "${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE")
|
||||||
|
set("${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}" "")
|
||||||
|
else()
|
||||||
|
set(PACKAGE_FIND_VERSION ${PACKAGE_FIND_VERSION}-${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE})
|
||||||
|
endif()
|
||||||
|
set(PACKAGE_FIND_VERSION_PRERELEASE "${${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE}")
|
||||||
|
|
||||||
|
# VERSION_EQUAL ignores the prerelease strings, so we use STREQUAL.
|
||||||
|
if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
|
||||||
|
set(PACKAGE_VERSION_EXACT TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE TRUE) #Assume true until shown otherwise
|
||||||
|
|
||||||
|
if(PACKAGE_FIND_VERSION) #Only perform version checks if one is given
|
||||||
|
if(NOT PACKAGE_FIND_VERSION_MAJOR EQUAL "@protobuf_VERSION_MAJOR@")
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||||
|
elseif(PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||||
|
elseif(PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
|
||||||
|
# Do not match prerelease versions to non-prerelease version requests.
|
||||||
|
if(NOT "@protobuf_VERSION_PRERELEASE@" STREQUAL "" AND PACKAGE_FIND_VERSION_PRERELEASE STREQUAL "")
|
||||||
|
message(AUTHOR_WARNING "To use this prerelease version of ${PACKAGE_FIND_NAME}, set ${PACKAGE_FIND_NAME}_FIND_VERSION_PRERELEASE to '@protobuf_VERSION_PRERELEASE@' or greater.")
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Not robustly SemVer compliant, but protobuf never uses '.' separated prerelease identifiers.
|
||||||
|
if(PACKAGE_FIND_VERSION_PRERELEASE STRGREATER "@protobuf_VERSION_PRERELEASE@")
|
||||||
|
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Check and save build options used to create this package
|
||||||
|
macro(_check_and_save_build_option OPTION VALUE)
|
||||||
|
if(DEFINED ${PACKAGE_FIND_NAME}_${OPTION} AND
|
||||||
|
NOT ${PACKAGE_FIND_NAME}_${OPTION} STREQUAL ${VALUE})
|
||||||
|
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
||||||
|
endif()
|
||||||
|
set(${PACKAGE_FIND_NAME}_${OPTION} ${VALUE} PARENT_SCOPE)
|
||||||
|
endmacro()
|
||||||
|
_check_and_save_build_option(WITH_ZLIB @protobuf_WITH_ZLIB@)
|
||||||
|
_check_and_save_build_option(MSVC_STATIC_RUNTIME @protobuf_MSVC_STATIC_RUNTIME@)
|
||||||
|
_check_and_save_build_option(BUILD_SHARED_LIBS @protobuf_BUILD_SHARED_LIBS@)
|
||||||
|
|
||||||
|
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
|
||||||
|
if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "" AND NOT "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
|
||||||
|
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
|
||||||
|
if(NOT CMAKE_SIZEOF_VOID_P STREQUAL "@CMAKE_SIZEOF_VOID_P@")
|
||||||
|
math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8")
|
||||||
|
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
|
||||||
|
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -1,27 +1,112 @@
|
||||||
# Version info variables
|
# User options
|
||||||
set(PROTOBUF_VERSION "@protobuf_VERSION@")
|
include("${CMAKE_CURRENT_LIST_DIR}/protobuf-options.cmake")
|
||||||
set(PROTOBUF_VERSION_STRING "@protobuf_VERSION_STRING@")
|
|
||||||
|
|
||||||
# Current dir
|
# Depend packages
|
||||||
get_filename_component(_PROTOBUF_PACKAGE_PREFIX
|
@_protobuf_FIND_ZLIB@
|
||||||
"${CMAKE_CURRENT_LIST_FILE}" PATH)
|
|
||||||
|
|
||||||
# Imported targets
|
# Imported targets
|
||||||
include("${_PROTOBUF_PACKAGE_PREFIX}/protobuf-targets.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/protobuf-targets.cmake")
|
||||||
|
|
||||||
# Compute the installation prefix relative to this file.
|
function(protobuf_generate)
|
||||||
get_filename_component(_PROTOBUF_IMPORT_PREFIX
|
include(CMakeParseArguments)
|
||||||
"${_PROTOBUF_PACKAGE_PREFIX}" PATH)
|
set(_singleargs LANGUAGE OUT_VAR)
|
||||||
get_filename_component(_PROTOBUF_IMPORT_PREFIX
|
if(COMMAND target_sources)
|
||||||
"${_PROTOBUF_IMPORT_PREFIX}" PATH)
|
list(APPEND _singleargs TARGET)
|
||||||
get_filename_component(_PROTOBUF_IMPORT_PREFIX
|
endif()
|
||||||
"${_PROTOBUF_IMPORT_PREFIX}" PATH)
|
|
||||||
|
cmake_parse_arguments(protobuf_generate "APPEND_PATH" "${_singleargs}" "PROTOS IMPORT_DIRS GENERATE_EXTENSIONS" "${ARGN}")
|
||||||
|
|
||||||
|
if(protobuf_generate_PROTOS AND NOT protobuf_generate_TARGET)
|
||||||
|
message(SEND_ERROR "Error: protobuf_generate called without any targets or source files")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT protobuf_generate_OUT_VAR AND NOT protobuf_generate_TARGET)
|
||||||
|
message(SEND_ERROR "Error: protobuf_generate called without a target or output variable")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT protobuf_generate_LANGUAGE)
|
||||||
|
set(protobuf_generate_LANGUAGE cpp)
|
||||||
|
endif()
|
||||||
|
string(TOLOWER ${protobuf_generate_LANGUAGE} protobuf_generate_LANGUAGE)
|
||||||
|
|
||||||
|
if(NOT protobuf_GENERATE_EXTENSIONS)
|
||||||
|
if(protobuf_generate_LANGUAGE STREQUAL cpp)
|
||||||
|
set(protobuf_GENERATE_EXTENSIONS .pb.h .pb.cc)
|
||||||
|
elseif(protobuf_generate_LANGUAGE STREQUAL python)
|
||||||
|
set(protobuf_GENERATE_EXTENSIONS _pb2.py)
|
||||||
|
else()
|
||||||
|
message(SEND_ERROR "Error: protobuf_generate given unknown Language ${LANGUAGE}, please provide a value for GENERATE_EXTENSIONS")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(protobuf_generate_APPEND_PATH)
|
||||||
|
# Create an include path for each file specified
|
||||||
|
foreach(_file ${ARGN})
|
||||||
|
get_filename_component(_abs_file ${_file} ABSOLUTE)
|
||||||
|
get_filename_component(_abs_path ${_abs_file} PATH)
|
||||||
|
list(FIND _protobuf_include_path ${_abs_path} _contains_already)
|
||||||
|
if(${_contains_already} EQUAL -1)
|
||||||
|
list(APPEND _protobuf_include_path -I ${_abs_path})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
else()
|
||||||
|
set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
foreach(DIR ${protobuf_generate_IMPORT_DIRS})
|
||||||
|
get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
|
||||||
|
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
|
||||||
|
if(${_contains_already} EQUAL -1)
|
||||||
|
list(APPEND _protobuf_include_path -I ${ABS_PATH})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(protobuf_generate_TARGET)
|
||||||
|
get_target_property(_source_list ${protobuf_generate_TARGET} SOURCES)
|
||||||
|
foreach(_file ${_source_list})
|
||||||
|
if(_file MATCHES "proto$")
|
||||||
|
list(APPEND protobuf_generate_PROTOS ${_file})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT protobuf_generate_PROTOS)
|
||||||
|
message(SEND_ERROR "Error: protobuf_generate could not find any .proto files")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(_generated_srcs)
|
||||||
|
foreach(_proto ${protobuf_generate_PROTOS})
|
||||||
|
get_filename_component(_abs_file ${_proto} ABSOLUTE)
|
||||||
|
get_filename_component(_basename ${_proto} NAME_WE)
|
||||||
|
|
||||||
|
foreach(_ext ${_output_extensions})
|
||||||
|
list(APPEND _generated_srcs "${CMAKE_CURRENT_BINARY_DIR}/${_basename}${_ext}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${_generated_srcs}
|
||||||
|
COMMAND protobuf::protoc
|
||||||
|
ARGS --${protobuf_generate_LANGUAGE}_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${_abs_file}
|
||||||
|
DEPENDS ${ABS_FIL} protobuf::protoc
|
||||||
|
COMMENT "Running ${protobuf_generate_LANGUAGE} protocol buffer compiler on ${_proto}"
|
||||||
|
VERBATIM )
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set_source_files_properties(${_generated_srcs} PROPERTIES GENERATED TRUE)
|
||||||
|
if(protobuf_generate_OUT_VAR)
|
||||||
|
set(${protobuf_generate_OUT_VAR} ${_generated_srcs} PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
if(protobuf_generate_TARGET)
|
||||||
|
target_sources(${protobuf_generate_TARGET} PUBLIC ${_generated_srcs})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
endfunction()
|
||||||
|
|
||||||
# CMake FindProtobuf module compatible file
|
# CMake FindProtobuf module compatible file
|
||||||
if(NOT DEFINED PROTOBUF_MODULE_COMPATIBLE OR "${PROTOBUF_MODULE_COMPATIBLE}")
|
if(protobuf_MODULE_COMPATIBLE)
|
||||||
include("${_PROTOBUF_PACKAGE_PREFIX}/protobuf-module.cmake")
|
include("${CMAKE_CURRENT_LIST_DIR}/protobuf-module.cmake")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Cleanup temporary variables.
|
|
||||||
set(_PROTOBUF_PACKAGE_PREFIX)
|
|
||||||
set(_PROTOBUF_IMPORT_PREFIX)
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
if(PROTOBUF_SRC_ROOT_FOLDER)
|
# This file contains backwards compatibility patches for various legacy functions and variables
|
||||||
message(AUTHOR_WARNING "Variable PROTOBUF_SRC_ROOT_FOLDER defined, but not"
|
# Functions
|
||||||
" used in CONFIG mode")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
function(PROTOBUF_GENERATE_CPP SRCS HDRS)
|
function(PROTOBUF_GENERATE_CPP SRCS HDRS)
|
||||||
if(NOT ARGN)
|
if(NOT ARGN)
|
||||||
|
@ -10,80 +8,99 @@ function(PROTOBUF_GENERATE_CPP SRCS HDRS)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
|
if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
|
||||||
# Create an include path for each file specified
|
set(_append_arg APPEND_PATH)
|
||||||
foreach(FIL ${ARGN})
|
|
||||||
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
|
|
||||||
get_filename_component(ABS_PATH ${ABS_FIL} PATH)
|
|
||||||
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
|
|
||||||
if(${_contains_already} EQUAL -1)
|
|
||||||
list(APPEND _protobuf_include_path -I ${ABS_PATH})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
else()
|
|
||||||
set(_protobuf_include_path -I ${CMAKE_CURRENT_SOURCE_DIR})
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Add well-known type protos include path
|
if(DEFINED Protobuf_IMPORT_DIRS)
|
||||||
list(APPEND _protobuf_include_path
|
set(_import_arg IMPORT_DIRS ${Protobuf_IMPORT_DIRS})
|
||||||
-I "${_PROTOBUF_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@")
|
|
||||||
|
|
||||||
if(DEFINED PROTOBUF_IMPORT_DIRS)
|
|
||||||
foreach(DIR ${PROTOBUF_IMPORT_DIRS})
|
|
||||||
get_filename_component(ABS_PATH ${DIR} ABSOLUTE)
|
|
||||||
list(FIND _protobuf_include_path ${ABS_PATH} _contains_already)
|
|
||||||
if(${_contains_already} EQUAL -1)
|
|
||||||
list(APPEND _protobuf_include_path -I ${ABS_PATH})
|
|
||||||
endif()
|
|
||||||
endforeach()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(_outvar)
|
||||||
|
protobuf_generate(${append_arg} LANGUAGE cpp OUT_VAR _outvar ${_import_arg} PROTOS ${ARGN})
|
||||||
|
|
||||||
set(${SRCS})
|
set(${SRCS})
|
||||||
set(${HDRS})
|
set(${HDRS})
|
||||||
foreach(FIL ${ARGN})
|
foreach(_file ${_outvar})
|
||||||
get_filename_component(ABS_FIL ${FIL} ABSOLUTE)
|
if(_file MATCHES "cc$")
|
||||||
get_filename_component(FIL_WE ${FIL} NAME_WE)
|
list(APPEND ${SRCS} ${_file})
|
||||||
|
else()
|
||||||
list(APPEND ${SRCS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc")
|
list(APPEND ${HDRS} ${_file})
|
||||||
list(APPEND ${HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h")
|
endif()
|
||||||
|
|
||||||
add_custom_command(
|
|
||||||
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.cc"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/${FIL_WE}.pb.h"
|
|
||||||
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE}
|
|
||||||
ARGS --cpp_out ${CMAKE_CURRENT_BINARY_DIR} ${_protobuf_include_path} ${ABS_FIL}
|
|
||||||
DEPENDS ${ABS_FIL} ${PROTOBUF_PROTOC_EXECUTABLE}
|
|
||||||
COMMENT "Running C++ protocol buffer compiler on ${FIL}"
|
|
||||||
VERBATIM)
|
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
set_source_files_properties(${${SRCS}} ${${HDRS}} PROPERTIES GENERATED TRUE)
|
|
||||||
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
|
set(${SRCS} ${${SRCS}} PARENT_SCOPE)
|
||||||
set(${HDRS} ${${HDRS}} PARENT_SCOPE)
|
set(${HDRS} ${${HDRS}} PARENT_SCOPE)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
function(PROTOBUF_GENERATE_PYTHON SRCS)
|
||||||
|
if(NOT ARGN)
|
||||||
|
message(SEND_ERROR "Error: PROTOBUF_GENERATE_PYTHON() called without any proto files")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(PROTOBUF_GENERATE_CPP_APPEND_PATH)
|
||||||
|
set(_append_arg APPEND_PATH)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED Protobuf_IMPORT_DIRS)
|
||||||
|
set(_import_arg IMPORT_DIRS ${Protobuf_IMPORT_DIRS})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(_outvar)
|
||||||
|
protobuf_generate(${append_arg} LANGUAGE cpp OUT_VAR _outvar ${_import_arg} PROTOS ${ARGN})
|
||||||
|
set(${SRCS} ${_outvar} PARENT_SCOPE)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
# Environment
|
||||||
|
|
||||||
|
# Backwards compatibility
|
||||||
|
# Define camel case versions of input variables
|
||||||
|
foreach(UPPER
|
||||||
|
PROTOBUF_SRC_ROOT_FOLDER
|
||||||
|
PROTOBUF_IMPORT_DIRS
|
||||||
|
PROTOBUF_DEBUG
|
||||||
|
PROTOBUF_LIBRARY
|
||||||
|
PROTOBUF_PROTOC_LIBRARY
|
||||||
|
PROTOBUF_INCLUDE_DIR
|
||||||
|
PROTOBUF_PROTOC_EXECUTABLE
|
||||||
|
PROTOBUF_LIBRARY_DEBUG
|
||||||
|
PROTOBUF_PROTOC_LIBRARY_DEBUG
|
||||||
|
PROTOBUF_LITE_LIBRARY
|
||||||
|
PROTOBUF_LITE_LIBRARY_DEBUG
|
||||||
|
)
|
||||||
|
if (DEFINED ${UPPER})
|
||||||
|
string(REPLACE "PROTOBUF_" "Protobuf_" Camel ${UPPER})
|
||||||
|
if (NOT DEFINED ${Camel})
|
||||||
|
set(${Camel} ${${UPPER}})
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
if(DEFINED Protobuf_SRC_ROOT_FOLDER)
|
||||||
|
message(AUTHOR_WARNING "Variable Protobuf_SRC_ROOT_FOLDER defined, but not"
|
||||||
|
" used in CONFIG mode")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
include(SelectLibraryConfigurations)
|
||||||
|
|
||||||
# Internal function: search for normal library as well as a debug one
|
# Internal function: search for normal library as well as a debug one
|
||||||
# if the debug one is specified also include debug/optimized keywords
|
# if the debug one is specified also include debug/optimized keywords
|
||||||
# in *_LIBRARIES variable
|
# in *_LIBRARIES variable
|
||||||
function(_protobuf_find_libraries name filename)
|
function(_protobuf_find_libraries name filename)
|
||||||
get_target_property(${name}_LIBRARY lib${filename}
|
if(${name}_LIBRARIES)
|
||||||
IMPORTED_LOCATION_RELEASE)
|
# Use result recorded by a previous call.
|
||||||
set(${name}_LIBRARY "${${name}_LIBRARY}" PARENT_SCOPE)
|
elseif(${name}_LIBRARY)
|
||||||
get_target_property(${name}_LIBRARY_DEBUG lib${filename}
|
# Honor cache entry used by CMake 3.5 and lower.
|
||||||
IMPORTED_LOCATION_DEBUG)
|
set(${name}_LIBRARIES "${${name}_LIBRARY}" PARENT_SCOPE)
|
||||||
set(${name}_LIBRARY_DEBUG "${${name}_LIBRARY_DEBUG}" PARENT_SCOPE)
|
else()
|
||||||
|
get_target_property(${name}_LIBRARY_RELEASE protobuf::lib${filename}
|
||||||
|
LOCATION_RELEASE)
|
||||||
|
get_target_property(${name}_LIBRARY_DEBUG protobuf::lib${filename}
|
||||||
|
LOCATION_DEBUG)
|
||||||
|
|
||||||
if(NOT ${name}_LIBRARY_DEBUG)
|
select_library_configurations(${name})
|
||||||
# There is no debug library
|
set(${name}_LIBRARY ${${name}_LIBRARY} PARENT_SCOPE)
|
||||||
set(${name}_LIBRARY_DEBUG ${${name}_LIBRARY} PARENT_SCOPE)
|
set(${name}_LIBRARIES ${${name}_LIBRARIES} PARENT_SCOPE)
|
||||||
set(${name}_LIBRARIES ${${name}_LIBRARY} PARENT_SCOPE)
|
endif()
|
||||||
else()
|
|
||||||
# There IS a debug library
|
|
||||||
set(${name}_LIBRARIES
|
|
||||||
optimized ${${name}_LIBRARY}
|
|
||||||
debug ${${name}_LIBRARY_DEBUG}
|
|
||||||
PARENT_SCOPE
|
|
||||||
)
|
|
||||||
endif()
|
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
# Internal function: find threads library
|
# Internal function: find threads library
|
||||||
|
@ -107,33 +124,59 @@ if(NOT DEFINED PROTOBUF_GENERATE_CPP_APPEND_PATH)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# The Protobuf library
|
# The Protobuf library
|
||||||
_protobuf_find_libraries(PROTOBUF protobuf)
|
_protobuf_find_libraries(Protobuf protobuf)
|
||||||
|
|
||||||
# The Protobuf Lite library
|
# The Protobuf Lite library
|
||||||
_protobuf_find_libraries(PROTOBUF_LITE protobuf-lite)
|
_protobuf_find_libraries(Protobuf_LITE protobuf-lite)
|
||||||
|
|
||||||
# The Protobuf Protoc Library
|
# The Protobuf Protoc Library
|
||||||
_protobuf_find_libraries(PROTOBUF_PROTOC protoc)
|
_protobuf_find_libraries(Protobuf_PROTOC protoc)
|
||||||
|
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
_protobuf_find_threads()
|
_protobuf_find_threads()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Set the include directory
|
# Set the include directory
|
||||||
set(PROTOBUF_INCLUDE_DIR "${_PROTOBUF_IMPORT_PREFIX}/@CMAKE_INSTALL_INCLUDEDIR@")
|
get_target_property(Protobuf_INCLUDE_DIRS protobuf::libprotobuf
|
||||||
|
INTERFACE_INCLUDE_DIRECTORIES)
|
||||||
|
|
||||||
# Set the protoc Executable
|
# Set the protoc Executable
|
||||||
get_target_property(PROTOBUF_PROTOC_EXECUTABLE protoc
|
get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
|
||||||
IMPORTED_LOCATION_RELEASE)
|
IMPORTED_LOCATION_RELEASE)
|
||||||
if(NOT PROTOBUF_PROTOC_EXECUTABLE)
|
if(NOT EXISTS "${Protobuf_PROTOC_EXECUTABLE}")
|
||||||
get_target_property(PROTOBUF_PROTOC_EXECUTABLE protoc
|
get_target_property(Protobuf_PROTOC_EXECUTABLE protobuf::protoc
|
||||||
IMPORTED_LOCATION_DEBUG)
|
IMPORTED_LOCATION_DEBUG)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
# Version info variable
|
||||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROTOBUF DEFAULT_MSG
|
set(Protobuf_VERSION "@protobuf_VERSION@")
|
||||||
PROTOBUF_LIBRARY PROTOBUF_INCLUDE_DIR)
|
|
||||||
|
|
||||||
if(PROTOBUF_FOUND)
|
include(FindPackageHandleStandardArgs)
|
||||||
set(PROTOBUF_INCLUDE_DIRS ${PROTOBUF_INCLUDE_DIR})
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Protobuf
|
||||||
endif()
|
REQUIRED_VARS Protobuf_PROTOC_EXECUTABLE Protobuf_LIBRARIES Protobuf_INCLUDE_DIRS
|
||||||
|
VERSION_VAR Protobuf_VERSION
|
||||||
|
)
|
||||||
|
|
||||||
|
# Backwards compatibility
|
||||||
|
# Define upper case versions of output variables
|
||||||
|
foreach(Camel
|
||||||
|
Protobuf_VERSION
|
||||||
|
Protobuf_SRC_ROOT_FOLDER
|
||||||
|
Protobuf_IMPORT_DIRS
|
||||||
|
Protobuf_DEBUG
|
||||||
|
Protobuf_INCLUDE_DIRS
|
||||||
|
Protobuf_LIBRARIES
|
||||||
|
Protobuf_PROTOC_LIBRARIES
|
||||||
|
Protobuf_LITE_LIBRARIES
|
||||||
|
Protobuf_LIBRARY
|
||||||
|
Protobuf_PROTOC_LIBRARY
|
||||||
|
Protobuf_INCLUDE_DIR
|
||||||
|
Protobuf_PROTOC_EXECUTABLE
|
||||||
|
Protobuf_LIBRARY_DEBUG
|
||||||
|
Protobuf_PROTOC_LIBRARY_DEBUG
|
||||||
|
Protobuf_LITE_LIBRARY
|
||||||
|
Protobuf_LITE_LIBRARY_DEBUG
|
||||||
|
)
|
||||||
|
string(TOUPPER ${Camel} UPPER)
|
||||||
|
set(${UPPER} ${${Camel}})
|
||||||
|
endforeach()
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Verbose output
|
||||||
|
option(protobuf_VERBOSE "Enable for verbose output" OFF)
|
||||||
|
mark_as_advanced(protobuf_VERBOSE)
|
||||||
|
|
||||||
|
# FindProtobuf module compatibel
|
||||||
|
option(protobuf_MODULE_COMPATIBLE "CMake build-in FindProtobuf.cmake module compatible" OFF)
|
||||||
|
mark_as_advanced(protobuf_MODULE_COMPATIBLE)
|
|
@ -4,6 +4,7 @@ endif()
|
||||||
|
|
||||||
option(protobuf_ABSOLUTE_TEST_PLUGIN_PATH
|
option(protobuf_ABSOLUTE_TEST_PLUGIN_PATH
|
||||||
"Using absolute test_plugin path in tests" ON)
|
"Using absolute test_plugin path in tests" ON)
|
||||||
|
mark_as_advanced(protobuf_ABSOLUTE_TEST_PLUGIN_PATH)
|
||||||
|
|
||||||
include_directories(
|
include_directories(
|
||||||
${protobuf_source_dir}/gmock
|
${protobuf_source_dir}/gmock
|
||||||
|
@ -16,6 +17,7 @@ add_library(gmock STATIC
|
||||||
${protobuf_source_dir}/gmock/src/gmock-all.cc
|
${protobuf_source_dir}/gmock/src/gmock-all.cc
|
||||||
${protobuf_source_dir}/gmock/gtest/src/gtest-all.cc
|
${protobuf_source_dir}/gmock/gtest/src/gtest-all.cc
|
||||||
)
|
)
|
||||||
|
target_link_libraries(gmock ${CMAKE_THREAD_LIBS_INIT})
|
||||||
add_library(gmock_main STATIC ${protobuf_source_dir}/gmock/src/gmock_main.cc)
|
add_library(gmock_main STATIC ${protobuf_source_dir}/gmock/src/gmock_main.cc)
|
||||||
target_link_libraries(gmock_main gmock)
|
target_link_libraries(gmock_main gmock)
|
||||||
|
|
||||||
|
@ -41,6 +43,9 @@ set(tests_protos
|
||||||
google/protobuf/unittest_empty.proto
|
google/protobuf/unittest_empty.proto
|
||||||
google/protobuf/unittest_import.proto
|
google/protobuf/unittest_import.proto
|
||||||
google/protobuf/unittest_import_public.proto
|
google/protobuf/unittest_import_public.proto
|
||||||
|
google/protobuf/unittest_lazy_dependencies.proto
|
||||||
|
google/protobuf/unittest_lazy_dependencies_custom_option.proto
|
||||||
|
google/protobuf/unittest_lazy_dependencies_enum.proto
|
||||||
google/protobuf/unittest_lite_imports_nonlite.proto
|
google/protobuf/unittest_lite_imports_nonlite.proto
|
||||||
google/protobuf/unittest_mset.proto
|
google/protobuf/unittest_mset.proto
|
||||||
google/protobuf/unittest_mset_wire_format.proto
|
google/protobuf/unittest_mset_wire_format.proto
|
||||||
|
@ -62,8 +67,10 @@ set(tests_protos
|
||||||
google/protobuf/util/internal/testdata/field_mask.proto
|
google/protobuf/util/internal/testdata/field_mask.proto
|
||||||
google/protobuf/util/internal/testdata/maps.proto
|
google/protobuf/util/internal/testdata/maps.proto
|
||||||
google/protobuf/util/internal/testdata/oneofs.proto
|
google/protobuf/util/internal/testdata/oneofs.proto
|
||||||
|
google/protobuf/util/internal/testdata/proto3.proto
|
||||||
google/protobuf/util/internal/testdata/struct.proto
|
google/protobuf/util/internal/testdata/struct.proto
|
||||||
google/protobuf/util/internal/testdata/timestamp_duration.proto
|
google/protobuf/util/internal/testdata/timestamp_duration.proto
|
||||||
|
google/protobuf/util/internal/testdata/wrappers.proto
|
||||||
google/protobuf/util/json_format_proto3.proto
|
google/protobuf/util/json_format_proto3.proto
|
||||||
google/protobuf/util/message_differencer_unittest.proto
|
google/protobuf/util/message_differencer_unittest.proto
|
||||||
)
|
)
|
||||||
|
@ -119,6 +126,7 @@ set(tests_files
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_unittest.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/cpp_unittest.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/metadata_test.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/cpp/metadata_test.cc
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/importer_unittest.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/importer_unittest.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment_unittest.cc
|
${protobuf_source_dir}/src/google/protobuf/compiler/java/java_doc_comment_unittest.cc
|
||||||
|
@ -164,6 +172,7 @@ set(tests_files
|
||||||
${protobuf_source_dir}/src/google/protobuf/stubs/type_traits_unittest.cc
|
${protobuf_source_dir}/src/google/protobuf/stubs/type_traits_unittest.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/text_format_unittest.cc
|
${protobuf_source_dir}/src/google/protobuf/text_format_unittest.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/unknown_field_set_unittest.cc
|
${protobuf_source_dir}/src/google/protobuf/unknown_field_set_unittest.cc
|
||||||
|
${protobuf_source_dir}/src/google/protobuf/util/delimited_message_util_test.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/util/field_comparator_test.cc
|
${protobuf_source_dir}/src/google/protobuf/util/field_comparator_test.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/util/field_mask_util_test.cc
|
${protobuf_source_dir}/src/google/protobuf/util/field_mask_util_test.cc
|
||||||
${protobuf_source_dir}/src/google/protobuf/util/internal/default_value_objectwriter_test.cc
|
${protobuf_source_dir}/src/google/protobuf/util/internal/default_value_objectwriter_test.cc
|
||||||
|
@ -201,7 +210,7 @@ set(lite_test_files
|
||||||
${protobuf_source_dir}/src/google/protobuf/lite_unittest.cc
|
${protobuf_source_dir}/src/google/protobuf/lite_unittest.cc
|
||||||
)
|
)
|
||||||
add_executable(lite-test ${lite_test_files} ${common_lite_test_files} ${lite_test_proto_files})
|
add_executable(lite-test ${lite_test_files} ${common_lite_test_files} ${lite_test_proto_files})
|
||||||
target_link_libraries(lite-test libprotobuf-lite)
|
target_link_libraries(lite-test libprotobuf-lite gmock_main)
|
||||||
|
|
||||||
set(lite_arena_test_files
|
set(lite_arena_test_files
|
||||||
${protobuf_source_dir}/src/google/protobuf/lite_arena_unittest.cc
|
${protobuf_source_dir}/src/google/protobuf/lite_arena_unittest.cc
|
||||||
|
@ -211,4 +220,5 @@ target_link_libraries(lite-arena-test libprotobuf-lite gmock_main)
|
||||||
|
|
||||||
add_custom_target(check
|
add_custom_target(check
|
||||||
COMMAND tests
|
COMMAND tests
|
||||||
|
DEPENDS tests test_plugin
|
||||||
WORKING_DIRECTORY ${protobuf_source_dir})
|
WORKING_DIRECTORY ${protobuf_source_dir})
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
{
|
||||||
|
"name": "google/protobuf",
|
||||||
|
"type": "library",
|
||||||
|
"description": "proto library for PHP",
|
||||||
|
"keywords": ["proto"],
|
||||||
|
"homepage": "https://developers.google.com/protocol-buffers/",
|
||||||
|
"license": "BSD-3-Clause",
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.5.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": ">=4.8.0"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Google\\Protobuf\\Internal\\": "php/src/Google/Protobuf/Internal",
|
||||||
|
"GPBMetadata\\Google\\Protobuf\\Internal\\": "php/src/GPBMetadata/Google/Protobuf/Internal"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,196 +0,0 @@
|
||||||
/* Modified for Chromium to support stlport and libc++ adaptively */
|
|
||||||
/* config.h. Generated from config.h.in by configure. */
|
|
||||||
/* config.h.in. Generated from configure.ac by autoheader. */
|
|
||||||
|
|
||||||
/* We want to detect which header files to include for the unordered (hash)
|
|
||||||
collections standardized in C++11 but first introduced as part of TR1.
|
|
||||||
Specifically, we want to avoid including ext/ headers when using libc++ as
|
|
||||||
it will generate noisy build warnings.
|
|
||||||
|
|
||||||
We take a several-tier approach. First, attempt to use clang's __has_include
|
|
||||||
and test for libc++'s configuration header. If that isn't available, include
|
|
||||||
<new> which will define libc++'s version macro (if using libc++).
|
|
||||||
|
|
||||||
There are no really good alternative headers that do less work. For example,
|
|
||||||
ciso646 and cstdbool and commonly recommended, but they both have issues.
|
|
||||||
The first has side effects with MSVC, and the second does not exists on Apple
|
|
||||||
platforms (the system libstdc++ is too old).
|
|
||||||
|
|
||||||
This dynamic check is necessary to allow using this normally dynamically
|
|
||||||
generated header with Chromium's many supported build configurations. It
|
|
||||||
should be expanded to import the right header on other platforms as
|
|
||||||
desired. */
|
|
||||||
|
|
||||||
#if defined(__has_include)
|
|
||||||
#if __has_include(<__config>)
|
|
||||||
#include <__config>
|
|
||||||
#else // __has_include(<__config>)
|
|
||||||
#include <new>
|
|
||||||
#endif // __has_include(<__config>)
|
|
||||||
#endif // defined(__has_include)
|
|
||||||
|
|
||||||
/* the name of <hash_map> */
|
|
||||||
#if defined(_LIBCPP_VERSION)
|
|
||||||
#define HASH_MAP_CLASS unordered_map
|
|
||||||
#else
|
|
||||||
#define HASH_MAP_CLASS hash_map
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* the location of <unordered_map> or <hash_map> */
|
|
||||||
#if defined(USE_STLPORT)
|
|
||||||
#define HASH_MAP_H <hash_map>
|
|
||||||
#elif defined(_LIBCPP_VERSION)
|
|
||||||
#define HASH_MAP_H <unordered_map>
|
|
||||||
#else
|
|
||||||
#define HASH_MAP_H <ext/hash_map>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* the namespace of hash_map/hash_set */
|
|
||||||
#if defined(USE_STLPORT) || defined(_LIBCPP_VERSION)
|
|
||||||
#define HASH_NAMESPACE std
|
|
||||||
#else
|
|
||||||
#define HASH_NAMESPACE __gnu_cxx
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* the name of <hash_set> */
|
|
||||||
#if defined(_LIBCPP_VERSION)
|
|
||||||
#define HASH_SET_CLASS unordered_set
|
|
||||||
#else
|
|
||||||
#define HASH_SET_CLASS hash_set
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* the location of <unordered_set> or <hash_set> */
|
|
||||||
#if defined(USE_STLPORT)
|
|
||||||
#define HASH_SET_H <hash_set>
|
|
||||||
#elif defined(_LIBCPP_VERSION)
|
|
||||||
#define HASH_SET_H <unordered_set>
|
|
||||||
#else
|
|
||||||
#define HASH_SET_H <ext/hash_set>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
|
||||||
#define HAVE_DLFCN_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <fcntl.h> header file. */
|
|
||||||
#define HAVE_FCNTL_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `ftruncate' function. */
|
|
||||||
#define HAVE_FTRUNCATE 1
|
|
||||||
|
|
||||||
/* define if the compiler has hash_map */
|
|
||||||
#define HAVE_HASH_MAP 1
|
|
||||||
|
|
||||||
/* define if the compiler has hash_set */
|
|
||||||
#define HAVE_HASH_SET 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
|
||||||
#define HAVE_INTTYPES_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <limits.h> header file. */
|
|
||||||
#define HAVE_LIMITS_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <memory.h> header file. */
|
|
||||||
#define HAVE_MEMORY_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `memset' function. */
|
|
||||||
#define HAVE_MEMSET 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `mkdir' function. */
|
|
||||||
#define HAVE_MKDIR 1
|
|
||||||
|
|
||||||
/* Define if you have POSIX threads libraries and header files. */
|
|
||||||
#define HAVE_PTHREAD 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <stdint.h> header file. */
|
|
||||||
#define HAVE_STDINT_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <stdlib.h> header file. */
|
|
||||||
#define HAVE_STDLIB_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `strchr' function. */
|
|
||||||
#define HAVE_STRCHR 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `strerror' function. */
|
|
||||||
#define HAVE_STRERROR 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <strings.h> header file. */
|
|
||||||
#define HAVE_STRINGS_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <string.h> header file. */
|
|
||||||
#define HAVE_STRING_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `strtol' function. */
|
|
||||||
#define HAVE_STRTOL 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/stat.h> header file. */
|
|
||||||
#define HAVE_SYS_STAT_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
|
||||||
#define HAVE_SYS_TYPES_H 1
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <unistd.h> header file. */
|
|
||||||
#define HAVE_UNISTD_H 1
|
|
||||||
|
|
||||||
/* Enable classes using zlib compression. */
|
|
||||||
#define HAVE_ZLIB 1
|
|
||||||
|
|
||||||
/* Name of package */
|
|
||||||
#define PACKAGE "protobuf"
|
|
||||||
|
|
||||||
/* Define to the address where bug reports for this package should be sent. */
|
|
||||||
#define PACKAGE_BUGREPORT "protobuf@googlegroups.com"
|
|
||||||
|
|
||||||
/* Define to the full name of this package. */
|
|
||||||
#define PACKAGE_NAME "Protocol Buffers"
|
|
||||||
|
|
||||||
/* Define to the full name and version of this package. */
|
|
||||||
#define PACKAGE_STRING "Protocol Buffers 2.3.0"
|
|
||||||
|
|
||||||
/* Define to the one symbol short name of this package. */
|
|
||||||
#define PACKAGE_TARNAME "protobuf"
|
|
||||||
|
|
||||||
/* Define to the version of this package. */
|
|
||||||
#define PACKAGE_VERSION "2.3.0"
|
|
||||||
|
|
||||||
/* Define to necessary symbol if this constant uses a non-standard name on
|
|
||||||
your system. */
|
|
||||||
/* #undef PTHREAD_CREATE_JOINABLE */
|
|
||||||
|
|
||||||
/* Define to 1 if you have the ANSI C header files. */
|
|
||||||
#define STDC_HEADERS 1
|
|
||||||
|
|
||||||
/* Version number of package */
|
|
||||||
#define VERSION "2.3.0"
|
|
||||||
|
|
||||||
/* Define to 1 if on AIX 3.
|
|
||||||
System headers sometimes define this.
|
|
||||||
We just want to avoid a redefinition error message. */
|
|
||||||
#ifndef _ALL_SOURCE
|
|
||||||
/* # undef _ALL_SOURCE */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enable GNU extensions on systems that have them. */
|
|
||||||
#ifndef _GNU_SOURCE
|
|
||||||
# define _GNU_SOURCE 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Define to 1 if on MINIX. */
|
|
||||||
/* #undef _MINIX */
|
|
||||||
|
|
||||||
/* Define to 2 if the system does not provide POSIX.1 features except with
|
|
||||||
this defined. */
|
|
||||||
/* #undef _POSIX_1_SOURCE */
|
|
||||||
|
|
||||||
/* Define to 1 if you need to in order for `stat' and other things to work. */
|
|
||||||
/* #undef _POSIX_SOURCE */
|
|
||||||
|
|
||||||
/* Enable extensions on Solaris. */
|
|
||||||
#ifndef __EXTENSIONS__
|
|
||||||
# define __EXTENSIONS__ 1
|
|
||||||
#endif
|
|
||||||
#ifndef _POSIX_PTHREAD_SEMANTICS
|
|
||||||
# define _POSIX_PTHREAD_SEMANTICS 1
|
|
||||||
#endif
|
|
||||||
#ifndef _TANDEM_SOURCE
|
|
||||||
# define _TANDEM_SOURCE 1
|
|
||||||
#endif
|
|
|
@ -4,15 +4,20 @@
|
||||||
AC_PREREQ(2.59)
|
AC_PREREQ(2.59)
|
||||||
|
|
||||||
# Note: If you change the version, you must also update it in:
|
# Note: If you change the version, you must also update it in:
|
||||||
# * java/pom.xml
|
# * Protobuf.podspec
|
||||||
# * python/setup.py
|
# * csharp/Google.Protobuf.Tools.nuspec
|
||||||
|
# * csharp/src/*/AssemblyInfo.cs
|
||||||
|
# * csharp/src/Google.Protobuf/Google.Protobuf.nuspec
|
||||||
|
# * java/*/pom.xml
|
||||||
|
# * python/google/protobuf/__init__.py
|
||||||
|
# * protoc-artifacts/pom.xml
|
||||||
# * src/google/protobuf/stubs/common.h
|
# * src/google/protobuf/stubs/common.h
|
||||||
# * src/Makefile.am (Update -version-info for LDFLAGS if needed)
|
# * src/Makefile.am (Update -version-info for LDFLAGS if needed)
|
||||||
#
|
#
|
||||||
# In the SVN trunk, the version should always be the next anticipated release
|
# In the SVN trunk, the version should always be the next anticipated release
|
||||||
# version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed
|
# version with the "-pre" suffix. (We used to use "-SNAPSHOT" but this pushed
|
||||||
# the size of one file name in the dist tarfile over the 99-char limit.)
|
# the size of one file name in the dist tarfile over the 99-char limit.)
|
||||||
AC_INIT([Protocol Buffers],[3.0.0-beta-3],[protobuf@googlegroups.com],[protobuf])
|
AC_INIT([Protocol Buffers],[3.3.2],[protobuf@googlegroups.com],[protobuf])
|
||||||
|
|
||||||
AM_MAINTAINER_MODE([enable])
|
AM_MAINTAINER_MODE([enable])
|
||||||
|
|
||||||
|
@ -26,7 +31,7 @@ AC_CONFIG_MACRO_DIR([m4])
|
||||||
AC_ARG_VAR(DIST_LANG, [language to include in the distribution package (i.e., make dist)])
|
AC_ARG_VAR(DIST_LANG, [language to include in the distribution package (i.e., make dist)])
|
||||||
case "$DIST_LANG" in
|
case "$DIST_LANG" in
|
||||||
"") DIST_LANG=all ;;
|
"") DIST_LANG=all ;;
|
||||||
all | cpp | csharp | java | python | javanano | objectivec | ruby | js) ;;
|
all | cpp | csharp | java | python | javanano | objectivec | ruby | js | php) ;;
|
||||||
*) AC_MSG_FAILURE([unknown language: $DIST_LANG]) ;;
|
*) AC_MSG_FAILURE([unknown language: $DIST_LANG]) ;;
|
||||||
esac
|
esac
|
||||||
AC_SUBST(DIST_LANG)
|
AC_SUBST(DIST_LANG)
|
||||||
|
@ -55,6 +60,7 @@ AC_ARG_WITH([protoc],
|
||||||
# Checks for programs.
|
# Checks for programs.
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
AC_PROG_CXX
|
AC_PROG_CXX
|
||||||
|
AC_PROG_CXX_FOR_BUILD
|
||||||
AC_LANG([C++])
|
AC_LANG([C++])
|
||||||
ACX_USE_SYSTEM_EXTENSIONS
|
ACX_USE_SYSTEM_EXTENSIONS
|
||||||
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
|
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
|
||||||
|
@ -87,6 +93,25 @@ ACX_CHECK_SUNCC
|
||||||
# to the link
|
# to the link
|
||||||
AC_PROG_LIBTOOL
|
AC_PROG_LIBTOOL
|
||||||
|
|
||||||
|
# Check whether the linker supports version scripts
|
||||||
|
AC_MSG_CHECKING([whether the linker supports version scripts])
|
||||||
|
save_LDFLAGS=$LDFLAGS
|
||||||
|
LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
|
||||||
|
cat > conftest.map <<EOF
|
||||||
|
{
|
||||||
|
global:
|
||||||
|
main;
|
||||||
|
local:
|
||||||
|
*;
|
||||||
|
};
|
||||||
|
EOF
|
||||||
|
AC_LINK_IFELSE(
|
||||||
|
[AC_LANG_SOURCE([int main() { return 0; }])],
|
||||||
|
[have_ld_version_script=yes; AC_MSG_RESULT(yes)],
|
||||||
|
[have_ld_version_script=no; AC_MSG_RESULT(no)])
|
||||||
|
LDFLAGS=$save_LDFLAGS
|
||||||
|
AM_CONDITIONAL([HAVE_LD_VERSION_SCRIPT], [test "$have_ld_version_script" == "yes"])
|
||||||
|
|
||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h])
|
AC_CHECK_HEADERS([fcntl.h inttypes.h limits.h stdlib.h unistd.h])
|
||||||
|
@ -173,6 +198,8 @@ case "$target_os" in
|
||||||
esac
|
esac
|
||||||
AM_CONDITIONAL([OBJC_CONFORMANCE_TEST], [test $OBJC_CONFORMANCE_TEST = 1])
|
AM_CONDITIONAL([OBJC_CONFORMANCE_TEST], [test $OBJC_CONFORMANCE_TEST = 1])
|
||||||
|
|
||||||
|
AX_CXX_COMPILE_STDCXX([11], [noext], [optional])
|
||||||
|
|
||||||
# HACK: Make gmock's configure script pick up our copy of CFLAGS and CXXFLAGS,
|
# HACK: Make gmock's configure script pick up our copy of CFLAGS and CXXFLAGS,
|
||||||
# since the flags added by ACX_CHECK_SUNCC must be used when compiling gmock
|
# since the flags added by ACX_CHECK_SUNCC must be used when compiling gmock
|
||||||
# too.
|
# too.
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
|
import com.google.protobuf.ByteString;
|
||||||
|
import com.google.protobuf.CodedInputStream;
|
||||||
import com.google.protobuf.conformance.Conformance;
|
import com.google.protobuf.conformance.Conformance;
|
||||||
|
import com.google.protobuf.InvalidProtocolBufferException;
|
||||||
|
import com.google.protobuf_test_messages.proto3.TestMessagesProto3;
|
||||||
import com.google.protobuf.util.JsonFormat;
|
import com.google.protobuf.util.JsonFormat;
|
||||||
import com.google.protobuf.util.JsonFormat.TypeRegistry;
|
import com.google.protobuf.util.JsonFormat.TypeRegistry;
|
||||||
import com.google.protobuf.InvalidProtocolBufferException;
|
import java.io.IOException;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
class ConformanceJava {
|
class ConformanceJava {
|
||||||
private int testCount = 0;
|
private int testCount = 0;
|
||||||
|
@ -47,13 +51,182 @@ class ConformanceJava {
|
||||||
writeToStdout(buf);
|
writeToStdout(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private enum BinaryDecoder {
|
||||||
|
BYTE_STRING_DECODER() {
|
||||||
|
@Override
|
||||||
|
public TestMessagesProto3.TestAllTypes parse(ByteString bytes)
|
||||||
|
throws InvalidProtocolBufferException {
|
||||||
|
return TestMessagesProto3.TestAllTypes.parseFrom(bytes);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
BYTE_ARRAY_DECODER() {
|
||||||
|
@Override
|
||||||
|
public TestMessagesProto3.TestAllTypes parse(ByteString bytes)
|
||||||
|
throws InvalidProtocolBufferException {
|
||||||
|
return TestMessagesProto3.TestAllTypes.parseFrom(bytes.toByteArray());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ARRAY_BYTE_BUFFER_DECODER() {
|
||||||
|
@Override
|
||||||
|
public TestMessagesProto3.TestAllTypes parse(ByteString bytes)
|
||||||
|
throws InvalidProtocolBufferException {
|
||||||
|
ByteBuffer buffer = ByteBuffer.allocate(bytes.size());
|
||||||
|
bytes.copyTo(buffer);
|
||||||
|
buffer.flip();
|
||||||
|
try {
|
||||||
|
return TestMessagesProto3.TestAllTypes.parseFrom(CodedInputStream.newInstance(buffer));
|
||||||
|
} catch (InvalidProtocolBufferException e) {
|
||||||
|
throw e;
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"ByteString based ByteBuffer should not throw IOException.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
READONLY_ARRAY_BYTE_BUFFER_DECODER() {
|
||||||
|
@Override
|
||||||
|
public TestMessagesProto3.TestAllTypes parse(ByteString bytes)
|
||||||
|
throws InvalidProtocolBufferException {
|
||||||
|
try {
|
||||||
|
return TestMessagesProto3.TestAllTypes.parseFrom(
|
||||||
|
CodedInputStream.newInstance(bytes.asReadOnlyByteBuffer()));
|
||||||
|
} catch (InvalidProtocolBufferException e) {
|
||||||
|
throw e;
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"ByteString based ByteBuffer should not throw IOException.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
DIRECT_BYTE_BUFFER_DECODER() {
|
||||||
|
@Override
|
||||||
|
public TestMessagesProto3.TestAllTypes parse(ByteString bytes)
|
||||||
|
throws InvalidProtocolBufferException {
|
||||||
|
ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.size());
|
||||||
|
bytes.copyTo(buffer);
|
||||||
|
buffer.flip();
|
||||||
|
try {
|
||||||
|
return TestMessagesProto3.TestAllTypes.parseFrom(CodedInputStream.newInstance(buffer));
|
||||||
|
} catch (InvalidProtocolBufferException e) {
|
||||||
|
throw e;
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"ByteString based ByteBuffer should not throw IOException.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
READONLY_DIRECT_BYTE_BUFFER_DECODER() {
|
||||||
|
@Override
|
||||||
|
public TestMessagesProto3.TestAllTypes parse(ByteString bytes)
|
||||||
|
throws InvalidProtocolBufferException {
|
||||||
|
ByteBuffer buffer = ByteBuffer.allocateDirect(bytes.size());
|
||||||
|
bytes.copyTo(buffer);
|
||||||
|
buffer.flip();
|
||||||
|
try {
|
||||||
|
return TestMessagesProto3.TestAllTypes.parseFrom(
|
||||||
|
CodedInputStream.newInstance(buffer.asReadOnlyBuffer()));
|
||||||
|
} catch (InvalidProtocolBufferException e) {
|
||||||
|
throw e;
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"ByteString based ByteBuffer should not throw IOException.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
INPUT_STREAM_DECODER() {
|
||||||
|
@Override
|
||||||
|
public TestMessagesProto3.TestAllTypes parse(ByteString bytes)
|
||||||
|
throws InvalidProtocolBufferException {
|
||||||
|
try {
|
||||||
|
return TestMessagesProto3.TestAllTypes.parseFrom(bytes.newInput());
|
||||||
|
} catch (InvalidProtocolBufferException e) {
|
||||||
|
throw e;
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(
|
||||||
|
"ByteString based InputStream should not throw IOException.", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public abstract TestMessagesProto3.TestAllTypes parse(ByteString bytes)
|
||||||
|
throws InvalidProtocolBufferException;
|
||||||
|
}
|
||||||
|
|
||||||
|
private TestMessagesProto3.TestAllTypes parseBinary(ByteString bytes)
|
||||||
|
throws InvalidProtocolBufferException {
|
||||||
|
TestMessagesProto3.TestAllTypes[] messages =
|
||||||
|
new TestMessagesProto3.TestAllTypes[BinaryDecoder.values().length];
|
||||||
|
InvalidProtocolBufferException[] exceptions =
|
||||||
|
new InvalidProtocolBufferException[BinaryDecoder.values().length];
|
||||||
|
|
||||||
|
boolean hasMessage = false;
|
||||||
|
boolean hasException = false;
|
||||||
|
for (int i = 0; i < BinaryDecoder.values().length; ++i) {
|
||||||
|
try {
|
||||||
|
messages[i] = BinaryDecoder.values()[i].parse(bytes);
|
||||||
|
hasMessage = true;
|
||||||
|
} catch (InvalidProtocolBufferException e) {
|
||||||
|
exceptions[i] = e;
|
||||||
|
hasException = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasMessage && hasException) {
|
||||||
|
StringBuilder sb =
|
||||||
|
new StringBuilder("Binary decoders disagreed on whether the payload was valid.\n");
|
||||||
|
for (int i = 0; i < BinaryDecoder.values().length; ++i) {
|
||||||
|
sb.append(BinaryDecoder.values()[i].name());
|
||||||
|
if (messages[i] != null) {
|
||||||
|
sb.append(" accepted the payload.\n");
|
||||||
|
} else {
|
||||||
|
sb.append(" rejected the payload.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasException) {
|
||||||
|
// We do not check if exceptions are equal. Different implementations may return different
|
||||||
|
// exception messages. Throw an arbitrary one out instead.
|
||||||
|
throw exceptions[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fast path comparing all the messages with the first message, assuming equality being
|
||||||
|
// symmetric and transitive.
|
||||||
|
boolean allEqual = true;
|
||||||
|
for (int i = 1; i < messages.length; ++i) {
|
||||||
|
if (!messages[0].equals(messages[i])) {
|
||||||
|
allEqual = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Slow path: compare and find out all unequal pairs.
|
||||||
|
if (!allEqual) {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < messages.length - 1; ++i) {
|
||||||
|
for (int j = i + 1; j < messages.length; ++j) {
|
||||||
|
if (!messages[i].equals(messages[j])) {
|
||||||
|
sb.append(BinaryDecoder.values()[i].name())
|
||||||
|
.append(" and ")
|
||||||
|
.append(BinaryDecoder.values()[j].name())
|
||||||
|
.append(" parsed the payload differently.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new RuntimeException(sb.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return messages[0];
|
||||||
|
}
|
||||||
|
|
||||||
private Conformance.ConformanceResponse doTest(Conformance.ConformanceRequest request) {
|
private Conformance.ConformanceResponse doTest(Conformance.ConformanceRequest request) {
|
||||||
Conformance.TestAllTypes testMessage;
|
TestMessagesProto3.TestAllTypes testMessage;
|
||||||
|
|
||||||
switch (request.getPayloadCase()) {
|
switch (request.getPayloadCase()) {
|
||||||
case PROTOBUF_PAYLOAD: {
|
case PROTOBUF_PAYLOAD: {
|
||||||
try {
|
try {
|
||||||
testMessage = Conformance.TestAllTypes.parseFrom(request.getProtobufPayload());
|
testMessage = parseBinary(request.getProtobufPayload());
|
||||||
} catch (InvalidProtocolBufferException e) {
|
} catch (InvalidProtocolBufferException e) {
|
||||||
return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build();
|
return Conformance.ConformanceResponse.newBuilder().setParseError(e.getMessage()).build();
|
||||||
}
|
}
|
||||||
|
@ -61,7 +234,7 @@ class ConformanceJava {
|
||||||
}
|
}
|
||||||
case JSON_PAYLOAD: {
|
case JSON_PAYLOAD: {
|
||||||
try {
|
try {
|
||||||
Conformance.TestAllTypes.Builder builder = Conformance.TestAllTypes.newBuilder();
|
TestMessagesProto3.TestAllTypes.Builder builder = TestMessagesProto3.TestAllTypes.newBuilder();
|
||||||
JsonFormat.parser().usingTypeRegistry(typeRegistry)
|
JsonFormat.parser().usingTypeRegistry(typeRegistry)
|
||||||
.merge(request.getJsonPayload(), builder);
|
.merge(request.getJsonPayload(), builder);
|
||||||
testMessage = builder.build();
|
testMessage = builder.build();
|
||||||
|
@ -127,7 +300,7 @@ class ConformanceJava {
|
||||||
|
|
||||||
public void run() throws Exception {
|
public void run() throws Exception {
|
||||||
typeRegistry = TypeRegistry.newBuilder().add(
|
typeRegistry = TypeRegistry.newBuilder().add(
|
||||||
Conformance.TestAllTypes.getDescriptor()).build();
|
TestMessagesProto3.TestAllTypes.getDescriptor()).build();
|
||||||
while (doTestIo()) {
|
while (doTestIo()) {
|
||||||
this.testCount++;
|
this.testCount++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,7 @@ class ConformanceJavaLite {
|
||||||
}
|
}
|
||||||
case JSON_PAYLOAD: {
|
case JSON_PAYLOAD: {
|
||||||
return Conformance.ConformanceResponse.newBuilder().setSkipped(
|
return Conformance.ConformanceResponse.newBuilder().setSkipped(
|
||||||
"Lite runtime does not suport Json Formant.").build();
|
"Lite runtime does not support JSON format.").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.");
|
||||||
|
@ -78,7 +78,7 @@ class ConformanceJavaLite {
|
||||||
|
|
||||||
case JSON:
|
case JSON:
|
||||||
return Conformance.ConformanceResponse.newBuilder().setSkipped(
|
return Conformance.ConformanceResponse.newBuilder().setSkipped(
|
||||||
"Lite runtime does not suport Json Formant.").build();
|
"Lite runtime does not support JSON format.").build();
|
||||||
|
|
||||||
default: {
|
default: {
|
||||||
throw new RuntimeException("Unexpected request output.");
|
throw new RuntimeException("Unexpected request output.");
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
## Process this file with automake to produce Makefile.in
|
## Process this file with automake to produce Makefile.in
|
||||||
|
|
||||||
conformance_protoc_inputs = \
|
conformance_protoc_inputs = \
|
||||||
conformance.proto
|
conformance.proto \
|
||||||
|
$(top_srcdir)/src/google/protobuf/test_messages_proto3.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 \
|
||||||
|
@ -20,7 +21,8 @@ other_language_protoc_outputs = \
|
||||||
conformance_pb2.py \
|
conformance_pb2.py \
|
||||||
Conformance.pbobjc.h \
|
Conformance.pbobjc.h \
|
||||||
Conformance.pbobjc.m \
|
Conformance.pbobjc.m \
|
||||||
conformance.rb \
|
conformance_pb.js \
|
||||||
|
conformance_pb.rb \
|
||||||
com/google/protobuf/Any.java \
|
com/google/protobuf/Any.java \
|
||||||
com/google/protobuf/AnyOrBuilder.java \
|
com/google/protobuf/AnyOrBuilder.java \
|
||||||
com/google/protobuf/AnyProto.java \
|
com/google/protobuf/AnyProto.java \
|
||||||
|
@ -61,6 +63,7 @@ other_language_protoc_outputs = \
|
||||||
com/google/protobuf/Value.java \
|
com/google/protobuf/Value.java \
|
||||||
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 \
|
||||||
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 \
|
||||||
|
@ -77,6 +80,12 @@ other_language_protoc_outputs = \
|
||||||
google/protobuf/struct.pb.h \
|
google/protobuf/struct.pb.h \
|
||||||
google/protobuf/struct.rb \
|
google/protobuf/struct.rb \
|
||||||
google/protobuf/struct_pb2.py \
|
google/protobuf/struct_pb2.py \
|
||||||
|
google/protobuf/TestMessagesProto3.pbobjc.h \
|
||||||
|
google/protobuf/TestMessagesProto3.pbobjc.m \
|
||||||
|
google/protobuf/test_messages_proto3.pb.cc \
|
||||||
|
google/protobuf/test_messages_proto3.pb.h \
|
||||||
|
google/protobuf/test_messages_proto3_pb.rb \
|
||||||
|
google/protobuf/test_messages_proto3_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 \
|
||||||
|
@ -85,46 +94,79 @@ other_language_protoc_outputs = \
|
||||||
google/protobuf/wrappers.pb.h \
|
google/protobuf/wrappers.pb.h \
|
||||||
google/protobuf/wrappers.rb \
|
google/protobuf/wrappers.rb \
|
||||||
google/protobuf/wrappers_pb2.py \
|
google/protobuf/wrappers_pb2.py \
|
||||||
lite/com/google/protobuf/Any.java \
|
Conformance/ConformanceRequest.php \
|
||||||
lite/com/google/protobuf/AnyOrBuilder.java \
|
Conformance/ConformanceResponse.php \
|
||||||
lite/com/google/protobuf/AnyProto.java \
|
Conformance/WireFormat.php \
|
||||||
lite/com/google/protobuf/BoolValue.java \
|
GPBMetadata/Conformance.php \
|
||||||
lite/com/google/protobuf/BoolValueOrBuilder.java \
|
GPBMetadata/Google/Protobuf/Any.php \
|
||||||
lite/com/google/protobuf/BytesValue.java \
|
GPBMetadata/Google/Protobuf/Duration.php \
|
||||||
lite/com/google/protobuf/BytesValueOrBuilder.java \
|
GPBMetadata/Google/Protobuf/FieldMask.php \
|
||||||
lite/com/google/protobuf/conformance/Conformance.java \
|
GPBMetadata/Google/Protobuf/Struct.php \
|
||||||
lite/com/google/protobuf/DoubleValue.java \
|
GPBMetadata/Google/Protobuf/TestMessagesProto3.php \
|
||||||
lite/com/google/protobuf/DoubleValueOrBuilder.java \
|
GPBMetadata/Google/Protobuf/Timestamp.php \
|
||||||
lite/com/google/protobuf/Duration.java \
|
GPBMetadata/Google/Protobuf/Wrappers.php \
|
||||||
lite/com/google/protobuf/DurationOrBuilder.java \
|
Google/Protobuf/Any.php \
|
||||||
lite/com/google/protobuf/DurationProto.java \
|
Google/Protobuf/BoolValue.php \
|
||||||
lite/com/google/protobuf/FieldMask.java \
|
Google/Protobuf/BytesValue.php \
|
||||||
lite/com/google/protobuf/FieldMaskOrBuilder.java \
|
Google/Protobuf/DoubleValue.php \
|
||||||
lite/com/google/protobuf/FieldMaskProto.java \
|
Google/Protobuf/Duration.php \
|
||||||
lite/com/google/protobuf/FloatValue.java \
|
Google/Protobuf/FieldMask.php \
|
||||||
lite/com/google/protobuf/FloatValueOrBuilder.java \
|
Google/Protobuf/FloatValue.php \
|
||||||
lite/com/google/protobuf/Int32Value.java \
|
Google/Protobuf/Int32Value.php \
|
||||||
lite/com/google/protobuf/Int32ValueOrBuilder.java \
|
Google/Protobuf/Int64Value.php \
|
||||||
lite/com/google/protobuf/Int64Value.java \
|
Google/Protobuf/ListValue.php \
|
||||||
lite/com/google/protobuf/Int64ValueOrBuilder.java \
|
Google/Protobuf/NullValue.php \
|
||||||
lite/com/google/protobuf/ListValue.java \
|
Google/Protobuf/StringValue.php \
|
||||||
lite/com/google/protobuf/ListValueOrBuilder.java \
|
Google/Protobuf/Struct.php \
|
||||||
lite/com/google/protobuf/NullValue.java \
|
Google/Protobuf/Timestamp.php \
|
||||||
lite/com/google/protobuf/StringValue.java \
|
Google/Protobuf/UInt32Value.php \
|
||||||
lite/com/google/protobuf/StringValueOrBuilder.java \
|
Google/Protobuf/UInt64Value.php \
|
||||||
lite/com/google/protobuf/Struct.java \
|
Google/Protobuf/Value.php \
|
||||||
lite/com/google/protobuf/StructOrBuilder.java \
|
Protobuf_test_messages/Proto3/ForeignEnum.php \
|
||||||
lite/com/google/protobuf/StructProto.java \
|
Protobuf_test_messages/Proto3/ForeignMessage.php \
|
||||||
lite/com/google/protobuf/Timestamp.java \
|
Protobuf_test_messages/Proto3/TestAllTypes_NestedEnum.php \
|
||||||
lite/com/google/protobuf/TimestampOrBuilder.java \
|
Protobuf_test_messages/Proto3/TestAllTypes_NestedMessage.php \
|
||||||
lite/com/google/protobuf/TimestampProto.java \
|
Protobuf_test_messages/Proto3/TestAllTypes.php
|
||||||
lite/com/google/protobuf/UInt32Value.java \
|
# lite/com/google/protobuf/Any.java \
|
||||||
lite/com/google/protobuf/UInt32ValueOrBuilder.java \
|
# lite/com/google/protobuf/AnyOrBuilder.java \
|
||||||
lite/com/google/protobuf/UInt64Value.java \
|
# lite/com/google/protobuf/AnyProto.java \
|
||||||
lite/com/google/protobuf/UInt64ValueOrBuilder.java \
|
# lite/com/google/protobuf/BoolValue.java \
|
||||||
lite/com/google/protobuf/Value.java \
|
# lite/com/google/protobuf/BoolValueOrBuilder.java \
|
||||||
lite/com/google/protobuf/ValueOrBuilder.java \
|
# lite/com/google/protobuf/BytesValue.java \
|
||||||
lite/com/google/protobuf/WrappersProto.java
|
# lite/com/google/protobuf/BytesValueOrBuilder.java \
|
||||||
|
# lite/com/google/protobuf/conformance/Conformance.java \
|
||||||
|
# lite/com/google/protobuf/DoubleValue.java \
|
||||||
|
# lite/com/google/protobuf/DoubleValueOrBuilder.java \
|
||||||
|
# lite/com/google/protobuf/Duration.java \
|
||||||
|
# lite/com/google/protobuf/DurationOrBuilder.java \
|
||||||
|
# lite/com/google/protobuf/DurationProto.java \
|
||||||
|
# lite/com/google/protobuf/FieldMask.java \
|
||||||
|
# lite/com/google/protobuf/FieldMaskOrBuilder.java \
|
||||||
|
# lite/com/google/protobuf/FieldMaskProto.java \
|
||||||
|
# lite/com/google/protobuf/FloatValue.java \
|
||||||
|
# lite/com/google/protobuf/FloatValueOrBuilder.java \
|
||||||
|
# lite/com/google/protobuf/Int32Value.java \
|
||||||
|
# lite/com/google/protobuf/Int32ValueOrBuilder.java \
|
||||||
|
# lite/com/google/protobuf/Int64Value.java \
|
||||||
|
# lite/com/google/protobuf/Int64ValueOrBuilder.java \
|
||||||
|
# lite/com/google/protobuf/ListValue.java \
|
||||||
|
# lite/com/google/protobuf/ListValueOrBuilder.java \
|
||||||
|
# lite/com/google/protobuf/NullValue.java \
|
||||||
|
# lite/com/google/protobuf/StringValue.java \
|
||||||
|
# lite/com/google/protobuf/StringValueOrBuilder.java \
|
||||||
|
# lite/com/google/protobuf/Struct.java \
|
||||||
|
# lite/com/google/protobuf/StructOrBuilder.java \
|
||||||
|
# lite/com/google/protobuf/StructProto.java \
|
||||||
|
# lite/com/google/protobuf/Timestamp.java \
|
||||||
|
# lite/com/google/protobuf/TimestampOrBuilder.java \
|
||||||
|
# lite/com/google/protobuf/TimestampProto.java \
|
||||||
|
# lite/com/google/protobuf/UInt32Value.java \
|
||||||
|
# lite/com/google/protobuf/UInt32ValueOrBuilder.java \
|
||||||
|
# lite/com/google/protobuf/UInt64Value.java \
|
||||||
|
# lite/com/google/protobuf/UInt64ValueOrBuilder.java \
|
||||||
|
# lite/com/google/protobuf/Value.java \
|
||||||
|
# lite/com/google/protobuf/ValueOrBuilder.java \
|
||||||
|
# lite/com/google/protobuf/WrappersProto.java
|
||||||
|
|
||||||
bin_PROGRAMS = conformance-test-runner conformance-cpp
|
bin_PROGRAMS = conformance-test-runner conformance-cpp
|
||||||
|
|
||||||
|
@ -138,21 +180,25 @@ EXTRA_DIST = \
|
||||||
conformance.proto \
|
conformance.proto \
|
||||||
conformance_python.py \
|
conformance_python.py \
|
||||||
conformance_ruby.rb \
|
conformance_ruby.rb \
|
||||||
|
conformance_php.php \
|
||||||
failure_list_cpp.txt \
|
failure_list_cpp.txt \
|
||||||
failure_list_csharp.txt \
|
failure_list_csharp.txt \
|
||||||
failure_list_java.txt \
|
failure_list_java.txt \
|
||||||
|
failure_list_js.txt \
|
||||||
failure_list_objc.txt \
|
failure_list_objc.txt \
|
||||||
failure_list_python.txt \
|
failure_list_python.txt \
|
||||||
failure_list_python_cpp.txt \
|
failure_list_python_cpp.txt \
|
||||||
failure_list_python-post26.txt \
|
failure_list_python-post26.txt \
|
||||||
failure_list_ruby.txt
|
failure_list_ruby.txt \
|
||||||
|
failure_list_php.txt \
|
||||||
|
failure_list_php_c.txt
|
||||||
|
|
||||||
conformance_test_runner_LDADD = $(top_srcdir)/src/libprotobuf.la
|
conformance_test_runner_LDADD = $(top_srcdir)/src/libprotobuf.la
|
||||||
conformance_test_runner_SOURCES = conformance_test.h conformance_test.cc \
|
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
|
nodist_conformance_test_runner_SOURCES = conformance.pb.cc google/protobuf/test_messages_proto3.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"
|
||||||
|
@ -162,7 +208,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
|
nodist_conformance_cpp_SOURCES = conformance.pb.cc google/protobuf/test_messages_proto3.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.
|
||||||
|
@ -173,7 +219,7 @@ if OBJC_CONFORMANCE_TEST
|
||||||
bin_PROGRAMS += conformance-objc
|
bin_PROGRAMS += conformance-objc
|
||||||
|
|
||||||
conformance_objc_SOURCES = conformance_objc.m ../objectivec/GPBProtocolBuffers.m
|
conformance_objc_SOURCES = conformance_objc.m ../objectivec/GPBProtocolBuffers.m
|
||||||
nodist_conformance_objc_SOURCES = Conformance.pbobjc.m
|
nodist_conformance_objc_SOURCES = Conformance.pbobjc.m google/protobuf/TestMessagesProto3.pbobjc.m
|
||||||
# On travis, the build fails without the isysroot because whatever system
|
# On travis, the build fails without the isysroot because whatever system
|
||||||
# headers are being found don't include generics support for
|
# headers are being found don't include generics support for
|
||||||
# NSArray/NSDictionary, the only guess is their image at one time had an odd
|
# NSArray/NSDictionary, the only guess is their image at one time had an odd
|
||||||
|
@ -182,17 +228,24 @@ conformance_objc_CPPFLAGS = -I$(top_srcdir)/objectivec -isysroot `xcrun --sdk ma
|
||||||
conformance_objc_LDFLAGS = -framework Foundation
|
conformance_objc_LDFLAGS = -framework Foundation
|
||||||
# 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_objc" could fail if parallel enough.
|
# so a direct "make test_objc" could fail if parallel enough.
|
||||||
conformance_objc-conformance_objc.$(OBJEXT): Conformance.pbobjc.h
|
conformance_objc-conformance_objc.$(OBJEXT): Conformance.pbobjc.h google/protobuf/TestMessagesProto3.pbobjc.h
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
# JavaScript well-known types are expected to be in a directory called
|
||||||
|
# google-protobuf, because they are usually in the google-protobuf npm
|
||||||
|
# package. But we want to use the sources from our tree, so we recreate
|
||||||
|
# that directory structure here.
|
||||||
|
google-protobuf:
|
||||||
|
mkdir 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)
|
protoc_middleman: $(conformance_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=. $(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=. --ruby_out=. --python_out=. $(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
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -200,11 +253,11 @@ 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)
|
protoc_middleman: $(top_srcdir)/src/protoc$(EXEEXT) $(conformance_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 $(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 --ruby_out=$$oldpwd --python_out=$$oldpwd $(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) )
|
||||||
touch protoc_middleman
|
touch protoc_middleman
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
@ -215,13 +268,13 @@ $(other_language_protoc_outputs): protoc_middleman
|
||||||
|
|
||||||
BUILT_SOURCES = $(protoc_outputs) $(other_language_protoc_outputs)
|
BUILT_SOURCES = $(protoc_outputs) $(other_language_protoc_outputs)
|
||||||
|
|
||||||
CLEANFILES = $(protoc_outputs) protoc_middleman javac_middleman conformance-java javac_middleman_lite conformance-java-lite conformance-csharp $(other_language_protoc_outputs)
|
CLEANFILES = $(protoc_outputs) protoc_middleman javac_middleman conformance-java javac_middleman_lite conformance-java-lite conformance-csharp conformance-php conformance-php-c $(other_language_protoc_outputs)
|
||||||
|
|
||||||
MAINTAINERCLEANFILES = \
|
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
|
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
|
||||||
@touch javac_middleman
|
@touch javac_middleman
|
||||||
|
|
||||||
conformance-java: javac_middleman
|
conformance-java: javac_middleman
|
||||||
|
@ -246,36 +299,60 @@ conformance-java-lite: javac_middleman_lite
|
||||||
conformance-csharp: $(other_language_protoc_outputs)
|
conformance-csharp: $(other_language_protoc_outputs)
|
||||||
@echo "Writing shortcut script conformance-csharp..."
|
@echo "Writing shortcut script conformance-csharp..."
|
||||||
@echo '#! /bin/sh' > conformance-csharp
|
@echo '#! /bin/sh' > conformance-csharp
|
||||||
@echo 'mono ../csharp/src/Google.Protobuf.Conformance/bin/Release/Google.Protobuf.Conformance.exe "$$@"' >> conformance-csharp
|
@echo 'dotnet ../csharp/src/Google.Protobuf.Conformance/bin/Release/netcoreapp1.0/Google.Protobuf.Conformance.dll "$$@"' >> conformance-csharp
|
||||||
@chmod +x conformance-csharp
|
@chmod +x conformance-csharp
|
||||||
|
|
||||||
|
conformance-php:
|
||||||
|
@echo "Writing shortcut script conformance-php..."
|
||||||
|
@echo '#! /bin/sh' > conformance-php
|
||||||
|
@echo 'php -d auto_prepend_file=autoload.php ./conformance_php.php' >> conformance-php
|
||||||
|
@chmod +x conformance-php
|
||||||
|
|
||||||
|
conformance-php-c:
|
||||||
|
@echo "Writing shortcut script conformance-php-c..."
|
||||||
|
@echo '#! /bin/sh' > conformance-php-c
|
||||||
|
@echo 'php -dextension=../php/ext/google/protobuf/modules/protobuf.so ./conformance_php.php' >> conformance-php-c
|
||||||
|
@chmod +x conformance-php-c
|
||||||
|
|
||||||
# Targets for actually running tests.
|
# Targets for actually running tests.
|
||||||
test_cpp: protoc_middleman conformance-test-runner conformance-cpp
|
test_cpp: protoc_middleman conformance-test-runner conformance-cpp
|
||||||
./conformance-test-runner --failure_list failure_list_cpp.txt ./conformance-cpp
|
./conformance-test-runner --enforce_recommended --failure_list failure_list_cpp.txt ./conformance-cpp
|
||||||
|
|
||||||
test_java: protoc_middleman conformance-test-runner conformance-java
|
test_java: protoc_middleman conformance-test-runner conformance-java
|
||||||
./conformance-test-runner --failure_list failure_list_java.txt ./conformance-java
|
./conformance-test-runner --enforce_recommended --failure_list failure_list_java.txt ./conformance-java
|
||||||
|
|
||||||
test_java_lite: protoc_middleman conformance-test-runner conformance-java-lite
|
test_java_lite: protoc_middleman conformance-test-runner conformance-java-lite
|
||||||
./conformance-test-runner ./conformance-java-lite
|
./conformance-test-runner --enforce_recommended ./conformance-java-lite
|
||||||
|
|
||||||
test_csharp: protoc_middleman conformance-test-runner conformance-csharp
|
test_csharp: protoc_middleman conformance-test-runner conformance-csharp
|
||||||
./conformance-test-runner --failure_list failure_list_csharp.txt ./conformance-csharp
|
./conformance-test-runner --enforce_recommended --failure_list failure_list_csharp.txt ./conformance-csharp
|
||||||
|
|
||||||
test_ruby: protoc_middleman conformance-test-runner $(other_language_protoc_outputs)
|
test_ruby: protoc_middleman conformance-test-runner $(other_language_protoc_outputs)
|
||||||
RUBYLIB=../ruby/lib:. ./conformance-test-runner --failure_list failure_list_ruby.txt ./conformance_ruby.rb
|
RUBYLIB=../ruby/lib:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_ruby.txt ./conformance_ruby.rb
|
||||||
|
|
||||||
|
test_php: protoc_middleman conformance-test-runner conformance-php $(other_language_protoc_outputs)
|
||||||
|
./conformance-test-runner --enforce_recommended --failure_list failure_list_php.txt ./conformance-php
|
||||||
|
|
||||||
|
test_php_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs)
|
||||||
|
./conformance-test-runner --enforce_recommended --failure_list failure_list_php_c.txt ./conformance-php-c
|
||||||
|
|
||||||
|
test_php_zts_c: protoc_middleman conformance-test-runner conformance-php-c $(other_language_protoc_outputs)
|
||||||
|
./conformance-test-runner --enforce_recommended --failure_list failure_list_php_zts_c.txt ./conformance-php-c
|
||||||
|
|
||||||
# These depend on library paths being properly set up. The easiest way to
|
# These depend on library paths being properly set up. The easiest way to
|
||||||
# run them is to just use "tox" from the python dir.
|
# run them is to just use "tox" from the python dir.
|
||||||
test_python: protoc_middleman conformance-test-runner
|
test_python: protoc_middleman conformance-test-runner
|
||||||
./conformance-test-runner --failure_list failure_list_python.txt $(CONFORMANCE_PYTHON_EXTRA_FAILURES) ./conformance_python.py
|
./conformance-test-runner --enforce_recommended --failure_list failure_list_python.txt ./conformance_python.py
|
||||||
|
|
||||||
test_python_cpp: protoc_middleman conformance-test-runner
|
test_python_cpp: protoc_middleman conformance-test-runner
|
||||||
./conformance-test-runner --failure_list failure_list_python_cpp.txt $(CONFORMANCE_PYTHON_EXTRA_FAILURES) ./conformance_python.py
|
./conformance-test-runner --enforce_recommended --failure_list failure_list_python_cpp.txt ./conformance_python.py
|
||||||
|
|
||||||
|
test_nodejs: protoc_middleman conformance-test-runner $(other_language_protoc_outputs)
|
||||||
|
NODE_PATH=../js:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_js.txt ./conformance_nodejs.js
|
||||||
|
|
||||||
if OBJC_CONFORMANCE_TEST
|
if OBJC_CONFORMANCE_TEST
|
||||||
|
|
||||||
test_objc: protoc_middleman conformance-test-runner conformance-objc
|
test_objc: protoc_middleman conformance-test-runner conformance-objc
|
||||||
./conformance-test-runner --failure_list failure_list_objc.txt ./conformance-objc
|
./conformance-test-runner --enforce_recommended --failure_list failure_list_objc.txt ./conformance-objc
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
|
@ -19,11 +19,39 @@ directory to build `protoc`, since all the tests depend on it.
|
||||||
|
|
||||||
$ make
|
$ make
|
||||||
|
|
||||||
Then to run the tests against the C++ implementation, run:
|
Running the tests for C++
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
To run the tests against the C++ implementation, run:
|
||||||
|
|
||||||
$ cd conformance && make test_cpp
|
$ cd conformance && make test_cpp
|
||||||
|
|
||||||
More tests and languages will be added soon!
|
Running the tests for JavaScript (Node.js)
|
||||||
|
------------------------------------------
|
||||||
|
|
||||||
|
To run the JavaScript tests against Node.js, make sure you have "node"
|
||||||
|
on your path and then run:
|
||||||
|
|
||||||
|
$ cd conformance && make test_nodejs
|
||||||
|
|
||||||
|
Running the tests for Ruby (MRI)
|
||||||
|
--------------------------------
|
||||||
|
|
||||||
|
To run the Ruby tests against MRI, first build the C extension:
|
||||||
|
|
||||||
|
$ cd ruby && rake
|
||||||
|
|
||||||
|
Then run the tests like so:
|
||||||
|
|
||||||
|
$ cd conformance && make test_ruby
|
||||||
|
|
||||||
|
Running the tests for other languages
|
||||||
|
-------------------------------------
|
||||||
|
|
||||||
|
Most of the languages in the Protobuf source tree are set up to run
|
||||||
|
conformance tests. However some of them are more tricky to set up
|
||||||
|
properly. See `tests.sh` in the base of the repository to see how
|
||||||
|
Travis runs the tests.
|
||||||
|
|
||||||
Testing other Protocol Buffer implementations
|
Testing other Protocol Buffer implementations
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
|
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
define("GOOGLE_INTERNAL_NAMESPACE", "Google\\Protobuf\\Internal\\");
|
||||||
|
define("GOOGLE_NAMESPACE", "Google\\Protobuf\\");
|
||||||
|
define("GOOGLE_GPBMETADATA_NAMESPACE", "GPBMetadata\\Google\\Protobuf\\Internal\\");
|
||||||
|
|
||||||
|
function protobuf_autoloader_impl($class, $prefix) {
|
||||||
|
$length = strlen($prefix);
|
||||||
|
if ((substr($class, 0, $length) === $prefix)) {
|
||||||
|
$path = '../php/src/' . implode('/', array_map('ucwords', explode('\\', $class))) . '.php';
|
||||||
|
include_once $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function protobuf_autoloader($class) {
|
||||||
|
protobuf_autoloader_impl($class, GOOGLE_INTERNAL_NAMESPACE);
|
||||||
|
protobuf_autoloader_impl($class, GOOGLE_NAMESPACE);
|
||||||
|
protobuf_autoloader_impl($class, GOOGLE_GPBMETADATA_NAMESPACE);
|
||||||
|
}
|
||||||
|
|
||||||
|
spl_autoload_register('protobuf_autoloader');
|
|
@ -32,13 +32,6 @@ syntax = "proto3";
|
||||||
package conformance;
|
package conformance;
|
||||||
option java_package = "com.google.protobuf.conformance";
|
option java_package = "com.google.protobuf.conformance";
|
||||||
|
|
||||||
import "google/protobuf/any.proto";
|
|
||||||
import "google/protobuf/duration.proto";
|
|
||||||
import "google/protobuf/field_mask.proto";
|
|
||||||
import "google/protobuf/struct.proto";
|
|
||||||
import "google/protobuf/timestamp.proto";
|
|
||||||
import "google/protobuf/wrappers.proto";
|
|
||||||
|
|
||||||
// This defines the conformance testing protocol. This protocol exists between
|
// This defines the conformance testing protocol. This protocol exists between
|
||||||
// the conformance test suite itself and the code being tested. For each test,
|
// the conformance test suite itself and the code being tested. For each test,
|
||||||
// the suite will send a ConformanceRequest message and expect a
|
// the suite will send a ConformanceRequest message and expect a
|
||||||
|
@ -70,8 +63,13 @@ enum WireFormat {
|
||||||
// 2. parse the protobuf or JSON payload in "payload" (which may fail)
|
// 2. parse the protobuf or JSON payload in "payload" (which may fail)
|
||||||
// 3. if the parse succeeded, serialize the message in the requested format.
|
// 3. if the parse succeeded, serialize the message in the requested format.
|
||||||
message ConformanceRequest {
|
message ConformanceRequest {
|
||||||
// The payload (whether protobuf of JSON) is always for a TestAllTypes proto
|
// The payload (whether protobuf of JSON) is always for a
|
||||||
// (see below).
|
// protobuf_test_messages.proto3.TestAllTypes proto (as defined in
|
||||||
|
// src/google/protobuf/proto3_test_messages.proto).
|
||||||
|
//
|
||||||
|
// TODO(haberman): if/when we expand the conformance tests to support proto2,
|
||||||
|
// we will want to include a field that lets the payload/response be a
|
||||||
|
// protobuf_test_messages.proto2.TestAllTypes message instead.
|
||||||
oneof payload {
|
oneof payload {
|
||||||
bytes protobuf_payload = 1;
|
bytes protobuf_payload = 1;
|
||||||
string json_payload = 2;
|
string json_payload = 2;
|
||||||
|
@ -114,160 +112,3 @@ message ConformanceResponse {
|
||||||
string skipped = 5;
|
string skipped = 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// This proto includes every type of field in both singular and repeated
|
|
||||||
// forms.
|
|
||||||
message TestAllTypes {
|
|
||||||
message NestedMessage {
|
|
||||||
int32 a = 1;
|
|
||||||
TestAllTypes corecursive = 2;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum NestedEnum {
|
|
||||||
FOO = 0;
|
|
||||||
BAR = 1;
|
|
||||||
BAZ = 2;
|
|
||||||
NEG = -1; // Intentionally negative.
|
|
||||||
}
|
|
||||||
|
|
||||||
// Singular
|
|
||||||
int32 optional_int32 = 1;
|
|
||||||
int64 optional_int64 = 2;
|
|
||||||
uint32 optional_uint32 = 3;
|
|
||||||
uint64 optional_uint64 = 4;
|
|
||||||
sint32 optional_sint32 = 5;
|
|
||||||
sint64 optional_sint64 = 6;
|
|
||||||
fixed32 optional_fixed32 = 7;
|
|
||||||
fixed64 optional_fixed64 = 8;
|
|
||||||
sfixed32 optional_sfixed32 = 9;
|
|
||||||
sfixed64 optional_sfixed64 = 10;
|
|
||||||
float optional_float = 11;
|
|
||||||
double optional_double = 12;
|
|
||||||
bool optional_bool = 13;
|
|
||||||
string optional_string = 14;
|
|
||||||
bytes optional_bytes = 15;
|
|
||||||
|
|
||||||
NestedMessage optional_nested_message = 18;
|
|
||||||
ForeignMessage optional_foreign_message = 19;
|
|
||||||
|
|
||||||
NestedEnum optional_nested_enum = 21;
|
|
||||||
ForeignEnum optional_foreign_enum = 22;
|
|
||||||
|
|
||||||
string optional_string_piece = 24 [ctype=STRING_PIECE];
|
|
||||||
string optional_cord = 25 [ctype=CORD];
|
|
||||||
|
|
||||||
TestAllTypes 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Well-known types
|
|
||||||
google.protobuf.BoolValue optional_bool_wrapper = 201;
|
|
||||||
google.protobuf.Int32Value optional_int32_wrapper = 202;
|
|
||||||
google.protobuf.Int64Value optional_int64_wrapper = 203;
|
|
||||||
google.protobuf.UInt32Value optional_uint32_wrapper = 204;
|
|
||||||
google.protobuf.UInt64Value optional_uint64_wrapper = 205;
|
|
||||||
google.protobuf.FloatValue optional_float_wrapper = 206;
|
|
||||||
google.protobuf.DoubleValue optional_double_wrapper = 207;
|
|
||||||
google.protobuf.StringValue optional_string_wrapper = 208;
|
|
||||||
google.protobuf.BytesValue optional_bytes_wrapper = 209;
|
|
||||||
|
|
||||||
repeated google.protobuf.BoolValue repeated_bool_wrapper = 211;
|
|
||||||
repeated google.protobuf.Int32Value repeated_int32_wrapper = 212;
|
|
||||||
repeated google.protobuf.Int64Value repeated_int64_wrapper = 213;
|
|
||||||
repeated google.protobuf.UInt32Value repeated_uint32_wrapper = 214;
|
|
||||||
repeated google.protobuf.UInt64Value repeated_uint64_wrapper = 215;
|
|
||||||
repeated google.protobuf.FloatValue repeated_float_wrapper = 216;
|
|
||||||
repeated google.protobuf.DoubleValue repeated_double_wrapper = 217;
|
|
||||||
repeated google.protobuf.StringValue repeated_string_wrapper = 218;
|
|
||||||
repeated google.protobuf.BytesValue repeated_bytes_wrapper = 219;
|
|
||||||
|
|
||||||
google.protobuf.Duration optional_duration = 301;
|
|
||||||
google.protobuf.Timestamp optional_timestamp = 302;
|
|
||||||
google.protobuf.FieldMask optional_field_mask = 303;
|
|
||||||
google.protobuf.Struct optional_struct = 304;
|
|
||||||
google.protobuf.Any optional_any = 305;
|
|
||||||
google.protobuf.Value optional_value = 306;
|
|
||||||
|
|
||||||
repeated google.protobuf.Duration repeated_duration = 311;
|
|
||||||
repeated google.protobuf.Timestamp repeated_timestamp = 312;
|
|
||||||
repeated google.protobuf.FieldMask repeated_fieldmask = 313;
|
|
||||||
repeated google.protobuf.Struct repeated_struct = 324;
|
|
||||||
repeated google.protobuf.Any repeated_any = 315;
|
|
||||||
repeated google.protobuf.Value repeated_value = 316;
|
|
||||||
|
|
||||||
// Test field-name-to-JSON-name convention.
|
|
||||||
int32 fieldname1 = 401;
|
|
||||||
int32 field_name2 = 402;
|
|
||||||
int32 _field_name3 = 403;
|
|
||||||
int32 field__name4_ = 404;
|
|
||||||
int32 field0name5 = 405;
|
|
||||||
int32 field_0_name6 = 406;
|
|
||||||
int32 fieldName7 = 407;
|
|
||||||
int32 FieldName8 = 408;
|
|
||||||
int32 field_Name9 = 409;
|
|
||||||
int32 Field_Name10 = 410;
|
|
||||||
int32 FIELD_NAME11 = 411;
|
|
||||||
int32 FIELD_name12 = 412;
|
|
||||||
}
|
|
||||||
|
|
||||||
message ForeignMessage {
|
|
||||||
int32 c = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
enum ForeignEnum {
|
|
||||||
FOREIGN_FOO = 0;
|
|
||||||
FOREIGN_BAR = 1;
|
|
||||||
FOREIGN_BAZ = 2;
|
|
||||||
}
|
|
||||||
|
|
|
@ -33,12 +33,12 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "conformance.pb.h"
|
#include "conformance.pb.h"
|
||||||
|
#include <google/protobuf/test_messages_proto3.pb.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>
|
||||||
|
|
||||||
using conformance::ConformanceRequest;
|
using conformance::ConformanceRequest;
|
||||||
using conformance::ConformanceResponse;
|
using conformance::ConformanceResponse;
|
||||||
using conformance::TestAllTypes;
|
|
||||||
using google::protobuf::Descriptor;
|
using google::protobuf::Descriptor;
|
||||||
using google::protobuf::DescriptorPool;
|
using google::protobuf::DescriptorPool;
|
||||||
using google::protobuf::internal::scoped_ptr;
|
using google::protobuf::internal::scoped_ptr;
|
||||||
|
@ -47,6 +47,7 @@ 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 std::string;
|
using std::string;
|
||||||
|
|
||||||
static const char kTypeUrlPrefix[] = "type.googleapis.com";
|
static const char kTypeUrlPrefix[] = "type.googleapis.com";
|
||||||
|
|
|
@ -0,0 +1,168 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
var conformance = require('conformance_pb');
|
||||||
|
var test_messages_proto3 = require('google/protobuf/test_messages_proto3_pb');
|
||||||
|
var fs = require('fs');
|
||||||
|
|
||||||
|
var testCount = 0;
|
||||||
|
|
||||||
|
function doTest(request) {
|
||||||
|
var testMessage;
|
||||||
|
var response = new conformance.ConformanceResponse();
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (request.getRequestedOutputFormat() === conformance.WireFormat.JSON) {
|
||||||
|
response.setSkipped("JSON not supported.");
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (request.getPayloadCase()) {
|
||||||
|
case conformance.ConformanceRequest.PayloadCase.PROTOBUF_PAYLOAD:
|
||||||
|
try {
|
||||||
|
testMessage = test_messages_proto3.TestAllTypes.deserializeBinary(
|
||||||
|
request.getProtobufPayload());
|
||||||
|
} catch (err) {
|
||||||
|
response.setParseError(err.toString());
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
case conformance.ConformanceRequest.PayloadCase.JSON_PAYLOAD:
|
||||||
|
response.setSkipped("JSON not supported.");
|
||||||
|
return response;
|
||||||
|
|
||||||
|
case conformance.ConformanceRequest.PayloadCase.PAYLOAD_NOT_SET:
|
||||||
|
response.setRuntimeError("Request didn't have payload");
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (request.getRequestedOutputFormat()) {
|
||||||
|
case conformance.WireFormat.UNSPECIFIED:
|
||||||
|
response.setRuntimeError("Unspecified output format");
|
||||||
|
return response;
|
||||||
|
|
||||||
|
case conformance.WireFormat.PROTOBUF:
|
||||||
|
response.setProtobufPayload(testMessage.serializeBinary());
|
||||||
|
|
||||||
|
case conformance.WireFormat.JSON:
|
||||||
|
response.setSkipped("JSON not supported.");
|
||||||
|
return response;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw "Request didn't have requested output format";
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
response.setRuntimeError(err.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onEof(totalRead) {
|
||||||
|
if (totalRead == 0) {
|
||||||
|
return undefined;
|
||||||
|
} else {
|
||||||
|
throw "conformance_nodejs: premature EOF on stdin.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Utility function to read a buffer of N bytes.
|
||||||
|
function readBuffer(bytes) {
|
||||||
|
var buf = new Buffer(bytes);
|
||||||
|
var totalRead = 0;
|
||||||
|
while (totalRead < bytes) {
|
||||||
|
var read = 0;
|
||||||
|
try {
|
||||||
|
read = fs.readSync(process.stdin.fd, buf, totalRead, bytes - totalRead);
|
||||||
|
} catch (e) {
|
||||||
|
if (e.code == 'EOF') {
|
||||||
|
return onEof(totalRead)
|
||||||
|
} else if (e.code == 'EAGAIN') {
|
||||||
|
} else {
|
||||||
|
throw "conformance_nodejs: Error reading from stdin." + e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
totalRead += read;
|
||||||
|
}
|
||||||
|
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
function writeBuffer(buffer) {
|
||||||
|
var totalWritten = 0;
|
||||||
|
while (totalWritten < buffer.length) {
|
||||||
|
totalWritten += fs.writeSync(
|
||||||
|
process.stdout.fd, buffer, totalWritten, buffer.length - totalWritten);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns true if the test ran successfully, false on legitimate EOF.
|
||||||
|
// If EOF is encountered in an unexpected place, raises IOError.
|
||||||
|
function doTestIo() {
|
||||||
|
var lengthBuf = readBuffer(4);
|
||||||
|
if (!lengthBuf) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var length = lengthBuf.readInt32LE(0);
|
||||||
|
var serializedRequest = readBuffer(length);
|
||||||
|
if (!serializedRequest) {
|
||||||
|
throw "conformance_nodejs: Failed to read request.";
|
||||||
|
}
|
||||||
|
|
||||||
|
serializedRequest = new Uint8Array(serializedRequest);
|
||||||
|
var request =
|
||||||
|
conformance.ConformanceRequest.deserializeBinary(serializedRequest);
|
||||||
|
var response = doTest(request);
|
||||||
|
|
||||||
|
var serializedResponse = response.serializeBinary();
|
||||||
|
|
||||||
|
lengthBuf = new Buffer(4);
|
||||||
|
lengthBuf.writeInt32LE(serializedResponse.length, 0);
|
||||||
|
writeBuffer(lengthBuf);
|
||||||
|
writeBuffer(new Buffer(serializedResponse));
|
||||||
|
|
||||||
|
testCount += 1
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
if (!doTestIo()) {
|
||||||
|
console.error('conformance_nodejs: received EOF from test runner ' +
|
||||||
|
"after " + testCount + " tests, exiting")
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
|
@ -31,6 +31,7 @@
|
||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
|
|
||||||
#import "Conformance.pbobjc.h"
|
#import "Conformance.pbobjc.h"
|
||||||
|
#import "google/protobuf/TestMessagesProto3.pbobjc.h"
|
||||||
|
|
||||||
static void Die(NSString *format, ...) __dead2;
|
static void Die(NSString *format, ...) __dead2;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,113 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
require_once("Conformance/WireFormat.php");
|
||||||
|
require_once("Conformance/ConformanceResponse.php");
|
||||||
|
require_once("Conformance/ConformanceRequest.php");
|
||||||
|
require_once("Google/Protobuf/Any.php");
|
||||||
|
require_once("Google/Protobuf/Duration.php");
|
||||||
|
require_once("Google/Protobuf/FieldMask.php");
|
||||||
|
require_once("Google/Protobuf/Struct.php");
|
||||||
|
require_once("Google/Protobuf/Value.php");
|
||||||
|
require_once("Google/Protobuf/ListValue.php");
|
||||||
|
require_once("Google/Protobuf/NullValue.php");
|
||||||
|
require_once("Google/Protobuf/Timestamp.php");
|
||||||
|
require_once("Google/Protobuf/DoubleValue.php");
|
||||||
|
require_once("Google/Protobuf/BytesValue.php");
|
||||||
|
require_once("Google/Protobuf/FloatValue.php");
|
||||||
|
require_once("Google/Protobuf/Int64Value.php");
|
||||||
|
require_once("Google/Protobuf/UInt32Value.php");
|
||||||
|
require_once("Google/Protobuf/BoolValue.php");
|
||||||
|
require_once("Google/Protobuf/DoubleValue.php");
|
||||||
|
require_once("Google/Protobuf/Int32Value.php");
|
||||||
|
require_once("Google/Protobuf/StringValue.php");
|
||||||
|
require_once("Google/Protobuf/UInt64Value.php");
|
||||||
|
require_once("Protobuf_test_messages/Proto3/ForeignMessage.php");
|
||||||
|
require_once("Protobuf_test_messages/Proto3/ForeignEnum.php");
|
||||||
|
require_once("Protobuf_test_messages/Proto3/TestAllTypes.php");
|
||||||
|
require_once("Protobuf_test_messages/Proto3/TestAllTypes_NestedMessage.php");
|
||||||
|
require_once("Protobuf_test_messages/Proto3/TestAllTypes_NestedEnum.php");
|
||||||
|
|
||||||
|
require_once("GPBMetadata/Conformance.php");
|
||||||
|
require_once("GPBMetadata/Google/Protobuf/Any.php");
|
||||||
|
require_once("GPBMetadata/Google/Protobuf/Duration.php");
|
||||||
|
require_once("GPBMetadata/Google/Protobuf/FieldMask.php");
|
||||||
|
require_once("GPBMetadata/Google/Protobuf/Struct.php");
|
||||||
|
require_once("GPBMetadata/Google/Protobuf/Timestamp.php");
|
||||||
|
require_once("GPBMetadata/Google/Protobuf/Wrappers.php");
|
||||||
|
require_once("GPBMetadata/Google/Protobuf/TestMessagesProto3.php");
|
||||||
|
|
||||||
|
use \Conformance\WireFormat;
|
||||||
|
|
||||||
|
$test_count = 0;
|
||||||
|
|
||||||
|
function doTest($request)
|
||||||
|
{
|
||||||
|
$test_message = new \Protobuf_test_messages\Proto3\TestAllTypes();
|
||||||
|
$response = new \Conformance\ConformanceResponse();
|
||||||
|
if ($request->getPayload() == "protobuf_payload") {
|
||||||
|
try {
|
||||||
|
$test_message->mergeFromString($request->getProtobufPayload());
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$response->setParseError($e->getMessage());
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
} elseif ($request->getPayload() == "json_payload") {
|
||||||
|
try {
|
||||||
|
$test_message->mergeFromJsonString($request->getJsonPayload());
|
||||||
|
} catch (Exception $e) {
|
||||||
|
$response->setParseError($e->getMessage());
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
trigger_error("Request didn't have payload.", E_USER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($request->getRequestedOutputFormat() == WireFormat::UNSPECIFIED) {
|
||||||
|
trigger_error("Unspecified output format.", E_USER_ERROR);
|
||||||
|
} elseif ($request->getRequestedOutputFormat() == WireFormat::PROTOBUF) {
|
||||||
|
$response->setProtobufPayload($test_message->serializeToString());
|
||||||
|
} elseif ($request->getRequestedOutputFormat() == WireFormat::JSON) {
|
||||||
|
$response->setJsonPayload($test_message->serializeToJsonString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response;
|
||||||
|
}
|
||||||
|
|
||||||
|
function doTestIO()
|
||||||
|
{
|
||||||
|
$length_bytes = fread(STDIN, 4);
|
||||||
|
if (strlen($length_bytes) == 0) {
|
||||||
|
return false; # EOF
|
||||||
|
} elseif (strlen($length_bytes) != 4) {
|
||||||
|
fwrite(STDERR, "I/O error\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$length = unpack("V", $length_bytes)[1];
|
||||||
|
$serialized_request = fread(STDIN, $length);
|
||||||
|
if (strlen($serialized_request) != $length) {
|
||||||
|
trigger_error("I/O error", E_USER_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
$request = new \Conformance\ConformanceRequest();
|
||||||
|
$request->mergeFromString($serialized_request);
|
||||||
|
|
||||||
|
$response = doTest($request);
|
||||||
|
|
||||||
|
$serialized_response = $response->serializeToString();
|
||||||
|
fwrite(STDOUT, pack("V", strlen($serialized_response)));
|
||||||
|
fwrite(STDOUT, $serialized_response);
|
||||||
|
|
||||||
|
$GLOBALS['test_count'] += 1;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(true){
|
||||||
|
if (!doTestIO()) {
|
||||||
|
fprintf(STDERR,
|
||||||
|
"conformance_php: received EOF from test runner " +
|
||||||
|
"after %d tests, exiting\n", $test_count);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
|
@ -38,8 +38,9 @@ See conformance.proto for more information.
|
||||||
import struct
|
import struct
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
from google.protobuf import message
|
|
||||||
from google.protobuf import json_format
|
from google.protobuf import json_format
|
||||||
|
from google.protobuf import message
|
||||||
|
from google.protobuf import test_messages_proto3_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)
|
||||||
|
@ -52,9 +53,9 @@ class ProtocolError(Exception):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def do_test(request):
|
def do_test(request):
|
||||||
test_message = conformance_pb2.TestAllTypes()
|
test_message = test_messages_proto3_pb2.TestAllTypes()
|
||||||
response = conformance_pb2.ConformanceResponse()
|
response = conformance_pb2.ConformanceResponse()
|
||||||
test_message = conformance_pb2.TestAllTypes()
|
test_message = test_messages_proto3_pb2.TestAllTypes()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if request.WhichOneof('payload') == 'protobuf_payload':
|
if request.WhichOneof('payload') == 'protobuf_payload':
|
||||||
|
@ -67,7 +68,7 @@ def do_test(request):
|
||||||
elif request.WhichOneof('payload') == 'json_payload':
|
elif request.WhichOneof('payload') == 'json_payload':
|
||||||
try:
|
try:
|
||||||
json_format.Parse(request.json_payload, test_message)
|
json_format.Parse(request.json_payload, test_message)
|
||||||
except json_format.ParseError as e:
|
except Exception as e:
|
||||||
response.parse_error = str(e)
|
response.parse_error = str(e)
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
@ -81,7 +82,11 @@ def do_test(request):
|
||||||
response.protobuf_payload = test_message.SerializeToString()
|
response.protobuf_payload = test_message.SerializeToString()
|
||||||
|
|
||||||
elif request.requested_output_format == conformance_pb2.JSON:
|
elif request.requested_output_format == conformance_pb2.JSON:
|
||||||
response.json_payload = json_format.MessageToJson(test_message)
|
try:
|
||||||
|
response.json_payload = json_format.MessageToJson(test_message)
|
||||||
|
except Exception as e:
|
||||||
|
response.serialize_error = str(e)
|
||||||
|
return response
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
response.runtime_error = str(e)
|
response.runtime_error = str(e)
|
||||||
|
|
|
@ -30,21 +30,22 @@
|
||||||
# (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.
|
||||||
|
|
||||||
require 'conformance'
|
require 'conformance_pb'
|
||||||
|
require 'google/protobuf/test_messages_proto3_pb'
|
||||||
|
|
||||||
$test_count = 0
|
$test_count = 0
|
||||||
$verbose = false
|
$verbose = false
|
||||||
|
|
||||||
def do_test(request)
|
def do_test(request)
|
||||||
test_message = Conformance::TestAllTypes.new
|
test_message = ProtobufTestMessages::Proto3::TestAllTypes.new
|
||||||
response = Conformance::ConformanceResponse.new
|
response = Conformance::ConformanceResponse.new
|
||||||
|
|
||||||
begin
|
begin
|
||||||
case request.payload
|
case request.payload
|
||||||
when :protobuf_payload
|
when :protobuf_payload
|
||||||
begin
|
begin
|
||||||
test_message =
|
test_message = ProtobufTestMessages::Proto3::TestAllTypes.decode(
|
||||||
Conformance::TestAllTypes.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
|
||||||
|
@ -52,7 +53,8 @@ def do_test(request)
|
||||||
|
|
||||||
when :json_payload
|
when :json_payload
|
||||||
begin
|
begin
|
||||||
test_message = Conformance::TestAllTypes.decode_json(request.json_payload)
|
test_message = ProtobufTestMessages::Proto3::TestAllTypes.decode_json(
|
||||||
|
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')
|
||||||
return response
|
return response
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -49,9 +49,14 @@
|
||||||
namespace conformance {
|
namespace conformance {
|
||||||
class ConformanceRequest;
|
class ConformanceRequest;
|
||||||
class ConformanceResponse;
|
class ConformanceResponse;
|
||||||
class TestAllTypes;
|
|
||||||
} // namespace conformance
|
} // namespace conformance
|
||||||
|
|
||||||
|
namespace protobuf_test_messages {
|
||||||
|
namespace proto3 {
|
||||||
|
class TestAllTypes;
|
||||||
|
} // namespace proto3
|
||||||
|
} // namespace protobuf_test_messages
|
||||||
|
|
||||||
namespace google {
|
namespace google {
|
||||||
namespace protobuf {
|
namespace protobuf {
|
||||||
|
|
||||||
|
@ -91,14 +96,30 @@ class ConformanceTestRunner {
|
||||||
//
|
//
|
||||||
class ConformanceTestSuite {
|
class ConformanceTestSuite {
|
||||||
public:
|
public:
|
||||||
ConformanceTestSuite() : verbose_(false) {}
|
ConformanceTestSuite() : verbose_(false), enforce_recommended_(false) {}
|
||||||
|
|
||||||
void SetVerbose(bool verbose) { verbose_ = verbose; }
|
void SetVerbose(bool verbose) { verbose_ = verbose; }
|
||||||
|
|
||||||
// Sets the list of tests that are expected to fail when RunSuite() is called.
|
// Sets the list of tests that are expected to fail when RunSuite() is called.
|
||||||
// RunSuite() will fail unless the set of failing tests is exactly the same
|
// RunSuite() will fail unless the set of failing tests is exactly the same
|
||||||
// as this list.
|
// as this list.
|
||||||
void SetFailureList(const std::vector<std::string>& failure_list);
|
//
|
||||||
|
// The filename here is *only* used to create/format useful error messages for
|
||||||
|
// how to update the failure list. We do NOT read this file at all.
|
||||||
|
void SetFailureList(const std::string& filename,
|
||||||
|
const std::vector<std::string>& failure_list);
|
||||||
|
|
||||||
|
// Whether to require the testee to pass RECOMMENDED tests. By default failing
|
||||||
|
// a RECOMMENDED test case will not fail the entire suite but will only
|
||||||
|
// generated a warning. If this flag is set to true, RECOMMENDED tests will
|
||||||
|
// be treated the same way as REQUIRED tests and failing a RECOMMENDED test
|
||||||
|
// case will cause the entire test suite to fail as well. An implementation
|
||||||
|
// can enable this if it wants to be strictly conforming to protobuf spec.
|
||||||
|
// See the comments about ConformanceLevel below to learn more about the
|
||||||
|
// difference between REQUIRED and RECOMMENDED test cases.
|
||||||
|
void SetEnforceRecommended(bool value) {
|
||||||
|
enforce_recommended_ = value;
|
||||||
|
}
|
||||||
|
|
||||||
// Run all the conformance tests against the given test runner.
|
// Run all the conformance tests against the given test runner.
|
||||||
// Test output will be stored in "output".
|
// Test output will be stored in "output".
|
||||||
|
@ -109,8 +130,27 @@ class ConformanceTestSuite {
|
||||||
bool RunSuite(ConformanceTestRunner* runner, std::string* output);
|
bool RunSuite(ConformanceTestRunner* runner, std::string* output);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// Test cases are classified into a few categories:
|
||||||
|
// REQUIRED: the test case must be passed for an implementation to be
|
||||||
|
// interoperable with other implementations. For example, a
|
||||||
|
// parser implementaiton must accept both packed and unpacked
|
||||||
|
// form of repeated primitive fields.
|
||||||
|
// RECOMMENDED: the test case is not required for the implementation to
|
||||||
|
// be interoperable with other implementations, but is
|
||||||
|
// recommended for best performance and compatibility. For
|
||||||
|
// example, a proto3 serializer should serialize repeated
|
||||||
|
// primitive fields in packed form, but an implementation
|
||||||
|
// failing to do so will still be able to communicate with
|
||||||
|
// other implementations.
|
||||||
|
enum ConformanceLevel {
|
||||||
|
REQUIRED = 0,
|
||||||
|
RECOMMENDED = 1,
|
||||||
|
};
|
||||||
|
string ConformanceLevelToString(ConformanceLevel level);
|
||||||
|
|
||||||
void ReportSuccess(const std::string& test_name);
|
void ReportSuccess(const std::string& test_name);
|
||||||
void ReportFailure(const string& test_name,
|
void ReportFailure(const string& test_name,
|
||||||
|
ConformanceLevel level,
|
||||||
const conformance::ConformanceRequest& request,
|
const conformance::ConformanceRequest& request,
|
||||||
const conformance::ConformanceResponse& response,
|
const conformance::ConformanceResponse& response,
|
||||||
const char* fmt, ...);
|
const char* fmt, ...);
|
||||||
|
@ -120,35 +160,60 @@ class ConformanceTestSuite {
|
||||||
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,
|
void RunValidInputTest(const string& test_name,
|
||||||
|
ConformanceLevel level,
|
||||||
|
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);
|
||||||
void RunValidJsonTest(const string& test_name, const string& input_json,
|
void RunValidJsonTest(const string& test_name,
|
||||||
|
ConformanceLevel level,
|
||||||
|
const string& input_json,
|
||||||
const string& equivalent_text_format);
|
const string& equivalent_text_format);
|
||||||
void RunValidJsonTestWithProtobufInput(const string& test_name,
|
void RunValidJsonTestWithProtobufInput(
|
||||||
const conformance::TestAllTypes& input,
|
const string& test_name,
|
||||||
const string& equivalent_text_format);
|
ConformanceLevel level,
|
||||||
|
const protobuf_test_messages::proto3::TestAllTypes& input,
|
||||||
|
const string& equivalent_text_format);
|
||||||
|
void RunValidProtobufTest(const string& test_name, ConformanceLevel level,
|
||||||
|
const string& input_protobuf,
|
||||||
|
const string& equivalent_text_format);
|
||||||
|
void RunValidProtobufTestWithMessage(
|
||||||
|
const string& test_name, ConformanceLevel level,
|
||||||
|
const protobuf_test_messages::proto3::TestAllTypes& input,
|
||||||
|
const string& equivalent_text_format);
|
||||||
|
|
||||||
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,
|
||||||
|
ConformanceLevel level,
|
||||||
const string& input_json,
|
const string& input_json,
|
||||||
const Validator& validator);
|
const Validator& validator);
|
||||||
void ExpectParseFailureForJson(const string& test_name,
|
void ExpectParseFailureForJson(const string& test_name,
|
||||||
|
ConformanceLevel level,
|
||||||
const string& input_json);
|
const string& input_json);
|
||||||
void ExpectSerializeFailureForJson(const string& test_name,
|
void ExpectSerializeFailureForJson(const string& test_name,
|
||||||
|
ConformanceLevel level,
|
||||||
const string& text_format);
|
const string& text_format);
|
||||||
void ExpectParseFailureForProto(const std::string& proto,
|
void ExpectParseFailureForProto(const std::string& proto,
|
||||||
const std::string& test_name);
|
const std::string& test_name,
|
||||||
|
ConformanceLevel level);
|
||||||
void ExpectHardParseFailureForProto(const std::string& proto,
|
void ExpectHardParseFailureForProto(const std::string& proto,
|
||||||
const std::string& test_name);
|
const std::string& test_name,
|
||||||
|
ConformanceLevel level);
|
||||||
void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type);
|
void TestPrematureEOFForType(google::protobuf::FieldDescriptor::Type type);
|
||||||
bool CheckSetEmpty(const set<string>& set_to_check, const char* msg);
|
void TestIllegalTags();
|
||||||
|
void TestValidDataForType(
|
||||||
|
google::protobuf::FieldDescriptor::Type,
|
||||||
|
std::vector<std::pair<std::string, std::string>> values);
|
||||||
|
bool CheckSetEmpty(const std::set<string>& set_to_check,
|
||||||
|
const std::string& write_to_file, const std::string& msg);
|
||||||
ConformanceTestRunner* runner_;
|
ConformanceTestRunner* runner_;
|
||||||
int successes_;
|
int successes_;
|
||||||
int expected_failures_;
|
int expected_failures_;
|
||||||
bool verbose_;
|
bool verbose_;
|
||||||
|
bool enforce_recommended_;
|
||||||
std::string output_;
|
std::string output_;
|
||||||
|
std::string failure_list_filename_;
|
||||||
|
|
||||||
// The set of test names that are expected to fail in this run, but haven't
|
// The set of test names that are expected to fail in this run, but haven't
|
||||||
// failed yet.
|
// failed yet.
|
||||||
|
|
|
@ -251,6 +251,16 @@ void UsageError() {
|
||||||
" should contain one test name per\n");
|
" should contain one test name per\n");
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
" line. Use '#' for comments.\n");
|
" line. Use '#' for comments.\n");
|
||||||
|
fprintf(stderr,
|
||||||
|
" --enforce_recommended Enforce that recommended test\n");
|
||||||
|
fprintf(stderr,
|
||||||
|
" cases are also passing. Specify\n");
|
||||||
|
fprintf(stderr,
|
||||||
|
" this flag if you want to be\n");
|
||||||
|
fprintf(stderr,
|
||||||
|
" strictly conforming to protobuf\n");
|
||||||
|
fprintf(stderr,
|
||||||
|
" spec.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -280,14 +290,18 @@ int main(int argc, char *argv[]) {
|
||||||
char *program;
|
char *program;
|
||||||
google::protobuf::ConformanceTestSuite suite;
|
google::protobuf::ConformanceTestSuite suite;
|
||||||
|
|
||||||
|
string failure_list_filename;
|
||||||
vector<string> failure_list;
|
vector<string> failure_list;
|
||||||
|
|
||||||
for (int arg = 1; arg < argc; ++arg) {
|
for (int arg = 1; arg < argc; ++arg) {
|
||||||
if (strcmp(argv[arg], "--failure_list") == 0) {
|
if (strcmp(argv[arg], "--failure_list") == 0) {
|
||||||
if (++arg == argc) UsageError();
|
if (++arg == argc) UsageError();
|
||||||
|
failure_list_filename = argv[arg];
|
||||||
ParseFailureList(argv[arg], &failure_list);
|
ParseFailureList(argv[arg], &failure_list);
|
||||||
} else if (strcmp(argv[arg], "--verbose") == 0) {
|
} else if (strcmp(argv[arg], "--verbose") == 0) {
|
||||||
suite.SetVerbose(true);
|
suite.SetVerbose(true);
|
||||||
|
} else if (strcmp(argv[arg], "--enforce_recommended") == 0) {
|
||||||
|
suite.SetEnforceRecommended(true);
|
||||||
} else if (argv[arg][0] == '-') {
|
} else if (argv[arg][0] == '-') {
|
||||||
fprintf(stderr, "Unknown option: %s\n", argv[arg]);
|
fprintf(stderr, "Unknown option: %s\n", argv[arg]);
|
||||||
UsageError();
|
UsageError();
|
||||||
|
@ -300,7 +314,7 @@ int main(int argc, char *argv[]) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
suite.SetFailureList(failure_list);
|
suite.SetFailureList(failure_list_filename, failure_list);
|
||||||
ForkPipeRunner runner(program);
|
ForkPipeRunner runner(program);
|
||||||
|
|
||||||
std::string output;
|
std::string output;
|
||||||
|
|
|
@ -7,100 +7,38 @@
|
||||||
# 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?
|
||||||
|
|
||||||
FieldMaskNumbersDontRoundTrip.JsonOutput
|
Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput
|
||||||
FieldMaskPathsDontRoundTrip.JsonOutput
|
Recommended.FieldMaskPathsDontRoundTrip.JsonOutput
|
||||||
FieldMaskTooManyUnderscore.JsonOutput
|
Recommended.FieldMaskTooManyUnderscore.JsonOutput
|
||||||
JsonInput.AnyUnorderedTypeTag.JsonOutput
|
Recommended.JsonInput.BoolFieldDoubleQuotedFalse
|
||||||
JsonInput.AnyUnorderedTypeTag.ProtobufOutput
|
Recommended.JsonInput.BoolFieldDoubleQuotedTrue
|
||||||
JsonInput.AnyWithValueForInteger.JsonOutput
|
Recommended.JsonInput.FieldMaskInvalidCharacter
|
||||||
JsonInput.AnyWithValueForInteger.ProtobufOutput
|
Recommended.JsonInput.FieldNameDuplicate
|
||||||
JsonInput.AnyWithValueForJsonObject.JsonOutput
|
Recommended.JsonInput.FieldNameDuplicateDifferentCasing1
|
||||||
JsonInput.AnyWithValueForJsonObject.ProtobufOutput
|
Recommended.JsonInput.FieldNameDuplicateDifferentCasing2
|
||||||
JsonInput.BoolFieldDoubleQuotedFalse
|
Recommended.JsonInput.FieldNameNotQuoted
|
||||||
JsonInput.BoolFieldDoubleQuotedTrue
|
Recommended.JsonInput.MapFieldValueIsNull
|
||||||
JsonInput.BoolFieldIntegerOne
|
Recommended.JsonInput.RepeatedFieldMessageElementIsNull
|
||||||
JsonInput.BoolFieldIntegerZero
|
Recommended.JsonInput.RepeatedFieldPrimitiveElementIsNull
|
||||||
JsonInput.BytesFieldInvalidBase64Characters
|
Recommended.JsonInput.RepeatedFieldTrailingComma
|
||||||
JsonInput.BytesFieldNoPadding
|
Recommended.JsonInput.RepeatedFieldTrailingCommaWithNewlines
|
||||||
JsonInput.DoubleFieldTooSmall
|
Recommended.JsonInput.RepeatedFieldTrailingCommaWithSpace
|
||||||
JsonInput.DurationHasZeroFractionalDigit.Validator
|
Recommended.JsonInput.RepeatedFieldTrailingCommaWithSpaceCommaSpace
|
||||||
JsonInput.DurationJsonInputTooLarge
|
Recommended.JsonInput.StringFieldSingleQuoteBoth
|
||||||
JsonInput.DurationJsonInputTooSmall
|
Recommended.JsonInput.StringFieldSingleQuoteKey
|
||||||
JsonInput.DurationMissingS
|
Recommended.JsonInput.StringFieldSingleQuoteValue
|
||||||
JsonInput.EnumFieldUnknownValue.Validator
|
Recommended.JsonInput.StringFieldUppercaseEscapeLetter
|
||||||
JsonInput.FieldMaskInvalidCharacter
|
Recommended.JsonInput.TrailingCommaInAnObject
|
||||||
JsonInput.FieldNameDuplicate
|
Recommended.JsonInput.TrailingCommaInAnObjectWithNewlines
|
||||||
JsonInput.FieldNameDuplicateDifferentCasing1
|
Recommended.JsonInput.TrailingCommaInAnObjectWithSpace
|
||||||
JsonInput.FieldNameDuplicateDifferentCasing2
|
Recommended.JsonInput.TrailingCommaInAnObjectWithSpaceCommaSpace
|
||||||
JsonInput.FieldNameInLowerCamelCase.Validator
|
Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
|
||||||
JsonInput.FieldNameInSnakeCase.JsonOutput
|
Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
|
||||||
JsonInput.FieldNameInSnakeCase.ProtobufOutput
|
Required.ProtobufInput.PrematureEofInPackedField.BOOL
|
||||||
JsonInput.FieldNameNotQuoted
|
Required.ProtobufInput.PrematureEofInPackedField.ENUM
|
||||||
JsonInput.FloatFieldTooLarge
|
Required.ProtobufInput.PrematureEofInPackedField.INT32
|
||||||
JsonInput.FloatFieldTooSmall
|
Required.ProtobufInput.PrematureEofInPackedField.INT64
|
||||||
JsonInput.Int32FieldLeadingSpace
|
Required.ProtobufInput.PrematureEofInPackedField.SINT32
|
||||||
JsonInput.Int32FieldLeadingZero
|
Required.ProtobufInput.PrematureEofInPackedField.SINT64
|
||||||
JsonInput.Int32FieldMinFloatValue.JsonOutput
|
Required.ProtobufInput.PrematureEofInPackedField.UINT32
|
||||||
JsonInput.Int32FieldMinFloatValue.ProtobufOutput
|
Required.ProtobufInput.PrematureEofInPackedField.UINT64
|
||||||
JsonInput.Int32FieldMinValue.JsonOutput
|
|
||||||
JsonInput.Int32FieldMinValue.ProtobufOutput
|
|
||||||
JsonInput.Int32FieldNegativeWithLeadingZero
|
|
||||||
JsonInput.Int32FieldNotInteger
|
|
||||||
JsonInput.Int32FieldNotNumber
|
|
||||||
JsonInput.Int32FieldTooLarge
|
|
||||||
JsonInput.Int32FieldTooSmall
|
|
||||||
JsonInput.Int32FieldTrailingSpace
|
|
||||||
JsonInput.Int64FieldNotInteger
|
|
||||||
JsonInput.Int64FieldNotNumber
|
|
||||||
JsonInput.Int64FieldTooLarge
|
|
||||||
JsonInput.Int64FieldTooSmall
|
|
||||||
JsonInput.MapFieldValueIsNull
|
|
||||||
JsonInput.OneofFieldDuplicate
|
|
||||||
JsonInput.RepeatedFieldMessageElementIsNull
|
|
||||||
JsonInput.RepeatedFieldPrimitiveElementIsNull
|
|
||||||
JsonInput.RepeatedFieldTrailingComma
|
|
||||||
JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
|
|
||||||
JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotMessage
|
|
||||||
JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotString
|
|
||||||
JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotBool
|
|
||||||
JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotInt
|
|
||||||
JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotString
|
|
||||||
JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool
|
|
||||||
JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
|
|
||||||
JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotMessage
|
|
||||||
JsonInput.StringFieldNotAString
|
|
||||||
JsonInput.StringFieldSurrogateInWrongOrder
|
|
||||||
JsonInput.StringFieldSurrogatePair.JsonOutput
|
|
||||||
JsonInput.StringFieldSurrogatePair.ProtobufOutput
|
|
||||||
JsonInput.StringFieldUnpairedHighSurrogate
|
|
||||||
JsonInput.StringFieldUnpairedLowSurrogate
|
|
||||||
JsonInput.StringFieldUppercaseEscapeLetter
|
|
||||||
JsonInput.TimestampJsonInputLowercaseT
|
|
||||||
JsonInput.TimestampJsonInputLowercaseZ
|
|
||||||
JsonInput.TimestampJsonInputMissingT
|
|
||||||
JsonInput.TimestampJsonInputMissingZ
|
|
||||||
JsonInput.TimestampJsonInputTooLarge
|
|
||||||
JsonInput.TimestampJsonInputTooSmall
|
|
||||||
JsonInput.TrailingCommaInAnObject
|
|
||||||
JsonInput.Uint32FieldNotInteger
|
|
||||||
JsonInput.Uint32FieldNotNumber
|
|
||||||
JsonInput.Uint32FieldTooLarge
|
|
||||||
JsonInput.Uint64FieldNotInteger
|
|
||||||
JsonInput.Uint64FieldNotNumber
|
|
||||||
JsonInput.Uint64FieldTooLarge
|
|
||||||
JsonInput.WrapperTypesWithNullValue.JsonOutput
|
|
||||||
JsonInput.WrapperTypesWithNullValue.ProtobufOutput
|
|
||||||
ProtobufInput.PrematureEofBeforeKnownRepeatedValue.MESSAGE
|
|
||||||
ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
|
|
||||||
ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
|
|
||||||
ProtobufInput.PrematureEofInPackedField.BOOL
|
|
||||||
ProtobufInput.PrematureEofInPackedField.ENUM
|
|
||||||
ProtobufInput.PrematureEofInPackedField.INT32
|
|
||||||
ProtobufInput.PrematureEofInPackedField.INT64
|
|
||||||
ProtobufInput.PrematureEofInPackedField.SINT32
|
|
||||||
ProtobufInput.PrematureEofInPackedField.SINT64
|
|
||||||
ProtobufInput.PrematureEofInPackedField.UINT32
|
|
||||||
ProtobufInput.PrematureEofInPackedField.UINT64
|
|
||||||
ProtobufInput.PrematureEofInsideKnownRepeatedValue.MESSAGE
|
|
||||||
TimestampProtoInputTooLarge.JsonOutput
|
|
||||||
TimestampProtoInputTooSmall.JsonOutput
|
|
||||||
|
|
|
@ -1,16 +1,4 @@
|
||||||
JsonInput.AnyWithValueForInteger.JsonOutput
|
Required.ProtobufInput.IllegalZeroFieldNum_Case_0
|
||||||
JsonInput.AnyWithValueForJsonObject.JsonOutput
|
Required.ProtobufInput.IllegalZeroFieldNum_Case_1
|
||||||
JsonInput.FieldNameInLowerCamelCase.Validator
|
Required.ProtobufInput.IllegalZeroFieldNum_Case_2
|
||||||
JsonInput.FieldNameInSnakeCase.JsonOutput
|
Required.ProtobufInput.IllegalZeroFieldNum_Case_3
|
||||||
JsonInput.FieldNameInSnakeCase.ProtobufOutput
|
|
||||||
JsonInput.FieldNameWithMixedCases.JsonOutput
|
|
||||||
JsonInput.FieldNameWithMixedCases.ProtobufOutput
|
|
||||||
JsonInput.FieldNameWithMixedCases.Validator
|
|
||||||
JsonInput.Int32FieldMinFloatValue.JsonOutput
|
|
||||||
JsonInput.Int32FieldMinValue.JsonOutput
|
|
||||||
JsonInput.Int64FieldMaxValueNotQuoted.JsonOutput
|
|
||||||
JsonInput.Int64FieldMaxValueNotQuoted.ProtobufOutput
|
|
||||||
JsonInput.OriginalProtoFieldName.JsonOutput
|
|
||||||
JsonInput.StringFieldSurrogatePair.JsonOutput
|
|
||||||
JsonInput.Uint64FieldMaxValueNotQuoted.JsonOutput
|
|
||||||
JsonInput.Uint64FieldMaxValueNotQuoted.ProtobufOutput
|
|
||||||
|
|
|
@ -4,46 +4,42 @@
|
||||||
# By listing them here we can keep tabs on which ones are failing and be sure
|
# By listing them here we can keep tabs on which ones are failing and be sure
|
||||||
# that we don't introduce regressions in other tests.
|
# that we don't introduce regressions in other tests.
|
||||||
|
|
||||||
FieldMaskNumbersDontRoundTrip.JsonOutput
|
Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput
|
||||||
FieldMaskPathsDontRoundTrip.JsonOutput
|
Recommended.FieldMaskPathsDontRoundTrip.JsonOutput
|
||||||
FieldMaskTooManyUnderscore.JsonOutput
|
Recommended.FieldMaskTooManyUnderscore.JsonOutput
|
||||||
JsonInput.AnyWithFieldMask.ProtobufOutput
|
Recommended.JsonInput.BoolFieldAllCapitalFalse
|
||||||
JsonInput.AnyWithValueForInteger.JsonOutput
|
Recommended.JsonInput.BoolFieldAllCapitalTrue
|
||||||
JsonInput.AnyWithValueForJsonObject.JsonOutput
|
Recommended.JsonInput.BoolFieldCamelCaseFalse
|
||||||
JsonInput.BoolFieldAllCapitalFalse
|
Recommended.JsonInput.BoolFieldCamelCaseTrue
|
||||||
JsonInput.BoolFieldAllCapitalTrue
|
Recommended.JsonInput.BoolFieldDoubleQuotedFalse
|
||||||
JsonInput.BoolFieldCamelCaseFalse
|
Recommended.JsonInput.BoolFieldDoubleQuotedTrue
|
||||||
JsonInput.BoolFieldCamelCaseTrue
|
Recommended.JsonInput.BoolMapFieldKeyNotQuoted
|
||||||
JsonInput.BoolFieldDoubleQuotedFalse
|
Recommended.JsonInput.DoubleFieldInfinityNotQuoted
|
||||||
JsonInput.BoolFieldDoubleQuotedTrue
|
Recommended.JsonInput.DoubleFieldNanNotQuoted
|
||||||
JsonInput.BoolMapFieldKeyNotQuoted
|
Recommended.JsonInput.DoubleFieldNegativeInfinityNotQuoted
|
||||||
JsonInput.DoubleFieldInfinityNotQuoted
|
Recommended.JsonInput.FieldMaskInvalidCharacter
|
||||||
JsonInput.DoubleFieldNanNotQuoted
|
Recommended.JsonInput.FieldNameDuplicate
|
||||||
JsonInput.DoubleFieldNegativeInfinityNotQuoted
|
Recommended.JsonInput.FieldNameNotQuoted
|
||||||
JsonInput.EnumFieldNotQuoted
|
Recommended.JsonInput.FloatFieldInfinityNotQuoted
|
||||||
JsonInput.FieldMask.ProtobufOutput
|
Recommended.JsonInput.FloatFieldNanNotQuoted
|
||||||
JsonInput.FieldMaskInvalidCharacter
|
Recommended.JsonInput.FloatFieldNegativeInfinityNotQuoted
|
||||||
JsonInput.FieldNameDuplicate
|
Recommended.JsonInput.Int32MapFieldKeyNotQuoted
|
||||||
JsonInput.FieldNameInSnakeCase.JsonOutput
|
Recommended.JsonInput.Int64MapFieldKeyNotQuoted
|
||||||
JsonInput.FieldNameNotQuoted
|
Recommended.JsonInput.JsonWithComments
|
||||||
JsonInput.FloatFieldInfinityNotQuoted
|
Recommended.JsonInput.StringFieldSingleQuoteBoth
|
||||||
JsonInput.FloatFieldNanNotQuoted
|
Recommended.JsonInput.StringFieldSingleQuoteKey
|
||||||
JsonInput.FloatFieldNegativeInfinityNotQuoted
|
Recommended.JsonInput.StringFieldSingleQuoteValue
|
||||||
JsonInput.Int32FieldLeadingZero
|
Recommended.JsonInput.StringFieldSurrogateInWrongOrder
|
||||||
JsonInput.Int32FieldMinFloatValue.JsonOutput
|
Recommended.JsonInput.StringFieldUnpairedHighSurrogate
|
||||||
JsonInput.Int32FieldMinValue.JsonOutput
|
Recommended.JsonInput.StringFieldUnpairedLowSurrogate
|
||||||
JsonInput.Int32FieldNegativeWithLeadingZero
|
Recommended.JsonInput.Uint32MapFieldKeyNotQuoted
|
||||||
JsonInput.Int32FieldPlusSign
|
Recommended.JsonInput.Uint64MapFieldKeyNotQuoted
|
||||||
JsonInput.Int32MapFieldKeyNotQuoted
|
Required.JsonInput.EnumFieldNotQuoted
|
||||||
JsonInput.Int64MapFieldKeyNotQuoted
|
Required.JsonInput.Int32FieldLeadingZero
|
||||||
JsonInput.JsonWithComments
|
Required.JsonInput.Int32FieldNegativeWithLeadingZero
|
||||||
JsonInput.OriginalProtoFieldName.JsonOutput
|
Required.JsonInput.Int32FieldPlusSign
|
||||||
JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool
|
Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotBool
|
||||||
JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
|
Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
|
||||||
JsonInput.StringFieldNotAString
|
Required.JsonInput.StringFieldNotAString
|
||||||
JsonInput.StringFieldSurrogateInWrongOrder
|
Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
|
||||||
JsonInput.StringFieldUnpairedHighSurrogate
|
Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
|
||||||
JsonInput.StringFieldUnpairedLowSurrogate
|
|
||||||
JsonInput.StringFieldUppercaseEscapeLetter
|
|
||||||
JsonInput.Uint32MapFieldKeyNotQuoted
|
|
||||||
JsonInput.Uint64MapFieldKeyNotQuoted
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
Required.ProtobufInput.RepeatedScalarSelectsLast.INT32.ProtobufOutput
|
||||||
|
Required.ProtobufInput.RepeatedScalarSelectsLast.UINT32.ProtobufOutput
|
||||||
|
Required.ProtobufInput.ValidDataRepeated.BOOL.ProtobufOutput
|
||||||
|
Required.ProtobufInput.ValidDataRepeated.DOUBLE.ProtobufOutput
|
||||||
|
Required.ProtobufInput.ValidDataRepeated.FIXED32.ProtobufOutput
|
||||||
|
Required.ProtobufInput.ValidDataRepeated.FIXED64.ProtobufOutput
|
||||||
|
Required.ProtobufInput.ValidDataRepeated.FLOAT.ProtobufOutput
|
||||||
|
Required.ProtobufInput.ValidDataRepeated.INT32.ProtobufOutput
|
||||||
|
Required.ProtobufInput.ValidDataRepeated.INT64.ProtobufOutput
|
||||||
|
Required.ProtobufInput.ValidDataRepeated.SFIXED32.ProtobufOutput
|
||||||
|
Required.ProtobufInput.ValidDataRepeated.SFIXED64.ProtobufOutput
|
||||||
|
Required.ProtobufInput.ValidDataRepeated.SINT32.ProtobufOutput
|
||||||
|
Required.ProtobufInput.ValidDataRepeated.SINT64.ProtobufOutput
|
||||||
|
Required.ProtobufInput.ValidDataRepeated.UINT32.ProtobufOutput
|
||||||
|
Required.ProtobufInput.ValidDataRepeated.UINT64.ProtobufOutput
|
|
@ -1,4 +1,2 @@
|
||||||
# No tests currently failing.
|
# JSON input or output tests are skipped (in conformance_objc.m) as mobile
|
||||||
#
|
# platforms don't support JSON wire format to avoid code bloat.
|
||||||
# json input or output tests are skipped (in conformance_objc.m) as mobile
|
|
||||||
# platforms don't support json wire format to avoid code bloat.
|
|
||||||
|
|
|
@ -0,0 +1,118 @@
|
||||||
|
Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput
|
||||||
|
Recommended.FieldMaskPathsDontRoundTrip.JsonOutput
|
||||||
|
Recommended.FieldMaskTooManyUnderscore.JsonOutput
|
||||||
|
Recommended.JsonInput.DurationHas3FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.DurationHas6FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.DurationHas9FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator
|
||||||
|
Recommended.JsonInput.TimestampHas3FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.TimestampHas6FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.TimestampHas9FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.TimestampHasZeroFractionalDigit.Validator
|
||||||
|
Recommended.JsonInput.TimestampZeroNormalized.Validator
|
||||||
|
Required.DurationProtoInputTooLarge.JsonOutput
|
||||||
|
Required.DurationProtoInputTooSmall.JsonOutput
|
||||||
|
Required.JsonInput.Any.JsonOutput
|
||||||
|
Required.JsonInput.Any.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyNested.JsonOutput
|
||||||
|
Required.JsonInput.AnyNested.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyUnorderedTypeTag.JsonOutput
|
||||||
|
Required.JsonInput.AnyUnorderedTypeTag.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithDuration.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithDuration.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithFieldMask.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithFieldMask.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithInt32ValueWrapper.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithStruct.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithStruct.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithTimestamp.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithTimestamp.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithValueForInteger.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithValueForInteger.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithValueForJsonObject.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithValueForJsonObject.ProtobufOutput
|
||||||
|
Required.JsonInput.DurationMaxValue.JsonOutput
|
||||||
|
Required.JsonInput.DurationMaxValue.ProtobufOutput
|
||||||
|
Required.JsonInput.DurationMinValue.JsonOutput
|
||||||
|
Required.JsonInput.DurationMinValue.ProtobufOutput
|
||||||
|
Required.JsonInput.DurationRepeatedValue.JsonOutput
|
||||||
|
Required.JsonInput.DurationRepeatedValue.ProtobufOutput
|
||||||
|
Required.JsonInput.FieldMask.JsonOutput
|
||||||
|
Required.JsonInput.FieldMask.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalBoolWrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalBoolWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalBytesWrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalBytesWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalDoubleWrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalDoubleWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalFloatWrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalFloatWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalInt32Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalInt32Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalInt64Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalInt64Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalStringWrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalStringWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalUint32Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalUint32Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalUint64Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalUint64Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
|
||||||
|
Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedBoolWrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedBoolWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedBytesWrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedBytesWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedDoubleWrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedDoubleWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedFloatWrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedFloatWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedInt32Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedInt32Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedInt64Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedInt64Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedStringWrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedStringWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedUint32Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedUint32Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedUint64Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedUint64Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.Struct.JsonOutput
|
||||||
|
Required.JsonInput.Struct.ProtobufOutput
|
||||||
|
Required.JsonInput.TimestampMaxValue.JsonOutput
|
||||||
|
Required.JsonInput.TimestampMaxValue.ProtobufOutput
|
||||||
|
Required.JsonInput.TimestampMinValue.JsonOutput
|
||||||
|
Required.JsonInput.TimestampMinValue.ProtobufOutput
|
||||||
|
Required.JsonInput.TimestampRepeatedValue.JsonOutput
|
||||||
|
Required.JsonInput.TimestampRepeatedValue.ProtobufOutput
|
||||||
|
Required.JsonInput.TimestampWithNegativeOffset.JsonOutput
|
||||||
|
Required.JsonInput.TimestampWithNegativeOffset.ProtobufOutput
|
||||||
|
Required.JsonInput.TimestampWithPositiveOffset.JsonOutput
|
||||||
|
Required.JsonInput.TimestampWithPositiveOffset.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptBool.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptBool.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptFloat.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptFloat.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptInteger.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptInteger.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptList.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptList.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptNull.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptNull.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptObject.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptObject.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptString.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptString.ProtobufOutput
|
||||||
|
Required.TimestampProtoInputTooLarge.JsonOutput
|
||||||
|
Required.TimestampProtoInputTooSmall.JsonOutput
|
||||||
|
Required.JsonInput.FloatFieldTooLarge
|
||||||
|
Required.JsonInput.FloatFieldTooSmall
|
||||||
|
Required.JsonInput.DoubleFieldTooSmall
|
||||||
|
Required.JsonInput.Int32FieldNotInteger
|
||||||
|
Required.JsonInput.Int64FieldNotInteger
|
||||||
|
Required.JsonInput.Uint32FieldNotInteger
|
||||||
|
Required.JsonInput.Uint64FieldNotInteger
|
||||||
|
Required.JsonInput.Int32FieldLeadingSpace
|
||||||
|
Required.JsonInput.OneofFieldDuplicate
|
||||||
|
Required.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput
|
|
@ -0,0 +1,197 @@
|
||||||
|
Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput
|
||||||
|
Recommended.FieldMaskPathsDontRoundTrip.JsonOutput
|
||||||
|
Recommended.FieldMaskTooManyUnderscore.JsonOutput
|
||||||
|
Recommended.JsonInput.BoolFieldIntegerOne
|
||||||
|
Recommended.JsonInput.BoolFieldIntegerZero
|
||||||
|
Recommended.JsonInput.DurationHas3FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.DurationHas6FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.DurationHas9FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator
|
||||||
|
Recommended.JsonInput.Int64FieldBeString.Validator
|
||||||
|
Recommended.JsonInput.MapFieldValueIsNull
|
||||||
|
Recommended.JsonInput.OneofZeroBytes.JsonOutput
|
||||||
|
Recommended.JsonInput.OneofZeroBytes.ProtobufOutput
|
||||||
|
Recommended.JsonInput.OneofZeroString.JsonOutput
|
||||||
|
Recommended.JsonInput.OneofZeroString.ProtobufOutput
|
||||||
|
Recommended.JsonInput.RepeatedFieldMessageElementIsNull
|
||||||
|
Recommended.JsonInput.RepeatedFieldPrimitiveElementIsNull
|
||||||
|
Recommended.JsonInput.StringEndsWithEscapeChar
|
||||||
|
Recommended.JsonInput.StringFieldSurrogateInWrongOrder
|
||||||
|
Recommended.JsonInput.StringFieldUnpairedHighSurrogate
|
||||||
|
Recommended.JsonInput.StringFieldUnpairedLowSurrogate
|
||||||
|
Recommended.JsonInput.TimestampHas3FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.TimestampHas6FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.TimestampHas9FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.TimestampHasZeroFractionalDigit.Validator
|
||||||
|
Recommended.JsonInput.TimestampZeroNormalized.Validator
|
||||||
|
Recommended.JsonInput.Uint64FieldBeString.Validator
|
||||||
|
Recommended.ProtobufInput.OneofZeroBytes.JsonOutput
|
||||||
|
Recommended.ProtobufInput.OneofZeroBytes.ProtobufOutput
|
||||||
|
Recommended.ProtobufInput.OneofZeroString.JsonOutput
|
||||||
|
Recommended.ProtobufInput.OneofZeroString.ProtobufOutput
|
||||||
|
Required.DurationProtoInputTooLarge.JsonOutput
|
||||||
|
Required.DurationProtoInputTooSmall.JsonOutput
|
||||||
|
Required.JsonInput.Any.JsonOutput
|
||||||
|
Required.JsonInput.Any.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyNested.JsonOutput
|
||||||
|
Required.JsonInput.AnyNested.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyUnorderedTypeTag.JsonOutput
|
||||||
|
Required.JsonInput.AnyUnorderedTypeTag.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithDuration.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithDuration.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithFieldMask.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithFieldMask.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithInt32ValueWrapper.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithStruct.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithStruct.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithTimestamp.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithTimestamp.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithValueForInteger.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithValueForInteger.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithValueForJsonObject.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithValueForJsonObject.ProtobufOutput
|
||||||
|
Required.JsonInput.BoolMapField.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldInfinity.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldInfinity.ProtobufOutput
|
||||||
|
Required.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput
|
||||||
|
Required.JsonInput.DoubleFieldMaxPositiveValue.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput
|
||||||
|
Required.JsonInput.DoubleFieldMinNegativeValue.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput
|
||||||
|
Required.JsonInput.DoubleFieldMinPositiveValue.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput
|
||||||
|
Required.JsonInput.DoubleFieldNan.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldNan.ProtobufOutput
|
||||||
|
Required.JsonInput.DoubleFieldNegativeInfinity.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput
|
||||||
|
Required.JsonInput.DoubleFieldQuotedValue.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldQuotedValue.ProtobufOutput
|
||||||
|
Required.JsonInput.DurationMaxValue.JsonOutput
|
||||||
|
Required.JsonInput.DurationMaxValue.ProtobufOutput
|
||||||
|
Required.JsonInput.DurationMinValue.JsonOutput
|
||||||
|
Required.JsonInput.DurationMinValue.ProtobufOutput
|
||||||
|
Required.JsonInput.DurationRepeatedValue.JsonOutput
|
||||||
|
Required.JsonInput.DurationRepeatedValue.ProtobufOutput
|
||||||
|
Required.JsonInput.EnumFieldNumericValueNonZero.JsonOutput
|
||||||
|
Required.JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
|
||||||
|
Required.JsonInput.EnumFieldNumericValueZero.JsonOutput
|
||||||
|
Required.JsonInput.EnumFieldNumericValueZero.ProtobufOutput
|
||||||
|
Required.JsonInput.EnumFieldUnknownValue.Validator
|
||||||
|
Required.JsonInput.FieldMask.JsonOutput
|
||||||
|
Required.JsonInput.FieldMask.ProtobufOutput
|
||||||
|
Required.JsonInput.FloatFieldInfinity.JsonOutput
|
||||||
|
Required.JsonInput.FloatFieldInfinity.ProtobufOutput
|
||||||
|
Required.JsonInput.FloatFieldNan.JsonOutput
|
||||||
|
Required.JsonInput.FloatFieldNan.ProtobufOutput
|
||||||
|
Required.JsonInput.FloatFieldNegativeInfinity.JsonOutput
|
||||||
|
Required.JsonInput.FloatFieldNegativeInfinity.ProtobufOutput
|
||||||
|
Required.JsonInput.FloatFieldQuotedValue.JsonOutput
|
||||||
|
Required.JsonInput.FloatFieldQuotedValue.ProtobufOutput
|
||||||
|
Required.JsonInput.FloatFieldTooLarge
|
||||||
|
Required.JsonInput.FloatFieldTooSmall
|
||||||
|
Required.JsonInput.Int32FieldExponentialFormat.JsonOutput
|
||||||
|
Required.JsonInput.Int32FieldExponentialFormat.ProtobufOutput
|
||||||
|
Required.JsonInput.Int32FieldFloatTrailingZero.JsonOutput
|
||||||
|
Required.JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
|
||||||
|
Required.JsonInput.Int32FieldMaxFloatValue.JsonOutput
|
||||||
|
Required.JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
|
||||||
|
Required.JsonInput.Int32FieldMinFloatValue.JsonOutput
|
||||||
|
Required.JsonInput.Int32FieldMinFloatValue.ProtobufOutput
|
||||||
|
Required.JsonInput.Int32FieldStringValue.JsonOutput
|
||||||
|
Required.JsonInput.Int32FieldStringValue.ProtobufOutput
|
||||||
|
Required.JsonInput.Int32FieldStringValueEscaped.JsonOutput
|
||||||
|
Required.JsonInput.Int32FieldStringValueEscaped.ProtobufOutput
|
||||||
|
Required.JsonInput.Int64FieldMaxValue.JsonOutput
|
||||||
|
Required.JsonInput.Int64FieldMaxValue.ProtobufOutput
|
||||||
|
Required.JsonInput.Int64FieldMinValue.JsonOutput
|
||||||
|
Required.JsonInput.Int64FieldMinValue.ProtobufOutput
|
||||||
|
Required.JsonInput.MessageField.JsonOutput
|
||||||
|
Required.JsonInput.MessageField.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalBoolWrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalBoolWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalBytesWrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalBytesWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalDoubleWrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalDoubleWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalFloatWrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalFloatWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalInt32Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalInt32Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalInt64Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalInt64Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalStringWrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalStringWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalUint32Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalUint32Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalUint64Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalUint64Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
|
||||||
|
Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedBoolWrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedBoolWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedBytesWrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedBytesWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedDoubleWrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedDoubleWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedFieldWrongElementTypeExpectingMessagesGotInt
|
||||||
|
Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
|
||||||
|
Required.JsonInput.RepeatedFloatWrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedFloatWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedInt32Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedInt32Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedInt64Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedInt64Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedStringWrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedStringWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedUint32Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedUint32Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedUint64Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedUint64Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.StringFieldEscape.JsonOutput
|
||||||
|
Required.JsonInput.StringFieldEscape.ProtobufOutput
|
||||||
|
Required.JsonInput.StringFieldNotAString
|
||||||
|
Required.JsonInput.StringFieldSurrogatePair.JsonOutput
|
||||||
|
Required.JsonInput.StringFieldSurrogatePair.ProtobufOutput
|
||||||
|
Required.JsonInput.StringFieldUnicodeEscape.JsonOutput
|
||||||
|
Required.JsonInput.StringFieldUnicodeEscape.ProtobufOutput
|
||||||
|
Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.JsonOutput
|
||||||
|
Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.ProtobufOutput
|
||||||
|
Required.JsonInput.Struct.JsonOutput
|
||||||
|
Required.JsonInput.Struct.ProtobufOutput
|
||||||
|
Required.JsonInput.TimestampMaxValue.JsonOutput
|
||||||
|
Required.JsonInput.TimestampMaxValue.ProtobufOutput
|
||||||
|
Required.JsonInput.TimestampMinValue.JsonOutput
|
||||||
|
Required.JsonInput.TimestampMinValue.ProtobufOutput
|
||||||
|
Required.JsonInput.TimestampRepeatedValue.JsonOutput
|
||||||
|
Required.JsonInput.TimestampRepeatedValue.ProtobufOutput
|
||||||
|
Required.JsonInput.TimestampWithNegativeOffset.JsonOutput
|
||||||
|
Required.JsonInput.TimestampWithNegativeOffset.ProtobufOutput
|
||||||
|
Required.JsonInput.TimestampWithPositiveOffset.JsonOutput
|
||||||
|
Required.JsonInput.TimestampWithPositiveOffset.ProtobufOutput
|
||||||
|
Required.JsonInput.Uint32FieldMaxFloatValue.JsonOutput
|
||||||
|
Required.JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
|
||||||
|
Required.JsonInput.Uint64FieldMaxValue.JsonOutput
|
||||||
|
Required.JsonInput.Uint64FieldMaxValue.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptBool.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptBool.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptFloat.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptFloat.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptInteger.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptInteger.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptList.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptList.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptNull.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptNull.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptObject.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptObject.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptString.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptString.ProtobufOutput
|
||||||
|
Required.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
|
||||||
|
Required.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
|
||||||
|
Required.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
|
||||||
|
Required.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput
|
||||||
|
Required.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput
|
||||||
|
Required.TimestampProtoInputTooLarge.JsonOutput
|
||||||
|
Required.TimestampProtoInputTooSmall.JsonOutput
|
|
@ -0,0 +1,225 @@
|
||||||
|
Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput
|
||||||
|
Recommended.FieldMaskPathsDontRoundTrip.JsonOutput
|
||||||
|
Recommended.FieldMaskTooManyUnderscore.JsonOutput
|
||||||
|
Recommended.JsonInput.BoolFieldIntegerOne
|
||||||
|
Recommended.JsonInput.BoolFieldIntegerZero
|
||||||
|
Recommended.JsonInput.DurationHas3FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.DurationHas6FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.DurationHas9FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator
|
||||||
|
Recommended.JsonInput.Int64FieldBeString.Validator
|
||||||
|
Recommended.JsonInput.OneofZeroBytes.JsonOutput
|
||||||
|
Recommended.JsonInput.OneofZeroBytes.ProtobufOutput
|
||||||
|
Recommended.JsonInput.OneofZeroDouble.JsonOutput
|
||||||
|
Recommended.JsonInput.OneofZeroDouble.ProtobufOutput
|
||||||
|
Recommended.JsonInput.OneofZeroFloat.JsonOutput
|
||||||
|
Recommended.JsonInput.OneofZeroFloat.ProtobufOutput
|
||||||
|
Recommended.JsonInput.OneofZeroString.JsonOutput
|
||||||
|
Recommended.JsonInput.OneofZeroString.ProtobufOutput
|
||||||
|
Recommended.JsonInput.OneofZeroUint32.JsonOutput
|
||||||
|
Recommended.JsonInput.OneofZeroUint32.ProtobufOutput
|
||||||
|
Recommended.JsonInput.OneofZeroUint64.JsonOutput
|
||||||
|
Recommended.JsonInput.OneofZeroUint64.ProtobufOutput
|
||||||
|
Recommended.JsonInput.StringEndsWithEscapeChar
|
||||||
|
Recommended.JsonInput.StringFieldSurrogateInWrongOrder
|
||||||
|
Recommended.JsonInput.StringFieldUnpairedHighSurrogate
|
||||||
|
Recommended.JsonInput.StringFieldUnpairedLowSurrogate
|
||||||
|
Recommended.JsonInput.TimestampHas3FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.TimestampHas6FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.TimestampHas9FractionalDigits.Validator
|
||||||
|
Recommended.JsonInput.TimestampHasZeroFractionalDigit.Validator
|
||||||
|
Recommended.JsonInput.TimestampZeroNormalized.Validator
|
||||||
|
Recommended.JsonInput.Uint64FieldBeString.Validator
|
||||||
|
Recommended.ProtobufInput.OneofZeroBytes.JsonOutput
|
||||||
|
Recommended.ProtobufInput.OneofZeroBytes.ProtobufOutput
|
||||||
|
Recommended.ProtobufInput.OneofZeroString.JsonOutput
|
||||||
|
Recommended.ProtobufInput.OneofZeroString.ProtobufOutput
|
||||||
|
Required.DurationProtoInputTooLarge.JsonOutput
|
||||||
|
Required.DurationProtoInputTooSmall.JsonOutput
|
||||||
|
Required.JsonInput.AllFieldAcceptNull.ProtobufOutput
|
||||||
|
Required.JsonInput.Any.JsonOutput
|
||||||
|
Required.JsonInput.Any.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyNested.JsonOutput
|
||||||
|
Required.JsonInput.AnyNested.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyUnorderedTypeTag.JsonOutput
|
||||||
|
Required.JsonInput.AnyUnorderedTypeTag.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithDuration.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithDuration.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithFieldMask.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithFieldMask.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithInt32ValueWrapper.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithStruct.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithStruct.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithTimestamp.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithTimestamp.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithValueForInteger.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithValueForInteger.ProtobufOutput
|
||||||
|
Required.JsonInput.AnyWithValueForJsonObject.JsonOutput
|
||||||
|
Required.JsonInput.AnyWithValueForJsonObject.ProtobufOutput
|
||||||
|
Required.JsonInput.BoolFieldFalse.ProtobufOutput
|
||||||
|
Required.JsonInput.BoolMapField.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldInfinity.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldInfinity.ProtobufOutput
|
||||||
|
Required.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput
|
||||||
|
Required.JsonInput.DoubleFieldMaxPositiveValue.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput
|
||||||
|
Required.JsonInput.DoubleFieldMinNegativeValue.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput
|
||||||
|
Required.JsonInput.DoubleFieldMinPositiveValue.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput
|
||||||
|
Required.JsonInput.DoubleFieldNan.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldNan.ProtobufOutput
|
||||||
|
Required.JsonInput.DoubleFieldNegativeInfinity.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput
|
||||||
|
Required.JsonInput.DoubleFieldQuotedValue.JsonOutput
|
||||||
|
Required.JsonInput.DoubleFieldQuotedValue.ProtobufOutput
|
||||||
|
Required.JsonInput.DurationMaxValue.JsonOutput
|
||||||
|
Required.JsonInput.DurationMaxValue.ProtobufOutput
|
||||||
|
Required.JsonInput.DurationMinValue.JsonOutput
|
||||||
|
Required.JsonInput.DurationMinValue.ProtobufOutput
|
||||||
|
Required.JsonInput.DurationRepeatedValue.JsonOutput
|
||||||
|
Required.JsonInput.DurationRepeatedValue.ProtobufOutput
|
||||||
|
Required.JsonInput.EnumField.ProtobufOutput
|
||||||
|
Required.JsonInput.EnumFieldNumericValueNonZero.JsonOutput
|
||||||
|
Required.JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
|
||||||
|
Required.JsonInput.EnumFieldNumericValueZero.JsonOutput
|
||||||
|
Required.JsonInput.EnumFieldNumericValueZero.ProtobufOutput
|
||||||
|
Required.JsonInput.EnumFieldUnknownValue.Validator
|
||||||
|
Required.JsonInput.FieldMask.JsonOutput
|
||||||
|
Required.JsonInput.FieldMask.ProtobufOutput
|
||||||
|
Required.JsonInput.FloatFieldInfinity.JsonOutput
|
||||||
|
Required.JsonInput.FloatFieldInfinity.ProtobufOutput
|
||||||
|
Required.JsonInput.FloatFieldNan.JsonOutput
|
||||||
|
Required.JsonInput.FloatFieldNan.ProtobufOutput
|
||||||
|
Required.JsonInput.FloatFieldNegativeInfinity.JsonOutput
|
||||||
|
Required.JsonInput.FloatFieldNegativeInfinity.ProtobufOutput
|
||||||
|
Required.JsonInput.FloatFieldQuotedValue.JsonOutput
|
||||||
|
Required.JsonInput.FloatFieldQuotedValue.ProtobufOutput
|
||||||
|
Required.JsonInput.FloatFieldTooLarge
|
||||||
|
Required.JsonInput.FloatFieldTooSmall
|
||||||
|
Required.JsonInput.Int32FieldExponentialFormat.JsonOutput
|
||||||
|
Required.JsonInput.Int32FieldExponentialFormat.ProtobufOutput
|
||||||
|
Required.JsonInput.Int32FieldFloatTrailingZero.JsonOutput
|
||||||
|
Required.JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
|
||||||
|
Required.JsonInput.Int32FieldMaxFloatValue.JsonOutput
|
||||||
|
Required.JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
|
||||||
|
Required.JsonInput.Int32FieldMinFloatValue.JsonOutput
|
||||||
|
Required.JsonInput.Int32FieldMinFloatValue.ProtobufOutput
|
||||||
|
Required.JsonInput.Int32FieldStringValue.JsonOutput
|
||||||
|
Required.JsonInput.Int32FieldStringValue.ProtobufOutput
|
||||||
|
Required.JsonInput.Int32FieldStringValueEscaped.JsonOutput
|
||||||
|
Required.JsonInput.Int32FieldStringValueEscaped.ProtobufOutput
|
||||||
|
Required.JsonInput.Int32MapEscapedKey.JsonOutput
|
||||||
|
Required.JsonInput.Int32MapEscapedKey.ProtobufOutput
|
||||||
|
Required.JsonInput.Int32MapField.JsonOutput
|
||||||
|
Required.JsonInput.Int32MapField.ProtobufOutput
|
||||||
|
Required.JsonInput.Int64FieldMaxValue.JsonOutput
|
||||||
|
Required.JsonInput.Int64FieldMaxValue.ProtobufOutput
|
||||||
|
Required.JsonInput.Int64FieldMinValue.JsonOutput
|
||||||
|
Required.JsonInput.Int64FieldMinValue.ProtobufOutput
|
||||||
|
Required.JsonInput.Int64MapEscapedKey.JsonOutput
|
||||||
|
Required.JsonInput.Int64MapEscapedKey.ProtobufOutput
|
||||||
|
Required.JsonInput.Int64MapField.JsonOutput
|
||||||
|
Required.JsonInput.Int64MapField.ProtobufOutput
|
||||||
|
Required.JsonInput.MessageField.JsonOutput
|
||||||
|
Required.JsonInput.MessageField.ProtobufOutput
|
||||||
|
Required.JsonInput.MessageMapField.JsonOutput
|
||||||
|
Required.JsonInput.MessageMapField.ProtobufOutput
|
||||||
|
Required.JsonInput.MessageRepeatedField.JsonOutput
|
||||||
|
Required.JsonInput.MessageRepeatedField.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalBoolWrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalBoolWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalBytesWrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalBytesWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalDoubleWrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalDoubleWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalFloatWrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalFloatWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalInt32Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalInt32Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalInt64Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalInt64Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalStringWrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalStringWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalUint32Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalUint32Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalUint64Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.OptionalUint64Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
|
||||||
|
Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
|
||||||
|
Required.JsonInput.PrimitiveRepeatedField.JsonOutput
|
||||||
|
Required.JsonInput.PrimitiveRepeatedField.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedBoolWrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedBoolWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedBytesWrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedBytesWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedDoubleWrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedDoubleWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
|
||||||
|
Required.JsonInput.RepeatedFloatWrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedFloatWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedInt32Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedInt32Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedInt64Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedInt64Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedStringWrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedStringWrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedUint32Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedUint32Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.RepeatedUint64Wrapper.JsonOutput
|
||||||
|
Required.JsonInput.RepeatedUint64Wrapper.ProtobufOutput
|
||||||
|
Required.JsonInput.StringFieldEscape.JsonOutput
|
||||||
|
Required.JsonInput.StringFieldEscape.ProtobufOutput
|
||||||
|
Required.JsonInput.StringFieldNotAString
|
||||||
|
Required.JsonInput.StringFieldSurrogatePair.JsonOutput
|
||||||
|
Required.JsonInput.StringFieldSurrogatePair.ProtobufOutput
|
||||||
|
Required.JsonInput.StringFieldUnicodeEscape.JsonOutput
|
||||||
|
Required.JsonInput.StringFieldUnicodeEscape.ProtobufOutput
|
||||||
|
Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.JsonOutput
|
||||||
|
Required.JsonInput.StringFieldUnicodeEscapeWithLowercaseHexLetters.ProtobufOutput
|
||||||
|
Required.JsonInput.Struct.JsonOutput
|
||||||
|
Required.JsonInput.Struct.ProtobufOutput
|
||||||
|
Required.JsonInput.TimestampMaxValue.JsonOutput
|
||||||
|
Required.JsonInput.TimestampMaxValue.ProtobufOutput
|
||||||
|
Required.JsonInput.TimestampMinValue.JsonOutput
|
||||||
|
Required.JsonInput.TimestampMinValue.ProtobufOutput
|
||||||
|
Required.JsonInput.TimestampRepeatedValue.JsonOutput
|
||||||
|
Required.JsonInput.TimestampRepeatedValue.ProtobufOutput
|
||||||
|
Required.JsonInput.TimestampWithNegativeOffset.JsonOutput
|
||||||
|
Required.JsonInput.TimestampWithNegativeOffset.ProtobufOutput
|
||||||
|
Required.JsonInput.TimestampWithPositiveOffset.JsonOutput
|
||||||
|
Required.JsonInput.TimestampWithPositiveOffset.ProtobufOutput
|
||||||
|
Required.JsonInput.Uint32FieldMaxFloatValue.JsonOutput
|
||||||
|
Required.JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
|
||||||
|
Required.JsonInput.Uint32MapField.JsonOutput
|
||||||
|
Required.JsonInput.Uint32MapField.ProtobufOutput
|
||||||
|
Required.JsonInput.Uint64FieldMaxValue.JsonOutput
|
||||||
|
Required.JsonInput.Uint64FieldMaxValue.ProtobufOutput
|
||||||
|
Required.JsonInput.Uint64MapField.JsonOutput
|
||||||
|
Required.JsonInput.Uint64MapField.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptBool.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptBool.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptFloat.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptFloat.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptInteger.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptInteger.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptList.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptList.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptNull.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptNull.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptObject.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptObject.ProtobufOutput
|
||||||
|
Required.JsonInput.ValueAcceptString.JsonOutput
|
||||||
|
Required.JsonInput.ValueAcceptString.ProtobufOutput
|
||||||
|
Required.JsonInput.WrapperTypesWithNullValue.ProtobufOutput
|
||||||
|
Required.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
|
||||||
|
Required.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
|
||||||
|
Required.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
|
||||||
|
Required.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput
|
||||||
|
Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED32.ProtobufOutput
|
||||||
|
Required.ProtobufInput.RepeatedScalarSelectsLast.FIXED64.ProtobufOutput
|
||||||
|
Required.ProtobufInput.RepeatedScalarSelectsLast.UINT64.ProtobufOutput
|
||||||
|
Required.TimestampProtoInputTooLarge.JsonOutput
|
||||||
|
Required.TimestampProtoInputTooSmall.JsonOutput
|
|
@ -1,85 +1,17 @@
|
||||||
DurationProtoInputTooLarge.JsonOutput
|
Recommended.JsonInput.DoubleFieldInfinityNotQuoted
|
||||||
DurationProtoInputTooSmall.JsonOutput
|
Recommended.JsonInput.DoubleFieldNanNotQuoted
|
||||||
FieldMaskNumbersDontRoundTrip.JsonOutput
|
Recommended.JsonInput.DoubleFieldNegativeInfinityNotQuoted
|
||||||
FieldMaskPathsDontRoundTrip.JsonOutput
|
Recommended.JsonInput.FloatFieldInfinityNotQuoted
|
||||||
FieldMaskTooManyUnderscore.JsonOutput
|
Recommended.JsonInput.FloatFieldNanNotQuoted
|
||||||
JsonInput.Any.JsonOutput
|
Recommended.JsonInput.FloatFieldNegativeInfinityNotQuoted
|
||||||
JsonInput.Any.ProtobufOutput
|
Required.JsonInput.BytesFieldInvalidBase64Characters
|
||||||
JsonInput.AnyNested.JsonOutput
|
Required.JsonInput.DoubleFieldTooSmall
|
||||||
JsonInput.AnyNested.ProtobufOutput
|
Required.JsonInput.EnumFieldUnknownValue.Validator
|
||||||
JsonInput.AnyUnorderedTypeTag.JsonOutput
|
Required.JsonInput.FloatFieldTooLarge
|
||||||
JsonInput.AnyUnorderedTypeTag.ProtobufOutput
|
Required.JsonInput.FloatFieldTooSmall
|
||||||
JsonInput.AnyWithDuration.JsonOutput
|
Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
|
||||||
JsonInput.AnyWithDuration.ProtobufOutput
|
Required.JsonInput.TimestampJsonInputLowercaseT
|
||||||
JsonInput.AnyWithFieldMask.JsonOutput
|
Required.ProtobufInput.IllegalZeroFieldNum_Case_0
|
||||||
JsonInput.AnyWithFieldMask.ProtobufOutput
|
Required.ProtobufInput.IllegalZeroFieldNum_Case_1
|
||||||
JsonInput.AnyWithInt32ValueWrapper.JsonOutput
|
Required.ProtobufInput.IllegalZeroFieldNum_Case_2
|
||||||
JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput
|
Required.ProtobufInput.IllegalZeroFieldNum_Case_3
|
||||||
JsonInput.AnyWithStruct.JsonOutput
|
|
||||||
JsonInput.AnyWithStruct.ProtobufOutput
|
|
||||||
JsonInput.AnyWithTimestamp.JsonOutput
|
|
||||||
JsonInput.AnyWithTimestamp.ProtobufOutput
|
|
||||||
JsonInput.AnyWithValueForInteger.JsonOutput
|
|
||||||
JsonInput.AnyWithValueForInteger.ProtobufOutput
|
|
||||||
JsonInput.AnyWithValueForJsonObject.JsonOutput
|
|
||||||
JsonInput.AnyWithValueForJsonObject.ProtobufOutput
|
|
||||||
JsonInput.BytesFieldInvalidBase64Characters
|
|
||||||
JsonInput.DoubleFieldInfinityNotQuoted
|
|
||||||
JsonInput.DoubleFieldNanNotQuoted
|
|
||||||
JsonInput.DoubleFieldNegativeInfinityNotQuoted
|
|
||||||
JsonInput.DoubleFieldTooSmall
|
|
||||||
JsonInput.DurationJsonInputTooLarge
|
|
||||||
JsonInput.DurationJsonInputTooSmall
|
|
||||||
JsonInput.DurationMissingS
|
|
||||||
JsonInput.EnumFieldNumericValueNonZero.JsonOutput
|
|
||||||
JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
|
|
||||||
JsonInput.EnumFieldNumericValueZero.JsonOutput
|
|
||||||
JsonInput.EnumFieldNumericValueZero.ProtobufOutput
|
|
||||||
JsonInput.EnumFieldUnknownValue.Validator
|
|
||||||
JsonInput.FieldMask.ProtobufOutput
|
|
||||||
JsonInput.FieldMaskInvalidCharacter
|
|
||||||
JsonInput.FieldNameInLowerCamelCase.Validator
|
|
||||||
JsonInput.FieldNameInSnakeCase.JsonOutput
|
|
||||||
JsonInput.FieldNameInSnakeCase.ProtobufOutput
|
|
||||||
JsonInput.FloatFieldInfinityNotQuoted
|
|
||||||
JsonInput.FloatFieldNanNotQuoted
|
|
||||||
JsonInput.FloatFieldNegativeInfinityNotQuoted
|
|
||||||
JsonInput.FloatFieldTooLarge
|
|
||||||
JsonInput.FloatFieldTooSmall
|
|
||||||
JsonInput.Int32FieldExponentialFormat.JsonOutput
|
|
||||||
JsonInput.Int32FieldExponentialFormat.ProtobufOutput
|
|
||||||
JsonInput.Int32FieldFloatTrailingZero.JsonOutput
|
|
||||||
JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
|
|
||||||
JsonInput.Int32FieldMaxFloatValue.JsonOutput
|
|
||||||
JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
|
|
||||||
JsonInput.Int32FieldMinFloatValue.JsonOutput
|
|
||||||
JsonInput.Int32FieldMinFloatValue.ProtobufOutput
|
|
||||||
JsonInput.Int32FieldMinValue.JsonOutput
|
|
||||||
JsonInput.OriginalProtoFieldName.JsonOutput
|
|
||||||
JsonInput.OriginalProtoFieldName.ProtobufOutput
|
|
||||||
JsonInput.RepeatedFieldMessageElementIsNull
|
|
||||||
JsonInput.RepeatedFieldPrimitiveElementIsNull
|
|
||||||
JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
|
|
||||||
JsonInput.StringFieldSurrogatePair.JsonOutput
|
|
||||||
JsonInput.StringFieldUnpairedLowSurrogate
|
|
||||||
JsonInput.Struct.JsonOutput
|
|
||||||
JsonInput.Struct.ProtobufOutput
|
|
||||||
JsonInput.TimestampJsonInputLowercaseT
|
|
||||||
JsonInput.Uint32FieldMaxFloatValue.JsonOutput
|
|
||||||
JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptBool.JsonOutput
|
|
||||||
JsonInput.ValueAcceptBool.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptFloat.JsonOutput
|
|
||||||
JsonInput.ValueAcceptFloat.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptInteger.JsonOutput
|
|
||||||
JsonInput.ValueAcceptInteger.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptList.JsonOutput
|
|
||||||
JsonInput.ValueAcceptList.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptNull.JsonOutput
|
|
||||||
JsonInput.ValueAcceptNull.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptObject.JsonOutput
|
|
||||||
JsonInput.ValueAcceptObject.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptString.JsonOutput
|
|
||||||
JsonInput.ValueAcceptString.ProtobufOutput
|
|
||||||
TimestampProtoInputTooLarge.JsonOutput
|
|
||||||
TimestampProtoInputTooSmall.JsonOutput
|
|
||||||
|
|
|
@ -7,104 +7,32 @@
|
||||||
# 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?
|
||||||
|
|
||||||
DurationProtoInputTooLarge.JsonOutput
|
Recommended.JsonInput.DoubleFieldInfinityNotQuoted
|
||||||
DurationProtoInputTooSmall.JsonOutput
|
Recommended.JsonInput.DoubleFieldNanNotQuoted
|
||||||
FieldMaskNumbersDontRoundTrip.JsonOutput
|
Recommended.JsonInput.DoubleFieldNegativeInfinityNotQuoted
|
||||||
FieldMaskPathsDontRoundTrip.JsonOutput
|
Recommended.JsonInput.FloatFieldInfinityNotQuoted
|
||||||
FieldMaskTooManyUnderscore.JsonOutput
|
Recommended.JsonInput.FloatFieldNanNotQuoted
|
||||||
JsonInput.Any.JsonOutput
|
Recommended.JsonInput.FloatFieldNegativeInfinityNotQuoted
|
||||||
JsonInput.Any.ProtobufOutput
|
Required.JsonInput.BytesFieldInvalidBase64Characters
|
||||||
JsonInput.AnyNested.JsonOutput
|
Required.JsonInput.DoubleFieldTooSmall
|
||||||
JsonInput.AnyNested.ProtobufOutput
|
Required.JsonInput.EnumFieldUnknownValue.Validator
|
||||||
JsonInput.AnyUnorderedTypeTag.JsonOutput
|
Required.JsonInput.FloatFieldTooLarge
|
||||||
JsonInput.AnyUnorderedTypeTag.ProtobufOutput
|
Required.JsonInput.FloatFieldTooSmall
|
||||||
JsonInput.AnyWithDuration.JsonOutput
|
Required.JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
|
||||||
JsonInput.AnyWithDuration.ProtobufOutput
|
Required.JsonInput.TimestampJsonInputLowercaseT
|
||||||
JsonInput.AnyWithFieldMask.JsonOutput
|
Required.ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
|
||||||
JsonInput.AnyWithFieldMask.ProtobufOutput
|
Required.ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
|
||||||
JsonInput.AnyWithInt32ValueWrapper.JsonOutput
|
Required.ProtobufInput.PrematureEofInPackedField.BOOL
|
||||||
JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput
|
Required.ProtobufInput.PrematureEofInPackedField.DOUBLE
|
||||||
JsonInput.AnyWithStruct.JsonOutput
|
Required.ProtobufInput.PrematureEofInPackedField.ENUM
|
||||||
JsonInput.AnyWithStruct.ProtobufOutput
|
Required.ProtobufInput.PrematureEofInPackedField.FIXED32
|
||||||
JsonInput.AnyWithTimestamp.JsonOutput
|
Required.ProtobufInput.PrematureEofInPackedField.FIXED64
|
||||||
JsonInput.AnyWithTimestamp.ProtobufOutput
|
Required.ProtobufInput.PrematureEofInPackedField.FLOAT
|
||||||
JsonInput.AnyWithValueForInteger.JsonOutput
|
Required.ProtobufInput.PrematureEofInPackedField.INT32
|
||||||
JsonInput.AnyWithValueForInteger.ProtobufOutput
|
Required.ProtobufInput.PrematureEofInPackedField.INT64
|
||||||
JsonInput.AnyWithValueForJsonObject.JsonOutput
|
Required.ProtobufInput.PrematureEofInPackedField.SFIXED32
|
||||||
JsonInput.AnyWithValueForJsonObject.ProtobufOutput
|
Required.ProtobufInput.PrematureEofInPackedField.SFIXED64
|
||||||
JsonInput.BytesFieldInvalidBase64Characters
|
Required.ProtobufInput.PrematureEofInPackedField.SINT32
|
||||||
JsonInput.DoubleFieldInfinityNotQuoted
|
Required.ProtobufInput.PrematureEofInPackedField.SINT64
|
||||||
JsonInput.DoubleFieldNanNotQuoted
|
Required.ProtobufInput.PrematureEofInPackedField.UINT32
|
||||||
JsonInput.DoubleFieldNegativeInfinityNotQuoted
|
Required.ProtobufInput.PrematureEofInPackedField.UINT64
|
||||||
JsonInput.DoubleFieldTooSmall
|
|
||||||
JsonInput.DurationJsonInputTooLarge
|
|
||||||
JsonInput.DurationJsonInputTooSmall
|
|
||||||
JsonInput.DurationMissingS
|
|
||||||
JsonInput.EnumFieldNumericValueNonZero.JsonOutput
|
|
||||||
JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
|
|
||||||
JsonInput.EnumFieldNumericValueZero.JsonOutput
|
|
||||||
JsonInput.EnumFieldNumericValueZero.ProtobufOutput
|
|
||||||
JsonInput.EnumFieldUnknownValue.Validator
|
|
||||||
JsonInput.FieldMask.ProtobufOutput
|
|
||||||
JsonInput.FieldMaskInvalidCharacter
|
|
||||||
JsonInput.FieldNameInLowerCamelCase.Validator
|
|
||||||
JsonInput.FieldNameInSnakeCase.JsonOutput
|
|
||||||
JsonInput.FieldNameInSnakeCase.ProtobufOutput
|
|
||||||
JsonInput.FloatFieldInfinityNotQuoted
|
|
||||||
JsonInput.FloatFieldNanNotQuoted
|
|
||||||
JsonInput.FloatFieldNegativeInfinityNotQuoted
|
|
||||||
JsonInput.FloatFieldTooLarge
|
|
||||||
JsonInput.FloatFieldTooSmall
|
|
||||||
JsonInput.Int32FieldExponentialFormat.JsonOutput
|
|
||||||
JsonInput.Int32FieldExponentialFormat.ProtobufOutput
|
|
||||||
JsonInput.Int32FieldFloatTrailingZero.JsonOutput
|
|
||||||
JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
|
|
||||||
JsonInput.Int32FieldMaxFloatValue.JsonOutput
|
|
||||||
JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
|
|
||||||
JsonInput.Int32FieldMinFloatValue.JsonOutput
|
|
||||||
JsonInput.Int32FieldMinFloatValue.ProtobufOutput
|
|
||||||
JsonInput.Int32FieldMinValue.JsonOutput
|
|
||||||
JsonInput.OriginalProtoFieldName.JsonOutput
|
|
||||||
JsonInput.OriginalProtoFieldName.ProtobufOutput
|
|
||||||
JsonInput.RepeatedFieldMessageElementIsNull
|
|
||||||
JsonInput.RepeatedFieldPrimitiveElementIsNull
|
|
||||||
JsonInput.RepeatedFieldWrongElementTypeExpectingIntegersGotBool
|
|
||||||
JsonInput.StringFieldSurrogatePair.JsonOutput
|
|
||||||
JsonInput.StringFieldUnpairedLowSurrogate
|
|
||||||
JsonInput.Struct.JsonOutput
|
|
||||||
JsonInput.Struct.ProtobufOutput
|
|
||||||
JsonInput.TimestampJsonInputLowercaseT
|
|
||||||
JsonInput.Uint32FieldMaxFloatValue.JsonOutput
|
|
||||||
JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptBool.JsonOutput
|
|
||||||
JsonInput.ValueAcceptBool.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptFloat.JsonOutput
|
|
||||||
JsonInput.ValueAcceptFloat.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptInteger.JsonOutput
|
|
||||||
JsonInput.ValueAcceptInteger.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptList.JsonOutput
|
|
||||||
JsonInput.ValueAcceptList.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptNull.JsonOutput
|
|
||||||
JsonInput.ValueAcceptNull.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptObject.JsonOutput
|
|
||||||
JsonInput.ValueAcceptObject.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptString.JsonOutput
|
|
||||||
JsonInput.ValueAcceptString.ProtobufOutput
|
|
||||||
ProtobufInput.PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE
|
|
||||||
ProtobufInput.PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE
|
|
||||||
ProtobufInput.PrematureEofInPackedField.BOOL
|
|
||||||
ProtobufInput.PrematureEofInPackedField.DOUBLE
|
|
||||||
ProtobufInput.PrematureEofInPackedField.ENUM
|
|
||||||
ProtobufInput.PrematureEofInPackedField.FIXED32
|
|
||||||
ProtobufInput.PrematureEofInPackedField.FIXED64
|
|
||||||
ProtobufInput.PrematureEofInPackedField.FLOAT
|
|
||||||
ProtobufInput.PrematureEofInPackedField.INT32
|
|
||||||
ProtobufInput.PrematureEofInPackedField.INT64
|
|
||||||
ProtobufInput.PrematureEofInPackedField.SFIXED32
|
|
||||||
ProtobufInput.PrematureEofInPackedField.SFIXED64
|
|
||||||
ProtobufInput.PrematureEofInPackedField.SINT32
|
|
||||||
ProtobufInput.PrematureEofInPackedField.SINT64
|
|
||||||
ProtobufInput.PrematureEofInPackedField.UINT32
|
|
||||||
ProtobufInput.PrematureEofInPackedField.UINT64
|
|
||||||
TimestampProtoInputTooLarge.JsonOutput
|
|
||||||
TimestampProtoInputTooSmall.JsonOutput
|
|
||||||
|
|
|
@ -1,199 +1,135 @@
|
||||||
DurationProtoInputTooLarge.JsonOutput
|
Recommended.FieldMaskNumbersDontRoundTrip.JsonOutput
|
||||||
DurationProtoInputTooSmall.JsonOutput
|
Recommended.FieldMaskPathsDontRoundTrip.JsonOutput
|
||||||
FieldMaskNumbersDontRoundTrip.JsonOutput
|
Recommended.FieldMaskTooManyUnderscore.JsonOutput
|
||||||
FieldMaskPathsDontRoundTrip.JsonOutput
|
Recommended.JsonInput.DurationHas3FractionalDigits.Validator
|
||||||
FieldMaskTooManyUnderscore.JsonOutput
|
Recommended.JsonInput.DurationHas6FractionalDigits.Validator
|
||||||
JsonInput.Any.JsonOutput
|
Recommended.JsonInput.DurationHas9FractionalDigits.Validator
|
||||||
JsonInput.Any.ProtobufOutput
|
Recommended.JsonInput.DurationHasZeroFractionalDigit.Validator
|
||||||
JsonInput.AnyNested.JsonOutput
|
Recommended.JsonInput.Int64FieldBeString.Validator
|
||||||
JsonInput.AnyNested.ProtobufOutput
|
Recommended.JsonInput.MapFieldValueIsNull
|
||||||
JsonInput.AnyUnorderedTypeTag.JsonOutput
|
Recommended.JsonInput.RepeatedFieldMessageElementIsNull
|
||||||
JsonInput.AnyUnorderedTypeTag.ProtobufOutput
|
Recommended.JsonInput.RepeatedFieldPrimitiveElementIsNull
|
||||||
JsonInput.AnyWithDuration.JsonOutput
|
Recommended.JsonInput.StringEndsWithEscapeChar
|
||||||
JsonInput.AnyWithDuration.ProtobufOutput
|
Recommended.JsonInput.StringFieldSurrogateInWrongOrder
|
||||||
JsonInput.AnyWithFieldMask.JsonOutput
|
Recommended.JsonInput.StringFieldUnpairedHighSurrogate
|
||||||
JsonInput.AnyWithFieldMask.ProtobufOutput
|
Recommended.JsonInput.StringFieldUnpairedLowSurrogate
|
||||||
JsonInput.AnyWithInt32ValueWrapper.JsonOutput
|
Recommended.JsonInput.TimestampHas3FractionalDigits.Validator
|
||||||
JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput
|
Recommended.JsonInput.TimestampHas6FractionalDigits.Validator
|
||||||
JsonInput.AnyWithStruct.JsonOutput
|
Recommended.JsonInput.TimestampHas9FractionalDigits.Validator
|
||||||
JsonInput.AnyWithStruct.ProtobufOutput
|
Recommended.JsonInput.TimestampHasZeroFractionalDigit.Validator
|
||||||
JsonInput.AnyWithTimestamp.JsonOutput
|
Recommended.JsonInput.TimestampZeroNormalized.Validator
|
||||||
JsonInput.AnyWithTimestamp.ProtobufOutput
|
Recommended.JsonInput.Uint64FieldBeString.Validator
|
||||||
JsonInput.AnyWithValueForInteger.JsonOutput
|
Required.DurationProtoInputTooLarge.JsonOutput
|
||||||
JsonInput.AnyWithValueForInteger.ProtobufOutput
|
Required.DurationProtoInputTooSmall.JsonOutput
|
||||||
JsonInput.AnyWithValueForJsonObject.JsonOutput
|
Required.JsonInput.Any.JsonOutput
|
||||||
JsonInput.AnyWithValueForJsonObject.ProtobufOutput
|
Required.JsonInput.Any.ProtobufOutput
|
||||||
JsonInput.BoolFieldIntegerOne
|
Required.JsonInput.AnyNested.JsonOutput
|
||||||
JsonInput.BoolFieldIntegerZero
|
Required.JsonInput.AnyNested.ProtobufOutput
|
||||||
JsonInput.DoubleFieldInfinity.JsonOutput
|
Required.JsonInput.AnyUnorderedTypeTag.JsonOutput
|
||||||
JsonInput.DoubleFieldInfinity.ProtobufOutput
|
Required.JsonInput.AnyUnorderedTypeTag.ProtobufOutput
|
||||||
JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
|
Required.JsonInput.AnyWithDuration.JsonOutput
|
||||||
JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput
|
Required.JsonInput.AnyWithDuration.ProtobufOutput
|
||||||
JsonInput.DoubleFieldMaxPositiveValue.JsonOutput
|
Required.JsonInput.AnyWithFieldMask.JsonOutput
|
||||||
JsonInput.DoubleFieldMaxPositiveValue.ProtobufOutput
|
Required.JsonInput.AnyWithFieldMask.ProtobufOutput
|
||||||
JsonInput.DoubleFieldMinNegativeValue.JsonOutput
|
Required.JsonInput.AnyWithInt32ValueWrapper.JsonOutput
|
||||||
JsonInput.DoubleFieldMinNegativeValue.ProtobufOutput
|
Required.JsonInput.AnyWithInt32ValueWrapper.ProtobufOutput
|
||||||
JsonInput.DoubleFieldMinPositiveValue.JsonOutput
|
Required.JsonInput.AnyWithStruct.JsonOutput
|
||||||
JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput
|
Required.JsonInput.AnyWithStruct.ProtobufOutput
|
||||||
JsonInput.DoubleFieldNan.JsonOutput
|
Required.JsonInput.AnyWithTimestamp.JsonOutput
|
||||||
JsonInput.DoubleFieldNan.ProtobufOutput
|
Required.JsonInput.AnyWithTimestamp.ProtobufOutput
|
||||||
JsonInput.DoubleFieldNegativeInfinity.JsonOutput
|
Required.JsonInput.AnyWithValueForInteger.JsonOutput
|
||||||
JsonInput.DoubleFieldNegativeInfinity.ProtobufOutput
|
Required.JsonInput.AnyWithValueForInteger.ProtobufOutput
|
||||||
JsonInput.DoubleFieldQuotedValue.JsonOutput
|
Required.JsonInput.AnyWithValueForJsonObject.JsonOutput
|
||||||
JsonInput.DoubleFieldQuotedValue.ProtobufOutput
|
Required.JsonInput.AnyWithValueForJsonObject.ProtobufOutput
|
||||||
JsonInput.DurationHas3FractionalDigits.Validator
|
Required.JsonInput.DoubleFieldMaxNegativeValue.JsonOutput
|
||||||
JsonInput.DurationHas6FractionalDigits.Validator
|
Required.JsonInput.DoubleFieldMaxNegativeValue.ProtobufOutput
|
||||||
JsonInput.DurationHas9FractionalDigits.Validator
|
Required.JsonInput.DoubleFieldMinPositiveValue.JsonOutput
|
||||||
JsonInput.DurationHasZeroFractionalDigit.Validator
|
Required.JsonInput.DoubleFieldMinPositiveValue.ProtobufOutput
|
||||||
JsonInput.DurationMaxValue.JsonOutput
|
Required.JsonInput.DoubleFieldNan.JsonOutput
|
||||||
JsonInput.DurationMaxValue.ProtobufOutput
|
Required.JsonInput.DurationMaxValue.JsonOutput
|
||||||
JsonInput.DurationMinValue.JsonOutput
|
Required.JsonInput.DurationMaxValue.ProtobufOutput
|
||||||
JsonInput.DurationMinValue.ProtobufOutput
|
Required.JsonInput.DurationMinValue.JsonOutput
|
||||||
JsonInput.DurationRepeatedValue.JsonOutput
|
Required.JsonInput.DurationMinValue.ProtobufOutput
|
||||||
JsonInput.DurationRepeatedValue.ProtobufOutput
|
Required.JsonInput.DurationRepeatedValue.JsonOutput
|
||||||
JsonInput.EnumFieldNumericValueNonZero.JsonOutput
|
Required.JsonInput.DurationRepeatedValue.ProtobufOutput
|
||||||
JsonInput.EnumFieldNumericValueNonZero.ProtobufOutput
|
Required.JsonInput.FieldMask.JsonOutput
|
||||||
JsonInput.EnumFieldNumericValueZero.JsonOutput
|
Required.JsonInput.FieldMask.ProtobufOutput
|
||||||
JsonInput.EnumFieldNumericValueZero.ProtobufOutput
|
Required.JsonInput.FloatFieldInfinity.JsonOutput
|
||||||
JsonInput.EnumFieldUnknownValue.Validator
|
Required.JsonInput.FloatFieldNan.JsonOutput
|
||||||
JsonInput.FieldMask.JsonOutput
|
Required.JsonInput.FloatFieldNegativeInfinity.JsonOutput
|
||||||
JsonInput.FieldMask.ProtobufOutput
|
Required.JsonInput.FloatFieldTooLarge
|
||||||
JsonInput.FieldNameInSnakeCase.JsonOutput
|
Required.JsonInput.FloatFieldTooSmall
|
||||||
JsonInput.FieldNameWithMixedCases.JsonOutput
|
Required.JsonInput.OneofFieldDuplicate
|
||||||
JsonInput.FieldNameWithMixedCases.ProtobufOutput
|
Required.JsonInput.OptionalBoolWrapper.JsonOutput
|
||||||
JsonInput.FieldNameWithMixedCases.Validator
|
Required.JsonInput.OptionalBoolWrapper.ProtobufOutput
|
||||||
JsonInput.FloatFieldInfinity.JsonOutput
|
Required.JsonInput.OptionalBytesWrapper.JsonOutput
|
||||||
JsonInput.FloatFieldInfinity.ProtobufOutput
|
Required.JsonInput.OptionalBytesWrapper.ProtobufOutput
|
||||||
JsonInput.FloatFieldNan.JsonOutput
|
Required.JsonInput.OptionalDoubleWrapper.JsonOutput
|
||||||
JsonInput.FloatFieldNan.ProtobufOutput
|
Required.JsonInput.OptionalDoubleWrapper.ProtobufOutput
|
||||||
JsonInput.FloatFieldNegativeInfinity.JsonOutput
|
Required.JsonInput.OptionalFloatWrapper.JsonOutput
|
||||||
JsonInput.FloatFieldNegativeInfinity.ProtobufOutput
|
Required.JsonInput.OptionalFloatWrapper.ProtobufOutput
|
||||||
JsonInput.FloatFieldQuotedValue.JsonOutput
|
Required.JsonInput.OptionalInt32Wrapper.JsonOutput
|
||||||
JsonInput.FloatFieldQuotedValue.ProtobufOutput
|
Required.JsonInput.OptionalInt32Wrapper.ProtobufOutput
|
||||||
JsonInput.FloatFieldTooLarge
|
Required.JsonInput.OptionalInt64Wrapper.JsonOutput
|
||||||
JsonInput.FloatFieldTooSmall
|
Required.JsonInput.OptionalInt64Wrapper.ProtobufOutput
|
||||||
JsonInput.Int32FieldExponentialFormat.JsonOutput
|
Required.JsonInput.OptionalStringWrapper.JsonOutput
|
||||||
JsonInput.Int32FieldExponentialFormat.ProtobufOutput
|
Required.JsonInput.OptionalStringWrapper.ProtobufOutput
|
||||||
JsonInput.Int32FieldFloatTrailingZero.JsonOutput
|
Required.JsonInput.OptionalUint32Wrapper.JsonOutput
|
||||||
JsonInput.Int32FieldFloatTrailingZero.ProtobufOutput
|
Required.JsonInput.OptionalUint32Wrapper.ProtobufOutput
|
||||||
JsonInput.Int32FieldMaxFloatValue.JsonOutput
|
Required.JsonInput.OptionalUint64Wrapper.JsonOutput
|
||||||
JsonInput.Int32FieldMaxFloatValue.ProtobufOutput
|
Required.JsonInput.OptionalUint64Wrapper.ProtobufOutput
|
||||||
JsonInput.Int32FieldMinFloatValue.JsonOutput
|
Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
|
||||||
JsonInput.Int32FieldMinFloatValue.ProtobufOutput
|
Required.JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
|
||||||
JsonInput.Int32FieldStringValue.JsonOutput
|
Required.JsonInput.RepeatedBoolWrapper.JsonOutput
|
||||||
JsonInput.Int32FieldStringValue.ProtobufOutput
|
Required.JsonInput.RepeatedBoolWrapper.ProtobufOutput
|
||||||
JsonInput.Int32FieldStringValueEscaped.JsonOutput
|
Required.JsonInput.RepeatedBytesWrapper.JsonOutput
|
||||||
JsonInput.Int32FieldStringValueEscaped.ProtobufOutput
|
Required.JsonInput.RepeatedBytesWrapper.ProtobufOutput
|
||||||
JsonInput.Int32MapEscapedKey.JsonOutput
|
Required.JsonInput.RepeatedDoubleWrapper.JsonOutput
|
||||||
JsonInput.Int32MapEscapedKey.ProtobufOutput
|
Required.JsonInput.RepeatedDoubleWrapper.ProtobufOutput
|
||||||
JsonInput.Int32MapField.JsonOutput
|
Required.JsonInput.RepeatedFloatWrapper.JsonOutput
|
||||||
JsonInput.Int32MapField.ProtobufOutput
|
Required.JsonInput.RepeatedFloatWrapper.ProtobufOutput
|
||||||
JsonInput.Int64FieldBeString.Validator
|
Required.JsonInput.RepeatedInt32Wrapper.JsonOutput
|
||||||
JsonInput.Int64FieldMaxValue.JsonOutput
|
Required.JsonInput.RepeatedInt32Wrapper.ProtobufOutput
|
||||||
JsonInput.Int64FieldMaxValue.ProtobufOutput
|
Required.JsonInput.RepeatedInt64Wrapper.JsonOutput
|
||||||
JsonInput.Int64FieldMinValue.JsonOutput
|
Required.JsonInput.RepeatedInt64Wrapper.ProtobufOutput
|
||||||
JsonInput.Int64FieldMinValue.ProtobufOutput
|
Required.JsonInput.RepeatedStringWrapper.JsonOutput
|
||||||
JsonInput.Int64MapEscapedKey.JsonOutput
|
Required.JsonInput.RepeatedStringWrapper.ProtobufOutput
|
||||||
JsonInput.Int64MapEscapedKey.ProtobufOutput
|
Required.JsonInput.RepeatedUint32Wrapper.JsonOutput
|
||||||
JsonInput.Int64MapField.JsonOutput
|
Required.JsonInput.RepeatedUint32Wrapper.ProtobufOutput
|
||||||
JsonInput.Int64MapField.ProtobufOutput
|
Required.JsonInput.RepeatedUint64Wrapper.JsonOutput
|
||||||
JsonInput.MessageField.JsonOutput
|
Required.JsonInput.RepeatedUint64Wrapper.ProtobufOutput
|
||||||
JsonInput.MessageField.ProtobufOutput
|
Required.JsonInput.StringFieldSurrogatePair.JsonOutput
|
||||||
JsonInput.MessageMapField.JsonOutput
|
Required.JsonInput.StringFieldSurrogatePair.ProtobufOutput
|
||||||
JsonInput.MessageMapField.ProtobufOutput
|
Required.JsonInput.Struct.JsonOutput
|
||||||
JsonInput.MessageRepeatedField.JsonOutput
|
Required.JsonInput.Struct.ProtobufOutput
|
||||||
JsonInput.MessageRepeatedField.ProtobufOutput
|
Required.JsonInput.TimestampMaxValue.JsonOutput
|
||||||
JsonInput.OptionalBoolWrapper.JsonOutput
|
Required.JsonInput.TimestampMaxValue.ProtobufOutput
|
||||||
JsonInput.OptionalBoolWrapper.ProtobufOutput
|
Required.JsonInput.TimestampMinValue.JsonOutput
|
||||||
JsonInput.OptionalBytesWrapper.JsonOutput
|
Required.JsonInput.TimestampMinValue.ProtobufOutput
|
||||||
JsonInput.OptionalBytesWrapper.ProtobufOutput
|
Required.JsonInput.TimestampRepeatedValue.JsonOutput
|
||||||
JsonInput.OptionalDoubleWrapper.JsonOutput
|
Required.JsonInput.TimestampRepeatedValue.ProtobufOutput
|
||||||
JsonInput.OptionalDoubleWrapper.ProtobufOutput
|
Required.JsonInput.TimestampWithNegativeOffset.JsonOutput
|
||||||
JsonInput.OptionalFloatWrapper.JsonOutput
|
Required.JsonInput.TimestampWithNegativeOffset.ProtobufOutput
|
||||||
JsonInput.OptionalFloatWrapper.ProtobufOutput
|
Required.JsonInput.TimestampWithPositiveOffset.JsonOutput
|
||||||
JsonInput.OptionalInt32Wrapper.JsonOutput
|
Required.JsonInput.TimestampWithPositiveOffset.ProtobufOutput
|
||||||
JsonInput.OptionalInt32Wrapper.ProtobufOutput
|
Required.JsonInput.ValueAcceptBool.JsonOutput
|
||||||
JsonInput.OptionalInt64Wrapper.JsonOutput
|
Required.JsonInput.ValueAcceptBool.ProtobufOutput
|
||||||
JsonInput.OptionalInt64Wrapper.ProtobufOutput
|
Required.JsonInput.ValueAcceptFloat.JsonOutput
|
||||||
JsonInput.OptionalStringWrapper.JsonOutput
|
Required.JsonInput.ValueAcceptFloat.ProtobufOutput
|
||||||
JsonInput.OptionalStringWrapper.ProtobufOutput
|
Required.JsonInput.ValueAcceptInteger.JsonOutput
|
||||||
JsonInput.OptionalUint32Wrapper.JsonOutput
|
Required.JsonInput.ValueAcceptInteger.ProtobufOutput
|
||||||
JsonInput.OptionalUint32Wrapper.ProtobufOutput
|
Required.JsonInput.ValueAcceptList.JsonOutput
|
||||||
JsonInput.OptionalUint64Wrapper.JsonOutput
|
Required.JsonInput.ValueAcceptList.ProtobufOutput
|
||||||
JsonInput.OptionalUint64Wrapper.ProtobufOutput
|
Required.JsonInput.ValueAcceptNull.JsonOutput
|
||||||
JsonInput.OptionalWrapperTypesWithNonDefaultValue.JsonOutput
|
Required.JsonInput.ValueAcceptNull.ProtobufOutput
|
||||||
JsonInput.OptionalWrapperTypesWithNonDefaultValue.ProtobufOutput
|
Required.JsonInput.ValueAcceptObject.JsonOutput
|
||||||
JsonInput.OriginalProtoFieldName.JsonOutput
|
Required.JsonInput.ValueAcceptObject.ProtobufOutput
|
||||||
JsonInput.PrimitiveRepeatedField.JsonOutput
|
Required.JsonInput.ValueAcceptString.JsonOutput
|
||||||
JsonInput.PrimitiveRepeatedField.ProtobufOutput
|
Required.JsonInput.ValueAcceptString.ProtobufOutput
|
||||||
JsonInput.RepeatedBoolWrapper.JsonOutput
|
Required.ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
|
||||||
JsonInput.RepeatedBoolWrapper.ProtobufOutput
|
Required.ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
|
||||||
JsonInput.RepeatedBytesWrapper.JsonOutput
|
Required.ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
|
||||||
JsonInput.RepeatedBytesWrapper.ProtobufOutput
|
Required.ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput
|
||||||
JsonInput.RepeatedDoubleWrapper.JsonOutput
|
Required.ProtobufInput.ValidDataRepeated.FLOAT.JsonOutput
|
||||||
JsonInput.RepeatedDoubleWrapper.ProtobufOutput
|
Required.TimestampProtoInputTooLarge.JsonOutput
|
||||||
JsonInput.RepeatedFieldWrongElementTypeExpectingStringsGotInt
|
Required.TimestampProtoInputTooSmall.JsonOutput
|
||||||
JsonInput.RepeatedFloatWrapper.JsonOutput
|
|
||||||
JsonInput.RepeatedFloatWrapper.ProtobufOutput
|
|
||||||
JsonInput.RepeatedInt32Wrapper.JsonOutput
|
|
||||||
JsonInput.RepeatedInt32Wrapper.ProtobufOutput
|
|
||||||
JsonInput.RepeatedInt64Wrapper.JsonOutput
|
|
||||||
JsonInput.RepeatedInt64Wrapper.ProtobufOutput
|
|
||||||
JsonInput.RepeatedStringWrapper.JsonOutput
|
|
||||||
JsonInput.RepeatedStringWrapper.ProtobufOutput
|
|
||||||
JsonInput.RepeatedUint32Wrapper.JsonOutput
|
|
||||||
JsonInput.RepeatedUint32Wrapper.ProtobufOutput
|
|
||||||
JsonInput.RepeatedUint64Wrapper.JsonOutput
|
|
||||||
JsonInput.RepeatedUint64Wrapper.ProtobufOutput
|
|
||||||
JsonInput.StringFieldNotAString
|
|
||||||
JsonInput.StringFieldSurrogateInWrongOrder
|
|
||||||
JsonInput.StringFieldSurrogatePair.JsonOutput
|
|
||||||
JsonInput.StringFieldSurrogatePair.ProtobufOutput
|
|
||||||
JsonInput.StringFieldUnpairedHighSurrogate
|
|
||||||
JsonInput.StringFieldUnpairedLowSurrogate
|
|
||||||
JsonInput.Struct.JsonOutput
|
|
||||||
JsonInput.Struct.ProtobufOutput
|
|
||||||
JsonInput.TimestampHas3FractionalDigits.Validator
|
|
||||||
JsonInput.TimestampHas6FractionalDigits.Validator
|
|
||||||
JsonInput.TimestampHas9FractionalDigits.Validator
|
|
||||||
JsonInput.TimestampHasZeroFractionalDigit.Validator
|
|
||||||
JsonInput.TimestampMaxValue.JsonOutput
|
|
||||||
JsonInput.TimestampMaxValue.ProtobufOutput
|
|
||||||
JsonInput.TimestampMinValue.JsonOutput
|
|
||||||
JsonInput.TimestampMinValue.ProtobufOutput
|
|
||||||
JsonInput.TimestampRepeatedValue.JsonOutput
|
|
||||||
JsonInput.TimestampRepeatedValue.ProtobufOutput
|
|
||||||
JsonInput.TimestampWithNegativeOffset.JsonOutput
|
|
||||||
JsonInput.TimestampWithNegativeOffset.ProtobufOutput
|
|
||||||
JsonInput.TimestampWithPositiveOffset.JsonOutput
|
|
||||||
JsonInput.TimestampWithPositiveOffset.ProtobufOutput
|
|
||||||
JsonInput.TimestampZeroNormalized.Validator
|
|
||||||
JsonInput.Uint32FieldMaxFloatValue.JsonOutput
|
|
||||||
JsonInput.Uint32FieldMaxFloatValue.ProtobufOutput
|
|
||||||
JsonInput.Uint32MapField.JsonOutput
|
|
||||||
JsonInput.Uint32MapField.ProtobufOutput
|
|
||||||
JsonInput.Uint64FieldBeString.Validator
|
|
||||||
JsonInput.Uint64FieldMaxValue.JsonOutput
|
|
||||||
JsonInput.Uint64FieldMaxValue.ProtobufOutput
|
|
||||||
JsonInput.Uint64MapField.JsonOutput
|
|
||||||
JsonInput.Uint64MapField.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptBool.JsonOutput
|
|
||||||
JsonInput.ValueAcceptBool.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptFloat.JsonOutput
|
|
||||||
JsonInput.ValueAcceptFloat.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptInteger.JsonOutput
|
|
||||||
JsonInput.ValueAcceptInteger.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptList.JsonOutput
|
|
||||||
JsonInput.ValueAcceptList.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptNull.JsonOutput
|
|
||||||
JsonInput.ValueAcceptNull.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptObject.JsonOutput
|
|
||||||
JsonInput.ValueAcceptObject.ProtobufOutput
|
|
||||||
JsonInput.ValueAcceptString.JsonOutput
|
|
||||||
JsonInput.ValueAcceptString.ProtobufOutput
|
|
||||||
ProtobufInput.DoubleFieldNormalizeQuietNan.JsonOutput
|
|
||||||
ProtobufInput.DoubleFieldNormalizeSignalingNan.JsonOutput
|
|
||||||
ProtobufInput.FloatFieldNormalizeQuietNan.JsonOutput
|
|
||||||
ProtobufInput.FloatFieldNormalizeSignalingNan.JsonOutput
|
|
||||||
TimestampProtoInputTooLarge.JsonOutput
|
|
||||||
TimestampProtoInputTooSmall.JsonOutput
|
|
||||||
|
|
58
packager/third_party/protobuf/src/google/protobuf/arena_nc_test.py → packager/third_party/protobuf/conformance/update_failure_list.py
vendored
Normal file → Executable file
58
packager/third_party/protobuf/src/google/protobuf/arena_nc_test.py → packager/third_party/protobuf/conformance/update_failure_list.py
vendored
Normal file → Executable file
|
@ -1,5 +1,4 @@
|
||||||
#! /usr/bin/env python
|
#!/usr/bin/env python
|
||||||
#
|
|
||||||
# Protocol Buffers - Google's data interchange format
|
# Protocol Buffers - Google's data interchange format
|
||||||
# Copyright 2008 Google Inc. All rights reserved.
|
# Copyright 2008 Google Inc. All rights reserved.
|
||||||
# https://developers.google.com/protocol-buffers/
|
# https://developers.google.com/protocol-buffers/
|
||||||
|
@ -30,32 +29,45 @@
|
||||||
# (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.
|
||||||
|
|
||||||
"""Negative compilation unit tests for arena API."""
|
"""Script to update a failure list file to add/remove failures.
|
||||||
|
|
||||||
import unittest
|
This is sort of like comm(1), except it recognizes comments and ignores them.
|
||||||
|
"""
|
||||||
|
|
||||||
from google3.testing.pybase import fake_target_util
|
import argparse
|
||||||
from google3.testing.pybase import unittest
|
import fileinput
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(
|
||||||
|
description='Adds/removes failures from the failure list.')
|
||||||
|
parser.add_argument('filename', type=str, help='failure list file to update')
|
||||||
|
parser.add_argument('--add', dest='add_list', action='append')
|
||||||
|
parser.add_argument('--remove', dest='remove_list', action='append')
|
||||||
|
|
||||||
class ArenaNcTest(unittest.TestCase):
|
args = parser.parse_args()
|
||||||
|
|
||||||
def testCompilerErrors(self):
|
add_set = set()
|
||||||
"""Runs a list of tests to verify compiler error messages."""
|
remove_set = set()
|
||||||
|
|
||||||
# Defines a list of test specs, where each element is a tuple
|
for add_file in (args.add_list or []):
|
||||||
# (test name, list of regexes for matching the compiler errors).
|
with open(add_file) as f:
|
||||||
test_specs = [
|
for line in f:
|
||||||
('ARENA_PRIVATE_CONSTRUCTOR',
|
add_set.add(line)
|
||||||
[r'calling a protected constructor']),
|
|
||||||
('SANITY', None)]
|
|
||||||
|
|
||||||
fake_target_util.AssertCcCompilerErrors(
|
for remove_file in (args.remove_list or []):
|
||||||
self, # The current test case.
|
with open(remove_file) as f:
|
||||||
'google3/google/protobuf/arena_nc', # The fake target file.
|
for line in f:
|
||||||
'arena_nc.o', # The sub-target to build.
|
if line in add_set:
|
||||||
test_specs # List of test specifications.
|
raise Exception("Asked to both add and remove test: " + line)
|
||||||
)
|
remove_set.add(line.strip())
|
||||||
|
|
||||||
if __name__ == '__main__':
|
add_list = sorted(add_set, reverse=True)
|
||||||
unittest.main()
|
|
||||||
|
existing_list = file(args.filename).read()
|
||||||
|
|
||||||
|
with open(args.filename, "w") as f:
|
||||||
|
for line in existing_list.splitlines(True):
|
||||||
|
test = line.split("#")[0].strip()
|
||||||
|
while len(add_list) > 0 and test > add_list[-1]:
|
||||||
|
f.write(add_list.pop())
|
||||||
|
if test not in remove_set:
|
||||||
|
f.write(line)
|
|
@ -1,16 +1,10 @@
|
||||||
#
|
# Output
|
||||||
# Untracked directories
|
bin
|
||||||
#
|
obj
|
||||||
src/AddressBook/bin
|
project.lock.json
|
||||||
src/AddressBook/obj
|
TestResult.xml
|
||||||
src/Google.Protobuf/bin/
|
|
||||||
src/Google.Protobuf/obj/
|
# Possibly legacy now?
|
||||||
src/Google.Protobuf.Conformance/bin/
|
|
||||||
src/Google.Protobuf.Conformance/obj/
|
|
||||||
src/Google.Protobuf.Test/bin/
|
|
||||||
src/Google.Protobuf.Test/obj/
|
|
||||||
src/Google.Protobuf.JsonDump/bin/
|
|
||||||
src/Google.Protobuf.JsonDump/obj/
|
|
||||||
mono/bin
|
mono/bin
|
||||||
mono/tmp
|
mono/tmp
|
||||||
mono/protoc
|
mono/protoc
|
||||||
|
@ -23,6 +17,7 @@ lib/NUnit
|
||||||
#
|
#
|
||||||
# Untracked files
|
# Untracked files
|
||||||
#
|
#
|
||||||
|
.vs
|
||||||
*.user
|
*.user
|
||||||
*.suo
|
*.suo
|
||||||
*.nupkg
|
*.nupkg
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<title>Google Protocol Buffers tools</title>
|
<title>Google Protocol Buffers tools</title>
|
||||||
<summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
|
<summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
|
||||||
<description>See project site for more info.</description>
|
<description>See project site for more info.</description>
|
||||||
<version>3.0.0-beta3</version>
|
<version>3.3.2</version>
|
||||||
<authors>Google Inc.</authors>
|
<authors>Google Inc.</authors>
|
||||||
<owners>protobuf-packages</owners>
|
<owners>protobuf-packages</owners>
|
||||||
<licenseUrl>https://github.com/google/protobuf/blob/master/LICENSE</licenseUrl>
|
<licenseUrl>https://github.com/google/protobuf/blob/master/LICENSE</licenseUrl>
|
||||||
|
|
|
@ -1,16 +1,13 @@
|
||||||
This directory contains the C# Protocol Buffers runtime library.
|
This directory contains the C# Protocol Buffers runtime library.
|
||||||
|
|
||||||
Status: Beta - ready for external testing
|
|
||||||
=========================================
|
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
=====
|
=====
|
||||||
|
|
||||||
The easiest way how to use C# protobufs is via the `Google.Protobuf`
|
The easiest way how to use C# protobufs is via the `Google.Protobuf`
|
||||||
NuGet package. Just add the NuGet package to your VS project.
|
NuGet package. Just add the NuGet package to your VS project.
|
||||||
|
|
||||||
Besides C# runtime library, the NuGet package also contains
|
You will also want to install the `Google.Protobuf.Tools` NuGet package, which
|
||||||
precompiled version of `protoc.exe` and a copy of well known `.proto`
|
contains precompiled version of `protoc.exe` and a copy of well known `.proto`
|
||||||
files under the package's `tools` directory.
|
files under the package's `tools` directory.
|
||||||
|
|
||||||
To generate C# files from your `.proto` files, invoke `protoc` with the
|
To generate C# files from your `.proto` files, invoke `protoc` with the
|
||||||
|
@ -34,16 +31,41 @@ which only uses features from C# 3 and earlier.
|
||||||
Building
|
Building
|
||||||
========
|
========
|
||||||
|
|
||||||
Open the `src/Google.Protobuf.sln` solution in Visual Studio 2015 or
|
Open the `src/Google.Protobuf.sln` solution in Visual Studio 2017 or
|
||||||
later. You should be able to run the NUnit test from Test Explorer
|
later.
|
||||||
(you might need to install NUnit Visual Studio add-in).
|
|
||||||
|
|
||||||
Although *users* of this project are only expected to have Visual
|
Although *users* of this project are only expected to have Visual
|
||||||
Studio 2012 or later, *developers* of the library are required to
|
Studio 2012 or later, *developers* of the library are required to
|
||||||
have Visual Studio 2015 or later, as the library uses C# 6 features
|
have Visual Studio 2017 or later, as the library uses C# 6 features
|
||||||
in its implementation. These features have no impact when using the
|
in its implementation, as well as the new Visual Studio 2017 csproj
|
||||||
compiled code - they're only relevant when building the
|
format. These features have no impact when using the compiled code -
|
||||||
`Google.Protobuf` assembly.
|
they're only relevant when building the `Google.Protobuf` assembly.
|
||||||
|
|
||||||
|
Testing
|
||||||
|
=======
|
||||||
|
|
||||||
|
The unit tests use [NUnit 3](https://github.com/nunit/nunit). NUnit doesn't yet
|
||||||
|
support `dotnet test`, so for now the test project is a console application
|
||||||
|
using NUnitLite. Simply run `Google.Protobuf.Test.exe` to run the unit tests
|
||||||
|
directly, or else use `dotnet run`.
|
||||||
|
|
||||||
|
.NET 3.5
|
||||||
|
========
|
||||||
|
|
||||||
|
We don't officially support .NET 3.5. However, there has been some effort
|
||||||
|
to make enabling .NET 3.5 support relatively painless in case you require it.
|
||||||
|
There's no guarantee that this will continue in the future, so rely on .NET
|
||||||
|
3.5 support at your peril.
|
||||||
|
|
||||||
|
To enable .NET 3.5 support, you must edit the `TargetFrameworks` elements of
|
||||||
|
[src/Google.Protobuf/Google.Protobuf.csproj](src/Google.Protobuf/Google.Protobuf.csproj)
|
||||||
|
(and [src/Google.Protobuf.Test/Google.Protobuf.Test.csproj](src/Google.Protobuf.Test/Google.Protobuf.Test.csproj)
|
||||||
|
if you want to run the unit tests):
|
||||||
|
|
||||||
|
Open the .csproj file in a text editor and simply add `net35` to the list of
|
||||||
|
target frameworks, noting that the `TargetFrameworks` element appears twice in
|
||||||
|
the file (once in the first `PropertyGroup` element, and again in the second
|
||||||
|
`PropertyGroup` element, i.e., the one with the conditional).
|
||||||
|
|
||||||
History of C# protobufs
|
History of C# protobufs
|
||||||
=======================
|
=======================
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
@rem Builds Google.Protobuf NuGet packages
|
@rem Builds Google.Protobuf NuGet packages
|
||||||
|
|
||||||
@rem Adjust the location of nuget.exe
|
dotnet restore src/Google.Protobuf.sln
|
||||||
set NUGET=C:\nuget\nuget.exe
|
dotnet pack -c Release src/Google.Protobuf.sln || goto :error
|
||||||
|
|
||||||
@rem Build src/Google.Protobuf.sln solution in Release configuration first.
|
|
||||||
%NUGET% pack src\Google.Protobuf\Google.Protobuf.nuspec -Symbols || goto :error
|
|
||||||
|
|
||||||
goto :EOF
|
goto :EOF
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,52 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
if [ $# -ne 1 ]; then
|
||||||
|
cat <<EOF
|
||||||
|
Usage: $0 <VERSION_NUMBER>
|
||||||
|
|
||||||
|
Example:
|
||||||
|
$ $0 3.0.0
|
||||||
|
|
||||||
|
This script will download pre-built protoc binaries from maven repository and
|
||||||
|
create the Google.Protobuf.Tools package. Well-known type .proto files will also
|
||||||
|
be included.
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
VERSION_NUMBER=$1
|
||||||
|
# <directory name> <binary file name> pairs.
|
||||||
|
declare -a FILE_NAMES=( \
|
||||||
|
windows_x86 windows-x86_32.exe \
|
||||||
|
windows_x64 windows-x86_64.exe \
|
||||||
|
macosx_x86 osx-x86_32.exe \
|
||||||
|
macosx_x64 osx-x86_64.exe \
|
||||||
|
linux_x86 linux-x86_32.exe \
|
||||||
|
linux_x64 linux-x86_64.exe \
|
||||||
|
)
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
mkdir -p protoc
|
||||||
|
# Create a zip file for each binary.
|
||||||
|
for((i=0;i<${#FILE_NAMES[@]};i+=2));do
|
||||||
|
DIR_NAME=${FILE_NAMES[$i]}
|
||||||
|
mkdir -p protoc/$DIR_NAME
|
||||||
|
|
||||||
|
if [ ${DIR_NAME:0:3} = "win" ]; then
|
||||||
|
TARGET_BINARY="protoc.exe"
|
||||||
|
else
|
||||||
|
TARGET_BINARY="protoc"
|
||||||
|
fi
|
||||||
|
|
||||||
|
BINARY_NAME=${FILE_NAMES[$(($i+1))]}
|
||||||
|
BINARY_URL=http://repo1.maven.org/maven2/com/google/protobuf/protoc/${VERSION_NUMBER}/protoc-${VERSION_NUMBER}-${BINARY_NAME}
|
||||||
|
|
||||||
|
if ! wget ${BINARY_URL} -O protoc/$DIR_NAME/$TARGET_BINARY &> /dev/null; then
|
||||||
|
echo "[ERROR] Failed to download ${BINARY_URL}" >&2
|
||||||
|
echo "[ERROR] Skipped $protoc-${VERSION_NAME}-${DIR_NAME}" >&2
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
nuget pack Google.Protobuf.Tools.nuspec
|
|
@ -1,17 +1,17 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Use mono to build solution and run all tests.
|
|
||||||
|
|
||||||
# Adjust these to reflect the location of nunit-console in your system.
|
|
||||||
NUNIT_CONSOLE=nunit-console
|
|
||||||
|
|
||||||
# The rest you can leave intact
|
|
||||||
CONFIG=Release
|
CONFIG=Release
|
||||||
SRC=$(dirname $0)/src
|
SRC=$(dirname $0)/src
|
||||||
|
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
echo Building the solution.
|
echo Building relevant projects.
|
||||||
xbuild /p:Configuration=$CONFIG $SRC/Google.Protobuf.sln
|
dotnet restore $SRC/Google.Protobuf.sln
|
||||||
|
dotnet build -c $CONFIG $SRC/Google.Protobuf.sln
|
||||||
|
|
||||||
echo Running tests.
|
echo Running tests.
|
||||||
$NUNIT_CONSOLE $SRC/Google.Protobuf.Test/bin/$CONFIG/Google.Protobuf.Test.dll
|
# Only test netcoreapp1.0, which uses the .NET Core runtime.
|
||||||
|
# If we want to test the .NET 4.5 version separately, we could
|
||||||
|
# run Mono explicitly. However, we don't have any differences between
|
||||||
|
# the .NET 4.5 and netstandard1.0 assemblies.
|
||||||
|
dotnet run -c $CONFIG -f netcoreapp1.0 -p $SRC/Google.Protobuf.Test/Google.Protobuf.Test.csproj
|
||||||
|
|
|
@ -0,0 +1,126 @@
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
// These proto descriptors have at one time been reported as an issue or defect.
|
||||||
|
// They are kept here to replicate the issue, and continue to verify the fix.
|
||||||
|
|
||||||
|
// Issue: Non-"Google.Protobuffers" namespace will ensure that protobuffer library types are qualified
|
||||||
|
option csharp_namespace = "UnitTest.Issues.TestProtos";
|
||||||
|
|
||||||
|
package unittest_issues;
|
||||||
|
option optimize_for = SPEED;
|
||||||
|
|
||||||
|
// Issue 307: when generating doubly-nested types, any references
|
||||||
|
// should be of the form A.Types.B.Types.C.
|
||||||
|
message Issue307 {
|
||||||
|
message NestedOnce {
|
||||||
|
message NestedTwice {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Old issue 13: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=13
|
||||||
|
// New issue 309: https://github.com/google/protobuf/issues/309
|
||||||
|
|
||||||
|
// message A {
|
||||||
|
// optional int32 _A = 1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// message B {
|
||||||
|
// optional int32 B_ = 1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
//message AB {
|
||||||
|
// optional int32 a_b = 1;
|
||||||
|
//}
|
||||||
|
|
||||||
|
// Similar issue with numeric names
|
||||||
|
// Java code failed too, so probably best for this to be a restriction.
|
||||||
|
// See https://github.com/google/protobuf/issues/308
|
||||||
|
// message NumberField {
|
||||||
|
// optional int32 _01 = 1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// issue 19 - negative enum values
|
||||||
|
|
||||||
|
enum NegativeEnum {
|
||||||
|
NEGATIVE_ENUM_ZERO = 0;
|
||||||
|
FiveBelow = -5;
|
||||||
|
MinusOne = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message NegativeEnumMessage {
|
||||||
|
NegativeEnum value = 1;
|
||||||
|
repeated NegativeEnum values = 2 [packed = false];
|
||||||
|
repeated NegativeEnum packed_values = 3 [packed=true];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Issue 21: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=21
|
||||||
|
// Decorate fields with [deprecated=true] as [System.Obsolete]
|
||||||
|
|
||||||
|
message DeprecatedChild {
|
||||||
|
}
|
||||||
|
|
||||||
|
enum DeprecatedEnum {
|
||||||
|
DEPRECATED_ZERO = 0;
|
||||||
|
one = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message DeprecatedFieldsMessage {
|
||||||
|
int32 PrimitiveValue = 1 [deprecated = true];
|
||||||
|
repeated int32 PrimitiveArray = 2 [deprecated = true];
|
||||||
|
|
||||||
|
DeprecatedChild MessageValue = 3 [deprecated = true];
|
||||||
|
repeated DeprecatedChild MessageArray = 4 [deprecated = true];
|
||||||
|
|
||||||
|
DeprecatedEnum EnumValue = 5 [deprecated = true];
|
||||||
|
repeated DeprecatedEnum EnumArray = 6 [deprecated = true];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Issue 45: http://code.google.com/p/protobuf-csharp-port/issues/detail?id=45
|
||||||
|
message ItemField {
|
||||||
|
int32 item = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message ReservedNames {
|
||||||
|
// Force a nested type called Types
|
||||||
|
message SomeNestedType {
|
||||||
|
}
|
||||||
|
|
||||||
|
int32 types = 1;
|
||||||
|
int32 descriptor = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TestJsonFieldOrdering {
|
||||||
|
// These fields are deliberately not declared in numeric
|
||||||
|
// order, and the oneof fields aren't contiguous either.
|
||||||
|
// This allows for reasonably robust tests of JSON output
|
||||||
|
// ordering.
|
||||||
|
// TestFieldOrderings in unittest_proto3.proto is similar,
|
||||||
|
// but doesn't include oneofs.
|
||||||
|
// TODO: Consider adding oneofs to TestFieldOrderings, although
|
||||||
|
// that will require fixing other tests in multiple platforms.
|
||||||
|
// Alternatively, consider just adding this to
|
||||||
|
// unittest_proto3.proto if multiple platforms want it.
|
||||||
|
|
||||||
|
int32 plain_int32 = 4;
|
||||||
|
|
||||||
|
oneof o1 {
|
||||||
|
string o1_string = 2;
|
||||||
|
int32 o1_int32 = 5;
|
||||||
|
}
|
||||||
|
|
||||||
|
string plain_string = 1;
|
||||||
|
|
||||||
|
oneof o2 {
|
||||||
|
int32 o2_int32 = 6;
|
||||||
|
string o2_string = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
message TestJsonName {
|
||||||
|
// Message for testing the effects for of the json_name option
|
||||||
|
string name = 1;
|
||||||
|
string description = 2 [json_name = "desc"];
|
||||||
|
string guid = 3 [json_name = "exid"];
|
||||||
|
}
|
|
@ -0,0 +1,120 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
// This file is mostly equivalent to map_unittest.proto, but imports
|
||||||
|
// unittest_proto3.proto instead of unittest.proto, so that it only
|
||||||
|
// uses proto3 messages. This makes it suitable for testing
|
||||||
|
// implementations which only support proto3.
|
||||||
|
// The TestRequiredMessageMap message has been removed as there are no
|
||||||
|
// required fields in proto3.
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
option cc_enable_arenas = true;
|
||||||
|
option csharp_namespace = "Google.Protobuf.TestProtos";
|
||||||
|
|
||||||
|
import "google/protobuf/unittest_proto3.proto";
|
||||||
|
|
||||||
|
// We don't put this in a package within proto2 because we need to make sure
|
||||||
|
// that the generated code doesn't depend on being in the proto2 namespace.
|
||||||
|
// In map_test_util.h we do "using namespace unittest = protobuf_unittest".
|
||||||
|
package protobuf_unittest;
|
||||||
|
|
||||||
|
// Tests maps.
|
||||||
|
message TestMap {
|
||||||
|
map<int32 , int32 > map_int32_int32 = 1;
|
||||||
|
map<int64 , int64 > map_int64_int64 = 2;
|
||||||
|
map<uint32 , uint32 > map_uint32_uint32 = 3;
|
||||||
|
map<uint64 , uint64 > map_uint64_uint64 = 4;
|
||||||
|
map<sint32 , sint32 > map_sint32_sint32 = 5;
|
||||||
|
map<sint64 , sint64 > map_sint64_sint64 = 6;
|
||||||
|
map<fixed32 , fixed32 > map_fixed32_fixed32 = 7;
|
||||||
|
map<fixed64 , fixed64 > map_fixed64_fixed64 = 8;
|
||||||
|
map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
|
||||||
|
map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
|
||||||
|
map<int32 , float > map_int32_float = 11;
|
||||||
|
map<int32 , double > map_int32_double = 12;
|
||||||
|
map<bool , bool > map_bool_bool = 13;
|
||||||
|
map<string , string > map_string_string = 14;
|
||||||
|
map<int32 , bytes > map_int32_bytes = 15;
|
||||||
|
map<int32 , MapEnum > map_int32_enum = 16;
|
||||||
|
map<int32 , ForeignMessage> map_int32_foreign_message = 17;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TestMapSubmessage {
|
||||||
|
TestMap test_map = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TestMessageMap {
|
||||||
|
map<int32, TestAllTypes> map_int32_message = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Two map fields share the same entry default instance.
|
||||||
|
message TestSameTypeMap {
|
||||||
|
map<int32, int32> map1 = 1;
|
||||||
|
map<int32, int32> map2 = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum MapEnum {
|
||||||
|
MAP_ENUM_FOO = 0;
|
||||||
|
MAP_ENUM_BAR = 1;
|
||||||
|
MAP_ENUM_BAZ = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TestArenaMap {
|
||||||
|
map<int32 , int32 > map_int32_int32 = 1;
|
||||||
|
map<int64 , int64 > map_int64_int64 = 2;
|
||||||
|
map<uint32 , uint32 > map_uint32_uint32 = 3;
|
||||||
|
map<uint64 , uint64 > map_uint64_uint64 = 4;
|
||||||
|
map<sint32 , sint32 > map_sint32_sint32 = 5;
|
||||||
|
map<sint64 , sint64 > map_sint64_sint64 = 6;
|
||||||
|
map<fixed32 , fixed32 > map_fixed32_fixed32 = 7;
|
||||||
|
map<fixed64 , fixed64 > map_fixed64_fixed64 = 8;
|
||||||
|
map<sfixed32, sfixed32> map_sfixed32_sfixed32 = 9;
|
||||||
|
map<sfixed64, sfixed64> map_sfixed64_sfixed64 = 10;
|
||||||
|
map<int32 , float > map_int32_float = 11;
|
||||||
|
map<int32 , double > map_int32_double = 12;
|
||||||
|
map<bool , bool > map_bool_bool = 13;
|
||||||
|
map<int32 , MapEnum > map_int32_enum = 14;
|
||||||
|
map<int32 , ForeignMessage> map_int32_foreign_message = 15;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Previously, message containing enum called Type cannot be used as value of
|
||||||
|
// map field.
|
||||||
|
message MessageContainingEnumCalledType {
|
||||||
|
enum Type {
|
||||||
|
TYPE_FOO = 0;
|
||||||
|
}
|
||||||
|
map<int32, MessageContainingEnumCalledType> type = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Previously, message cannot contain map field called "entry".
|
||||||
|
message MessageContainingMapCalledEntry {
|
||||||
|
map<int32, int32> entry = 1;
|
||||||
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
// Protocol Buffers - Google's data interchange format
|
// Protocol Buffers - Google's data interchange format
|
||||||
// Copyright 2008 Google Inc. All rights reserved.
|
// Copyright 2008 Google Inc. All rights reserved.
|
||||||
// http://code.google.com/p/protobuf/
|
// https://developers.google.com/protocol-buffers/
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
|
@ -28,37 +28,41 @@
|
||||||
// (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.
|
||||||
|
|
||||||
package com.google.protobuf;
|
// Author: kenton@google.com (Kenton Varda)
|
||||||
|
// Based on original Protocol Buffers design by
|
||||||
|
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||||
|
//
|
||||||
|
// A proto file which is imported by unittest_proto3.proto to test importing.
|
||||||
|
|
||||||
/**
|
syntax = "proto3";
|
||||||
* Blocking equivalent to {@link Service}.
|
|
||||||
*
|
|
||||||
* @author kenton@google.com Kenton Varda
|
|
||||||
* @author cpovirk@google.com Chris Povirk
|
|
||||||
*/
|
|
||||||
public interface BlockingService {
|
|
||||||
/**
|
|
||||||
* Equivalent to {@link Service#getDescriptorForType}.
|
|
||||||
*/
|
|
||||||
Descriptors.ServiceDescriptor getDescriptorForType();
|
|
||||||
|
|
||||||
/**
|
// We don't put this in a package within proto2 because we need to make sure
|
||||||
* Equivalent to {@link Service#callMethod}, except that
|
// that the generated code doesn't depend on being in the proto2 namespace.
|
||||||
* {@code callBlockingMethod()} returns the result of the RPC or throws a
|
// In test_util.h we do
|
||||||
* {@link ServiceException} if there is a failure, rather than passing the
|
// "using namespace unittest_import = protobuf_unittest_import".
|
||||||
* information to a callback.
|
package protobuf_unittest_import;
|
||||||
*/
|
|
||||||
Message callBlockingMethod(Descriptors.MethodDescriptor method,
|
|
||||||
RpcController controller,
|
|
||||||
Message request) throws ServiceException;
|
|
||||||
|
|
||||||
/**
|
option optimize_for = SPEED;
|
||||||
* Equivalent to {@link Service#getRequestPrototype}.
|
option cc_enable_arenas = true;
|
||||||
*/
|
|
||||||
Message getRequestPrototype(Descriptors.MethodDescriptor method);
|
|
||||||
|
|
||||||
/**
|
// Exercise the java_package option.
|
||||||
* Equivalent to {@link Service#getResponsePrototype}.
|
option java_package = "com.google.protobuf.test";
|
||||||
*/
|
option csharp_namespace = "Google.Protobuf.TestProtos";
|
||||||
Message getResponsePrototype(Descriptors.MethodDescriptor method);
|
|
||||||
|
// Do not set a java_outer_classname here to verify that Proto2 works without
|
||||||
|
// one.
|
||||||
|
|
||||||
|
// Test public import
|
||||||
|
import public "google/protobuf/unittest_import_public_proto3.proto";
|
||||||
|
|
||||||
|
message ImportMessage {
|
||||||
|
int32 d = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ImportEnum {
|
||||||
|
IMPORT_ENUM_UNSPECIFIED = 0;
|
||||||
|
IMPORT_FOO = 7;
|
||||||
|
IMPORT_BAR = 8;
|
||||||
|
IMPORT_BAZ = 9;
|
||||||
|
}
|
||||||
|
|
|
@ -28,18 +28,15 @@
|
||||||
// (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.
|
||||||
|
|
||||||
// Negative compilation test for arena usage.
|
// Author: liujisi@google.com (Pherl Liu)
|
||||||
|
|
||||||
#include <google/protobuf/arena.h>
|
syntax = "proto3";
|
||||||
#include <google/protobuf/unittest.pb.h>
|
|
||||||
|
|
||||||
#ifdef TEST_ARENA_PRIVATE_CONSTRUCTOR
|
package protobuf_unittest_import;
|
||||||
|
|
||||||
namespace google {
|
option java_package = "com.google.protobuf.test";
|
||||||
void ArenaPrivateConstructor() {
|
option csharp_namespace = "Google.Protobuf.TestProtos";
|
||||||
google::protobuf::Arena arena;
|
|
||||||
protobuf_unittest::TestAllTypes message(&arena);
|
message PublicImportMessage {
|
||||||
|
int32 e = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
} // namespace google
|
|
|
@ -0,0 +1,388 @@
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
// Author: kenton@google.com (Kenton Varda)
|
||||||
|
// Based on original Protocol Buffers design by
|
||||||
|
// Sanjay Ghemawat, Jeff Dean, and others.
|
||||||
|
//
|
||||||
|
// A proto file we will use for unit testing.
|
||||||
|
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
// Some generic_services option(s) added automatically.
|
||||||
|
// See: http://go/proto2-generic-services-default
|
||||||
|
option cc_generic_services = true; // auto-added
|
||||||
|
option java_generic_services = true; // auto-added
|
||||||
|
option py_generic_services = true; // auto-added
|
||||||
|
option cc_enable_arenas = true;
|
||||||
|
option csharp_namespace = "Google.Protobuf.TestProtos";
|
||||||
|
|
||||||
|
import "google/protobuf/unittest_import_proto3.proto";
|
||||||
|
|
||||||
|
// We don't put this in a package within proto2 because we need to make sure
|
||||||
|
// that the generated code doesn't depend on being in the proto2 namespace.
|
||||||
|
// In test_util.h we do "using namespace unittest = protobuf_unittest".
|
||||||
|
package protobuf_unittest;
|
||||||
|
|
||||||
|
// Protos optimized for SPEED use a strict superset of the generated code
|
||||||
|
// of equivalent ones optimized for CODE_SIZE, so we should optimize all our
|
||||||
|
// tests for speed unless explicitly testing code size optimization.
|
||||||
|
option optimize_for = SPEED;
|
||||||
|
|
||||||
|
option java_outer_classname = "UnittestProto";
|
||||||
|
|
||||||
|
// This proto includes every type of field in both singular and repeated
|
||||||
|
// forms.
|
||||||
|
message TestAllTypes {
|
||||||
|
message NestedMessage {
|
||||||
|
// The field name "b" fails to compile in proto1 because it conflicts with
|
||||||
|
// a local variable named "b" in one of the generated methods. Doh.
|
||||||
|
// This file needs to compile in proto1 to test backwards-compatibility.
|
||||||
|
int32 bb = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum NestedEnum {
|
||||||
|
NESTED_ENUM_UNSPECIFIED = 0;
|
||||||
|
FOO = 1;
|
||||||
|
BAR = 2;
|
||||||
|
BAZ = 3;
|
||||||
|
NEG = -1; // Intentionally negative.
|
||||||
|
}
|
||||||
|
|
||||||
|
// Singular
|
||||||
|
int32 single_int32 = 1;
|
||||||
|
int64 single_int64 = 2;
|
||||||
|
uint32 single_uint32 = 3;
|
||||||
|
uint64 single_uint64 = 4;
|
||||||
|
sint32 single_sint32 = 5;
|
||||||
|
sint64 single_sint64 = 6;
|
||||||
|
fixed32 single_fixed32 = 7;
|
||||||
|
fixed64 single_fixed64 = 8;
|
||||||
|
sfixed32 single_sfixed32 = 9;
|
||||||
|
sfixed64 single_sfixed64 = 10;
|
||||||
|
float single_float = 11;
|
||||||
|
double single_double = 12;
|
||||||
|
bool single_bool = 13;
|
||||||
|
string single_string = 14;
|
||||||
|
bytes single_bytes = 15;
|
||||||
|
|
||||||
|
NestedMessage single_nested_message = 18;
|
||||||
|
ForeignMessage single_foreign_message = 19;
|
||||||
|
protobuf_unittest_import.ImportMessage single_import_message = 20;
|
||||||
|
|
||||||
|
NestedEnum single_nested_enum = 21;
|
||||||
|
ForeignEnum single_foreign_enum = 22;
|
||||||
|
protobuf_unittest_import.ImportEnum single_import_enum = 23;
|
||||||
|
|
||||||
|
// Defined in unittest_import_public.proto
|
||||||
|
protobuf_unittest_import.PublicImportMessage
|
||||||
|
single_public_import_message = 26;
|
||||||
|
|
||||||
|
// 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 protobuf_unittest_import.ImportMessage repeated_import_message = 50;
|
||||||
|
|
||||||
|
repeated NestedEnum repeated_nested_enum = 51;
|
||||||
|
repeated ForeignEnum repeated_foreign_enum = 52;
|
||||||
|
repeated protobuf_unittest_import.ImportEnum repeated_import_enum = 53;
|
||||||
|
// Defined in unittest_import_public.proto
|
||||||
|
repeated protobuf_unittest_import.PublicImportMessage
|
||||||
|
repeated_public_import_message = 54;
|
||||||
|
|
||||||
|
// For oneof test
|
||||||
|
oneof oneof_field {
|
||||||
|
uint32 oneof_uint32 = 111;
|
||||||
|
NestedMessage oneof_nested_message = 112;
|
||||||
|
string oneof_string = 113;
|
||||||
|
bytes oneof_bytes = 114;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This proto includes a recusively nested message.
|
||||||
|
message NestedTestAllTypes {
|
||||||
|
NestedTestAllTypes child = 1;
|
||||||
|
TestAllTypes payload = 2;
|
||||||
|
repeated NestedTestAllTypes repeated_child = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TestDeprecatedFields {
|
||||||
|
int32 deprecated_int32 = 1 [deprecated=true];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Define these after TestAllTypes to make sure the compiler can handle
|
||||||
|
// that.
|
||||||
|
message ForeignMessage {
|
||||||
|
int32 c = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
enum ForeignEnum {
|
||||||
|
FOREIGN_UNSPECIFIED = 0;
|
||||||
|
FOREIGN_FOO = 4;
|
||||||
|
FOREIGN_BAR = 5;
|
||||||
|
FOREIGN_BAZ = 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TestReservedFields {
|
||||||
|
reserved 2, 15, 9 to 11;
|
||||||
|
reserved "bar", "baz";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Test that we can use NestedMessage from outside TestAllTypes.
|
||||||
|
message TestForeignNested {
|
||||||
|
TestAllTypes.NestedMessage foreign_nested = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that really large tag numbers don't break anything.
|
||||||
|
message TestReallyLargeTagNumber {
|
||||||
|
// The largest possible tag number is 2^28 - 1, since the wire format uses
|
||||||
|
// three bits to communicate wire type.
|
||||||
|
int32 a = 1;
|
||||||
|
int32 bb = 268435455;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TestRecursiveMessage {
|
||||||
|
TestRecursiveMessage a = 1;
|
||||||
|
int32 i = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test that mutual recursion works.
|
||||||
|
message TestMutualRecursionA {
|
||||||
|
TestMutualRecursionB bb = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TestMutualRecursionB {
|
||||||
|
TestMutualRecursionA a = 1;
|
||||||
|
int32 optional_int32 = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Test an enum that has multiple values with the same number.
|
||||||
|
enum TestEnumWithDupValue {
|
||||||
|
TEST_ENUM_WITH_DUP_VALUE_UNSPECIFIED = 0;
|
||||||
|
option allow_alias = true;
|
||||||
|
|
||||||
|
FOO1 = 1;
|
||||||
|
BAR1 = 2;
|
||||||
|
BAZ = 3;
|
||||||
|
FOO2 = 1;
|
||||||
|
BAR2 = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test an enum with large, unordered values.
|
||||||
|
enum TestSparseEnum {
|
||||||
|
TEST_SPARSE_ENUM_UNSPECIFIED = 0;
|
||||||
|
SPARSE_A = 123;
|
||||||
|
SPARSE_B = 62374;
|
||||||
|
SPARSE_C = 12589234;
|
||||||
|
SPARSE_D = -15;
|
||||||
|
SPARSE_E = -53452;
|
||||||
|
// In proto3, value 0 must be the first one specified
|
||||||
|
// SPARSE_F = 0;
|
||||||
|
SPARSE_G = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test message with CamelCase field names. This violates Protocol Buffer
|
||||||
|
// standard style.
|
||||||
|
message TestCamelCaseFieldNames {
|
||||||
|
int32 PrimitiveField = 1;
|
||||||
|
string StringField = 2;
|
||||||
|
ForeignEnum EnumField = 3;
|
||||||
|
ForeignMessage MessageField = 4;
|
||||||
|
|
||||||
|
repeated int32 RepeatedPrimitiveField = 7;
|
||||||
|
repeated string RepeatedStringField = 8;
|
||||||
|
repeated ForeignEnum RepeatedEnumField = 9;
|
||||||
|
repeated ForeignMessage RepeatedMessageField = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// We list fields out of order, to ensure that we're using field number and not
|
||||||
|
// field index to determine serialization order.
|
||||||
|
message TestFieldOrderings {
|
||||||
|
string my_string = 11;
|
||||||
|
int64 my_int = 1;
|
||||||
|
float my_float = 101;
|
||||||
|
message NestedMessage {
|
||||||
|
int64 oo = 2;
|
||||||
|
// The field name "b" fails to compile in proto1 because it conflicts with
|
||||||
|
// a local variable named "b" in one of the generated methods. Doh.
|
||||||
|
// This file needs to compile in proto1 to test backwards-compatibility.
|
||||||
|
int32 bb = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
NestedMessage single_nested_message = 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
message SparseEnumMessage {
|
||||||
|
TestSparseEnum sparse_enum = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test String and Bytes: string is for valid UTF-8 strings
|
||||||
|
message OneString {
|
||||||
|
string data = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MoreString {
|
||||||
|
repeated string data = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message OneBytes {
|
||||||
|
bytes data = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message MoreBytes {
|
||||||
|
bytes data = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test int32, uint32, int64, uint64, and bool are all compatible
|
||||||
|
message Int32Message {
|
||||||
|
int32 data = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Uint32Message {
|
||||||
|
uint32 data = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Int64Message {
|
||||||
|
int64 data = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message Uint64Message {
|
||||||
|
uint64 data = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
message BoolMessage {
|
||||||
|
bool data = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test oneofs.
|
||||||
|
message TestOneof {
|
||||||
|
oneof foo {
|
||||||
|
int32 foo_int = 1;
|
||||||
|
string foo_string = 2;
|
||||||
|
TestAllTypes foo_message = 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test messages for packed fields
|
||||||
|
|
||||||
|
message TestPackedTypes {
|
||||||
|
repeated int32 packed_int32 = 90 [packed = true];
|
||||||
|
repeated int64 packed_int64 = 91 [packed = true];
|
||||||
|
repeated uint32 packed_uint32 = 92 [packed = true];
|
||||||
|
repeated uint64 packed_uint64 = 93 [packed = true];
|
||||||
|
repeated sint32 packed_sint32 = 94 [packed = true];
|
||||||
|
repeated sint64 packed_sint64 = 95 [packed = true];
|
||||||
|
repeated fixed32 packed_fixed32 = 96 [packed = true];
|
||||||
|
repeated fixed64 packed_fixed64 = 97 [packed = true];
|
||||||
|
repeated sfixed32 packed_sfixed32 = 98 [packed = true];
|
||||||
|
repeated sfixed64 packed_sfixed64 = 99 [packed = true];
|
||||||
|
repeated float packed_float = 100 [packed = true];
|
||||||
|
repeated double packed_double = 101 [packed = true];
|
||||||
|
repeated bool packed_bool = 102 [packed = true];
|
||||||
|
repeated ForeignEnum packed_enum = 103 [packed = true];
|
||||||
|
}
|
||||||
|
|
||||||
|
// A message with the same fields as TestPackedTypes, but without packing. Used
|
||||||
|
// to test packed <-> unpacked wire compatibility.
|
||||||
|
message TestUnpackedTypes {
|
||||||
|
repeated int32 unpacked_int32 = 90 [packed = false];
|
||||||
|
repeated int64 unpacked_int64 = 91 [packed = false];
|
||||||
|
repeated uint32 unpacked_uint32 = 92 [packed = false];
|
||||||
|
repeated uint64 unpacked_uint64 = 93 [packed = false];
|
||||||
|
repeated sint32 unpacked_sint32 = 94 [packed = false];
|
||||||
|
repeated sint64 unpacked_sint64 = 95 [packed = false];
|
||||||
|
repeated fixed32 unpacked_fixed32 = 96 [packed = false];
|
||||||
|
repeated fixed64 unpacked_fixed64 = 97 [packed = false];
|
||||||
|
repeated sfixed32 unpacked_sfixed32 = 98 [packed = false];
|
||||||
|
repeated sfixed64 unpacked_sfixed64 = 99 [packed = false];
|
||||||
|
repeated float unpacked_float = 100 [packed = false];
|
||||||
|
repeated double unpacked_double = 101 [packed = false];
|
||||||
|
repeated bool unpacked_bool = 102 [packed = false];
|
||||||
|
repeated ForeignEnum unpacked_enum = 103 [packed = false];
|
||||||
|
}
|
||||||
|
|
||||||
|
message TestRepeatedScalarDifferentTagSizes {
|
||||||
|
// Parsing repeated fixed size values used to fail. This message needs to be
|
||||||
|
// used in order to get a tag of the right size; all of the repeated fields
|
||||||
|
// in TestAllTypes didn't trigger the check.
|
||||||
|
repeated fixed32 repeated_fixed32 = 12;
|
||||||
|
// Check for a varint type, just for good measure.
|
||||||
|
repeated int32 repeated_int32 = 13;
|
||||||
|
|
||||||
|
// These have two-byte tags.
|
||||||
|
repeated fixed64 repeated_fixed64 = 2046;
|
||||||
|
repeated int64 repeated_int64 = 2047;
|
||||||
|
|
||||||
|
// Three byte tags.
|
||||||
|
repeated float repeated_float = 262142;
|
||||||
|
repeated uint64 repeated_uint64 = 262143;
|
||||||
|
}
|
||||||
|
|
||||||
|
message TestCommentInjectionMessage {
|
||||||
|
// */ <- This should not close the generated doc comment
|
||||||
|
string a = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Test that RPC services work.
|
||||||
|
message FooRequest {}
|
||||||
|
message FooResponse {}
|
||||||
|
|
||||||
|
message FooClientMessage {}
|
||||||
|
message FooServerMessage{}
|
||||||
|
|
||||||
|
service TestService {
|
||||||
|
rpc Foo(FooRequest) returns (FooResponse);
|
||||||
|
rpc Bar(BarRequest) returns (BarResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
message BarRequest {}
|
||||||
|
message BarResponse {}
|
||||||
|
|
|
@ -0,0 +1,114 @@
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package protobuf_unittest;
|
||||||
|
|
||||||
|
option csharp_namespace = "Google.Protobuf.TestProtos";
|
||||||
|
option java_multiple_files = true;
|
||||||
|
option java_package = "com.google.protobuf.test";
|
||||||
|
|
||||||
|
import "google/protobuf/any.proto";
|
||||||
|
import "google/protobuf/api.proto";
|
||||||
|
import "google/protobuf/duration.proto";
|
||||||
|
import "google/protobuf/empty.proto";
|
||||||
|
import "google/protobuf/field_mask.proto";
|
||||||
|
import "google/protobuf/source_context.proto";
|
||||||
|
import "google/protobuf/struct.proto";
|
||||||
|
import "google/protobuf/timestamp.proto";
|
||||||
|
import "google/protobuf/type.proto";
|
||||||
|
import "google/protobuf/wrappers.proto";
|
||||||
|
|
||||||
|
// Test that we can include all well-known types.
|
||||||
|
// Each wrapper type is included separately, as languages
|
||||||
|
// map handle different wrappers in different ways.
|
||||||
|
message TestWellKnownTypes {
|
||||||
|
google.protobuf.Any any_field = 1;
|
||||||
|
google.protobuf.Api api_field = 2;
|
||||||
|
google.protobuf.Duration duration_field = 3;
|
||||||
|
google.protobuf.Empty empty_field = 4;
|
||||||
|
google.protobuf.FieldMask field_mask_field = 5;
|
||||||
|
google.protobuf.SourceContext source_context_field = 6;
|
||||||
|
google.protobuf.Struct struct_field = 7;
|
||||||
|
google.protobuf.Timestamp timestamp_field = 8;
|
||||||
|
google.protobuf.Type type_field = 9;
|
||||||
|
google.protobuf.DoubleValue double_field = 10;
|
||||||
|
google.protobuf.FloatValue float_field = 11;
|
||||||
|
google.protobuf.Int64Value int64_field = 12;
|
||||||
|
google.protobuf.UInt64Value uint64_field = 13;
|
||||||
|
google.protobuf.Int32Value int32_field = 14;
|
||||||
|
google.protobuf.UInt32Value uint32_field = 15;
|
||||||
|
google.protobuf.BoolValue bool_field = 16;
|
||||||
|
google.protobuf.StringValue string_field = 17;
|
||||||
|
google.protobuf.BytesValue bytes_field = 18;
|
||||||
|
// Part of struct, but useful to be able to test separately
|
||||||
|
google.protobuf.Value value_field = 19;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A repeated field for each well-known type.
|
||||||
|
message RepeatedWellKnownTypes {
|
||||||
|
repeated google.protobuf.Any any_field = 1;
|
||||||
|
repeated google.protobuf.Api api_field = 2;
|
||||||
|
repeated google.protobuf.Duration duration_field = 3;
|
||||||
|
repeated google.protobuf.Empty empty_field = 4;
|
||||||
|
repeated google.protobuf.FieldMask field_mask_field = 5;
|
||||||
|
repeated google.protobuf.SourceContext source_context_field = 6;
|
||||||
|
repeated google.protobuf.Struct struct_field = 7;
|
||||||
|
repeated google.protobuf.Timestamp timestamp_field = 8;
|
||||||
|
repeated google.protobuf.Type type_field = 9;
|
||||||
|
// These don't actually make a lot of sense, but they're not prohibited...
|
||||||
|
repeated google.protobuf.DoubleValue double_field = 10;
|
||||||
|
repeated google.protobuf.FloatValue float_field = 11;
|
||||||
|
repeated google.protobuf.Int64Value int64_field = 12;
|
||||||
|
repeated google.protobuf.UInt64Value uint64_field = 13;
|
||||||
|
repeated google.protobuf.Int32Value int32_field = 14;
|
||||||
|
repeated google.protobuf.UInt32Value uint32_field = 15;
|
||||||
|
repeated google.protobuf.BoolValue bool_field = 16;
|
||||||
|
repeated google.protobuf.StringValue string_field = 17;
|
||||||
|
repeated google.protobuf.BytesValue bytes_field = 18;
|
||||||
|
}
|
||||||
|
|
||||||
|
message OneofWellKnownTypes {
|
||||||
|
oneof oneof_field {
|
||||||
|
google.protobuf.Any any_field = 1;
|
||||||
|
google.protobuf.Api api_field = 2;
|
||||||
|
google.protobuf.Duration duration_field = 3;
|
||||||
|
google.protobuf.Empty empty_field = 4;
|
||||||
|
google.protobuf.FieldMask field_mask_field = 5;
|
||||||
|
google.protobuf.SourceContext source_context_field = 6;
|
||||||
|
google.protobuf.Struct struct_field = 7;
|
||||||
|
google.protobuf.Timestamp timestamp_field = 8;
|
||||||
|
google.protobuf.Type type_field = 9;
|
||||||
|
google.protobuf.DoubleValue double_field = 10;
|
||||||
|
google.protobuf.FloatValue float_field = 11;
|
||||||
|
google.protobuf.Int64Value int64_field = 12;
|
||||||
|
google.protobuf.UInt64Value uint64_field = 13;
|
||||||
|
google.protobuf.Int32Value int32_field = 14;
|
||||||
|
google.protobuf.UInt32Value uint32_field = 15;
|
||||||
|
google.protobuf.BoolValue bool_field = 16;
|
||||||
|
google.protobuf.StringValue string_field = 17;
|
||||||
|
google.protobuf.BytesValue bytes_field = 18;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// A map field for each well-known type. We only
|
||||||
|
// need to worry about the value part of the map being the
|
||||||
|
// well-known types, as messages can't be map keys.
|
||||||
|
message MapWellKnownTypes {
|
||||||
|
map<int32,google.protobuf.Any> any_field = 1;
|
||||||
|
map<int32,google.protobuf.Api> api_field = 2;
|
||||||
|
map<int32,google.protobuf.Duration> duration_field = 3;
|
||||||
|
map<int32,google.protobuf.Empty> empty_field = 4;
|
||||||
|
map<int32,google.protobuf.FieldMask> field_mask_field = 5;
|
||||||
|
map<int32,google.protobuf.SourceContext> source_context_field = 6;
|
||||||
|
map<int32,google.protobuf.Struct> struct_field = 7;
|
||||||
|
map<int32,google.protobuf.Timestamp> timestamp_field = 8;
|
||||||
|
map<int32,google.protobuf.Type> type_field = 9;
|
||||||
|
map<int32,google.protobuf.DoubleValue> double_field = 10;
|
||||||
|
map<int32,google.protobuf.FloatValue> float_field = 11;
|
||||||
|
map<int32,google.protobuf.Int64Value> int64_field = 12;
|
||||||
|
map<int32,google.protobuf.UInt64Value> uint64_field = 13;
|
||||||
|
map<int32,google.protobuf.Int32Value> int32_field = 14;
|
||||||
|
map<int32,google.protobuf.UInt32Value> uint32_field = 15;
|
||||||
|
map<int32,google.protobuf.BoolValue> bool_field = 16;
|
||||||
|
map<int32,google.protobuf.StringValue> string_field = 17;
|
||||||
|
map<int32,google.protobuf.BytesValue> bytes_field = 18;
|
||||||
|
}
|
|
@ -0,0 +1,171 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// 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.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Text;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Google.Protobuf
|
||||||
|
{
|
||||||
|
public class ByteStringTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void Equality()
|
||||||
|
{
|
||||||
|
ByteString b1 = ByteString.CopyFrom(1, 2, 3);
|
||||||
|
ByteString b2 = ByteString.CopyFrom(1, 2, 3);
|
||||||
|
ByteString b3 = ByteString.CopyFrom(1, 2, 4);
|
||||||
|
ByteString b4 = ByteString.CopyFrom(1, 2, 3, 4);
|
||||||
|
EqualityTester.AssertEquality(b1, b1);
|
||||||
|
EqualityTester.AssertEquality(b1, b2);
|
||||||
|
EqualityTester.AssertInequality(b1, b3);
|
||||||
|
EqualityTester.AssertInequality(b1, b4);
|
||||||
|
EqualityTester.AssertInequality(b1, null);
|
||||||
|
#pragma warning disable 1718 // Deliberately calling ==(b1, b1) and !=(b1, b1)
|
||||||
|
Assert.IsTrue(b1 == b1);
|
||||||
|
Assert.IsTrue(b1 == b2);
|
||||||
|
Assert.IsFalse(b1 == b3);
|
||||||
|
Assert.IsFalse(b1 == b4);
|
||||||
|
Assert.IsFalse(b1 == null);
|
||||||
|
Assert.IsTrue((ByteString) null == null);
|
||||||
|
Assert.IsFalse(b1 != b1);
|
||||||
|
Assert.IsFalse(b1 != b2);
|
||||||
|
#pragma warning disable 1718
|
||||||
|
Assert.IsTrue(b1 != b3);
|
||||||
|
Assert.IsTrue(b1 != b4);
|
||||||
|
Assert.IsTrue(b1 != null);
|
||||||
|
Assert.IsFalse((ByteString) null != null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EmptyByteStringHasZeroSize()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(0, ByteString.Empty.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CopyFromStringWithExplicitEncoding()
|
||||||
|
{
|
||||||
|
ByteString bs = ByteString.CopyFrom("AB", Encoding.Unicode);
|
||||||
|
Assert.AreEqual(4, bs.Length);
|
||||||
|
Assert.AreEqual(65, bs[0]);
|
||||||
|
Assert.AreEqual(0, bs[1]);
|
||||||
|
Assert.AreEqual(66, bs[2]);
|
||||||
|
Assert.AreEqual(0, bs[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IsEmptyWhenEmpty()
|
||||||
|
{
|
||||||
|
Assert.IsTrue(ByteString.CopyFromUtf8("").IsEmpty);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IsEmptyWhenNotEmpty()
|
||||||
|
{
|
||||||
|
Assert.IsFalse(ByteString.CopyFromUtf8("X").IsEmpty);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CopyFromByteArrayCopiesContents()
|
||||||
|
{
|
||||||
|
byte[] data = new byte[1];
|
||||||
|
data[0] = 10;
|
||||||
|
ByteString bs = ByteString.CopyFrom(data);
|
||||||
|
Assert.AreEqual(10, bs[0]);
|
||||||
|
data[0] = 5;
|
||||||
|
Assert.AreEqual(10, bs[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ToByteArrayCopiesContents()
|
||||||
|
{
|
||||||
|
ByteString bs = ByteString.CopyFromUtf8("Hello");
|
||||||
|
byte[] data = bs.ToByteArray();
|
||||||
|
Assert.AreEqual((byte)'H', data[0]);
|
||||||
|
Assert.AreEqual((byte)'H', bs[0]);
|
||||||
|
data[0] = 0;
|
||||||
|
Assert.AreEqual(0, data[0]);
|
||||||
|
Assert.AreEqual((byte)'H', bs[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CopyFromUtf8UsesUtf8()
|
||||||
|
{
|
||||||
|
ByteString bs = ByteString.CopyFromUtf8("\u20ac");
|
||||||
|
Assert.AreEqual(3, bs.Length);
|
||||||
|
Assert.AreEqual(0xe2, bs[0]);
|
||||||
|
Assert.AreEqual(0x82, bs[1]);
|
||||||
|
Assert.AreEqual(0xac, bs[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CopyFromPortion()
|
||||||
|
{
|
||||||
|
byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6};
|
||||||
|
ByteString bs = ByteString.CopyFrom(data, 2, 3);
|
||||||
|
Assert.AreEqual(3, bs.Length);
|
||||||
|
Assert.AreEqual(2, bs[0]);
|
||||||
|
Assert.AreEqual(3, bs[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ToStringUtf8()
|
||||||
|
{
|
||||||
|
ByteString bs = ByteString.CopyFromUtf8("\u20ac");
|
||||||
|
Assert.AreEqual("\u20ac", bs.ToStringUtf8());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ToStringWithExplicitEncoding()
|
||||||
|
{
|
||||||
|
ByteString bs = ByteString.CopyFrom("\u20ac", Encoding.Unicode);
|
||||||
|
Assert.AreEqual("\u20ac", bs.ToString(Encoding.Unicode));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void FromBase64_WithText()
|
||||||
|
{
|
||||||
|
byte[] data = new byte[] {0, 1, 2, 3, 4, 5, 6};
|
||||||
|
string base64 = Convert.ToBase64String(data);
|
||||||
|
ByteString bs = ByteString.FromBase64(base64);
|
||||||
|
Assert.AreEqual(data, bs.ToByteArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void FromBase64_Empty()
|
||||||
|
{
|
||||||
|
// Optimization which also fixes issue 61.
|
||||||
|
Assert.AreSame(ByteString.Empty, ByteString.FromBase64(""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,53 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2015 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.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Google.Protobuf
|
||||||
|
{
|
||||||
|
internal static class CodedInputStreamExtensions
|
||||||
|
{
|
||||||
|
public static void AssertNextTag(this CodedInputStream input, uint expectedTag)
|
||||||
|
{
|
||||||
|
uint tag = input.ReadTag();
|
||||||
|
Assert.AreEqual(expectedTag, tag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T ReadMessage<T>(this CodedInputStream stream, MessageParser<T> parser)
|
||||||
|
where T : IMessage<T>
|
||||||
|
{
|
||||||
|
var message = parser.CreateTemplate();
|
||||||
|
stream.ReadMessage(message);
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,598 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// 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.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using Google.Protobuf.TestProtos;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Google.Protobuf
|
||||||
|
{
|
||||||
|
public class CodedInputStreamTest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Helper to construct a byte array from a bunch of bytes. The inputs are
|
||||||
|
/// actually ints so that I can use hex notation and not get stupid errors
|
||||||
|
/// about precision.
|
||||||
|
/// </summary>
|
||||||
|
private static byte[] Bytes(params int[] bytesAsInts)
|
||||||
|
{
|
||||||
|
byte[] bytes = new byte[bytesAsInts.Length];
|
||||||
|
for (int i = 0; i < bytesAsInts.Length; i++)
|
||||||
|
{
|
||||||
|
bytes[i] = (byte) bytesAsInts[i];
|
||||||
|
}
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64()
|
||||||
|
/// </summary>
|
||||||
|
private static void AssertReadVarint(byte[] data, ulong value)
|
||||||
|
{
|
||||||
|
CodedInputStream input = new CodedInputStream(data);
|
||||||
|
Assert.AreEqual((uint) value, input.ReadRawVarint32());
|
||||||
|
|
||||||
|
input = new CodedInputStream(data);
|
||||||
|
Assert.AreEqual(value, input.ReadRawVarint64());
|
||||||
|
Assert.IsTrue(input.IsAtEnd);
|
||||||
|
|
||||||
|
// Try different block sizes.
|
||||||
|
for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2)
|
||||||
|
{
|
||||||
|
input = new CodedInputStream(new SmallBlockInputStream(data, bufferSize));
|
||||||
|
Assert.AreEqual((uint) value, input.ReadRawVarint32());
|
||||||
|
|
||||||
|
input = new CodedInputStream(new SmallBlockInputStream(data, bufferSize));
|
||||||
|
Assert.AreEqual(value, input.ReadRawVarint64());
|
||||||
|
Assert.IsTrue(input.IsAtEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try reading directly from a MemoryStream. We want to verify that it
|
||||||
|
// doesn't read past the end of the input, so write an extra byte - this
|
||||||
|
// lets us test the position at the end.
|
||||||
|
MemoryStream memoryStream = new MemoryStream();
|
||||||
|
memoryStream.Write(data, 0, data.Length);
|
||||||
|
memoryStream.WriteByte(0);
|
||||||
|
memoryStream.Position = 0;
|
||||||
|
Assert.AreEqual((uint) value, CodedInputStream.ReadRawVarint32(memoryStream));
|
||||||
|
Assert.AreEqual(data.Length, memoryStream.Position);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses the given bytes using ReadRawVarint32() and ReadRawVarint64() and
|
||||||
|
/// expects them to fail with an InvalidProtocolBufferException whose
|
||||||
|
/// description matches the given one.
|
||||||
|
/// </summary>
|
||||||
|
private static void AssertReadVarintFailure(InvalidProtocolBufferException expected, byte[] data)
|
||||||
|
{
|
||||||
|
CodedInputStream input = new CodedInputStream(data);
|
||||||
|
var exception = Assert.Throws<InvalidProtocolBufferException>(() => input.ReadRawVarint32());
|
||||||
|
Assert.AreEqual(expected.Message, exception.Message);
|
||||||
|
|
||||||
|
input = new CodedInputStream(data);
|
||||||
|
exception = Assert.Throws<InvalidProtocolBufferException>(() => input.ReadRawVarint64());
|
||||||
|
Assert.AreEqual(expected.Message, exception.Message);
|
||||||
|
|
||||||
|
// Make sure we get the same error when reading directly from a Stream.
|
||||||
|
exception = Assert.Throws<InvalidProtocolBufferException>(() => CodedInputStream.ReadRawVarint32(new MemoryStream(data)));
|
||||||
|
Assert.AreEqual(expected.Message, exception.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ReadVarint()
|
||||||
|
{
|
||||||
|
AssertReadVarint(Bytes(0x00), 0);
|
||||||
|
AssertReadVarint(Bytes(0x01), 1);
|
||||||
|
AssertReadVarint(Bytes(0x7f), 127);
|
||||||
|
// 14882
|
||||||
|
AssertReadVarint(Bytes(0xa2, 0x74), (0x22 << 0) | (0x74 << 7));
|
||||||
|
// 2961488830
|
||||||
|
AssertReadVarint(Bytes(0xbe, 0xf7, 0x92, 0x84, 0x0b),
|
||||||
|
(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
|
||||||
|
(0x0bL << 28));
|
||||||
|
|
||||||
|
// 64-bit
|
||||||
|
// 7256456126
|
||||||
|
AssertReadVarint(Bytes(0xbe, 0xf7, 0x92, 0x84, 0x1b),
|
||||||
|
(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
|
||||||
|
(0x1bL << 28));
|
||||||
|
// 41256202580718336
|
||||||
|
AssertReadVarint(Bytes(0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49),
|
||||||
|
(0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) |
|
||||||
|
(0x43L << 28) | (0x49L << 35) | (0x24L << 42) | (0x49L << 49));
|
||||||
|
// 11964378330978735131
|
||||||
|
AssertReadVarint(Bytes(0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01),
|
||||||
|
(0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) |
|
||||||
|
(0x3bUL << 28) | (0x56UL << 35) | (0x00UL << 42) |
|
||||||
|
(0x05UL << 49) | (0x26UL << 56) | (0x01UL << 63));
|
||||||
|
|
||||||
|
// Failures
|
||||||
|
AssertReadVarintFailure(
|
||||||
|
InvalidProtocolBufferException.MalformedVarint(),
|
||||||
|
Bytes(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
|
||||||
|
0x00));
|
||||||
|
AssertReadVarintFailure(
|
||||||
|
InvalidProtocolBufferException.TruncatedMessage(),
|
||||||
|
Bytes(0x80));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses the given bytes using ReadRawLittleEndian32() and checks
|
||||||
|
/// that the result matches the given value.
|
||||||
|
/// </summary>
|
||||||
|
private static void AssertReadLittleEndian32(byte[] data, uint value)
|
||||||
|
{
|
||||||
|
CodedInputStream input = new CodedInputStream(data);
|
||||||
|
Assert.AreEqual(value, input.ReadRawLittleEndian32());
|
||||||
|
Assert.IsTrue(input.IsAtEnd);
|
||||||
|
|
||||||
|
// Try different block sizes.
|
||||||
|
for (int blockSize = 1; blockSize <= 16; blockSize *= 2)
|
||||||
|
{
|
||||||
|
input = new CodedInputStream(
|
||||||
|
new SmallBlockInputStream(data, blockSize));
|
||||||
|
Assert.AreEqual(value, input.ReadRawLittleEndian32());
|
||||||
|
Assert.IsTrue(input.IsAtEnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses the given bytes using ReadRawLittleEndian64() and checks
|
||||||
|
/// that the result matches the given value.
|
||||||
|
/// </summary>
|
||||||
|
private static void AssertReadLittleEndian64(byte[] data, ulong value)
|
||||||
|
{
|
||||||
|
CodedInputStream input = new CodedInputStream(data);
|
||||||
|
Assert.AreEqual(value, input.ReadRawLittleEndian64());
|
||||||
|
Assert.IsTrue(input.IsAtEnd);
|
||||||
|
|
||||||
|
// Try different block sizes.
|
||||||
|
for (int blockSize = 1; blockSize <= 16; blockSize *= 2)
|
||||||
|
{
|
||||||
|
input = new CodedInputStream(
|
||||||
|
new SmallBlockInputStream(data, blockSize));
|
||||||
|
Assert.AreEqual(value, input.ReadRawLittleEndian64());
|
||||||
|
Assert.IsTrue(input.IsAtEnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ReadLittleEndian()
|
||||||
|
{
|
||||||
|
AssertReadLittleEndian32(Bytes(0x78, 0x56, 0x34, 0x12), 0x12345678);
|
||||||
|
AssertReadLittleEndian32(Bytes(0xf0, 0xde, 0xbc, 0x9a), 0x9abcdef0);
|
||||||
|
|
||||||
|
AssertReadLittleEndian64(Bytes(0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12),
|
||||||
|
0x123456789abcdef0L);
|
||||||
|
AssertReadLittleEndian64(
|
||||||
|
Bytes(0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a), 0x9abcdef012345678UL);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DecodeZigZag32()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(0));
|
||||||
|
Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(1));
|
||||||
|
Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(2));
|
||||||
|
Assert.AreEqual(-2, CodedInputStream.DecodeZigZag32(3));
|
||||||
|
Assert.AreEqual(0x3FFFFFFF, CodedInputStream.DecodeZigZag32(0x7FFFFFFE));
|
||||||
|
Assert.AreEqual(unchecked((int) 0xC0000000), CodedInputStream.DecodeZigZag32(0x7FFFFFFF));
|
||||||
|
Assert.AreEqual(0x7FFFFFFF, CodedInputStream.DecodeZigZag32(0xFFFFFFFE));
|
||||||
|
Assert.AreEqual(unchecked((int) 0x80000000), CodedInputStream.DecodeZigZag32(0xFFFFFFFF));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DecodeZigZag64()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(0));
|
||||||
|
Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(1));
|
||||||
|
Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(2));
|
||||||
|
Assert.AreEqual(-2, CodedInputStream.DecodeZigZag64(3));
|
||||||
|
Assert.AreEqual(0x000000003FFFFFFFL, CodedInputStream.DecodeZigZag64(0x000000007FFFFFFEL));
|
||||||
|
Assert.AreEqual(unchecked((long) 0xFFFFFFFFC0000000L), CodedInputStream.DecodeZigZag64(0x000000007FFFFFFFL));
|
||||||
|
Assert.AreEqual(0x000000007FFFFFFFL, CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFEL));
|
||||||
|
Assert.AreEqual(unchecked((long) 0xFFFFFFFF80000000L), CodedInputStream.DecodeZigZag64(0x00000000FFFFFFFFL));
|
||||||
|
Assert.AreEqual(0x7FFFFFFFFFFFFFFFL, CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFEL));
|
||||||
|
Assert.AreEqual(unchecked((long) 0x8000000000000000L), CodedInputStream.DecodeZigZag64(0xFFFFFFFFFFFFFFFFL));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ReadWholeMessage_VaryingBlockSizes()
|
||||||
|
{
|
||||||
|
TestAllTypes message = SampleMessages.CreateFullTestAllTypes();
|
||||||
|
|
||||||
|
byte[] rawBytes = message.ToByteArray();
|
||||||
|
Assert.AreEqual(rawBytes.Length, message.CalculateSize());
|
||||||
|
TestAllTypes message2 = TestAllTypes.Parser.ParseFrom(rawBytes);
|
||||||
|
Assert.AreEqual(message, message2);
|
||||||
|
|
||||||
|
// Try different block sizes.
|
||||||
|
for (int blockSize = 1; blockSize < 256; blockSize *= 2)
|
||||||
|
{
|
||||||
|
message2 = TestAllTypes.Parser.ParseFrom(new SmallBlockInputStream(rawBytes, blockSize));
|
||||||
|
Assert.AreEqual(message, message2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ReadHugeBlob()
|
||||||
|
{
|
||||||
|
// Allocate and initialize a 1MB blob.
|
||||||
|
byte[] blob = new byte[1 << 20];
|
||||||
|
for (int i = 0; i < blob.Length; i++)
|
||||||
|
{
|
||||||
|
blob[i] = (byte) i;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Make a message containing it.
|
||||||
|
var message = new TestAllTypes { SingleBytes = ByteString.CopyFrom(blob) };
|
||||||
|
|
||||||
|
// Serialize and parse it. Make sure to parse from an InputStream, not
|
||||||
|
// directly from a ByteString, so that CodedInputStream uses buffered
|
||||||
|
// reading.
|
||||||
|
TestAllTypes message2 = TestAllTypes.Parser.ParseFrom(message.ToByteString());
|
||||||
|
|
||||||
|
Assert.AreEqual(message, message2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ReadMaliciouslyLargeBlob()
|
||||||
|
{
|
||||||
|
MemoryStream ms = new MemoryStream();
|
||||||
|
CodedOutputStream output = new CodedOutputStream(ms);
|
||||||
|
|
||||||
|
uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteRawVarint32(tag);
|
||||||
|
output.WriteRawVarint32(0x7FFFFFFF);
|
||||||
|
output.WriteRawBytes(new byte[32]); // Pad with a few random bytes.
|
||||||
|
output.Flush();
|
||||||
|
ms.Position = 0;
|
||||||
|
|
||||||
|
CodedInputStream input = new CodedInputStream(ms);
|
||||||
|
Assert.AreEqual(tag, input.ReadTag());
|
||||||
|
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => input.ReadBytes());
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static TestRecursiveMessage MakeRecursiveMessage(int depth)
|
||||||
|
{
|
||||||
|
if (depth == 0)
|
||||||
|
{
|
||||||
|
return new TestRecursiveMessage { I = 5 };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new TestRecursiveMessage { A = MakeRecursiveMessage(depth - 1) };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void AssertMessageDepth(TestRecursiveMessage message, int depth)
|
||||||
|
{
|
||||||
|
if (depth == 0)
|
||||||
|
{
|
||||||
|
Assert.IsNull(message.A);
|
||||||
|
Assert.AreEqual(5, message.I);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Assert.IsNotNull(message.A);
|
||||||
|
AssertMessageDepth(message.A, depth - 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MaliciousRecursion()
|
||||||
|
{
|
||||||
|
ByteString data64 = MakeRecursiveMessage(64).ToByteString();
|
||||||
|
ByteString data65 = MakeRecursiveMessage(65).ToByteString();
|
||||||
|
|
||||||
|
AssertMessageDepth(TestRecursiveMessage.Parser.ParseFrom(data64), 64);
|
||||||
|
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestRecursiveMessage.Parser.ParseFrom(data65));
|
||||||
|
|
||||||
|
CodedInputStream input = CodedInputStream.CreateWithLimits(new MemoryStream(data64.ToByteArray()), 1000000, 63);
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestRecursiveMessage.Parser.ParseFrom(input));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SizeLimit()
|
||||||
|
{
|
||||||
|
// Have to use a Stream rather than ByteString.CreateCodedInput as SizeLimit doesn't
|
||||||
|
// apply to the latter case.
|
||||||
|
MemoryStream ms = new MemoryStream(SampleMessages.CreateFullTestAllTypes().ToByteArray());
|
||||||
|
CodedInputStream input = CodedInputStream.CreateWithLimits(ms, 16, 100);
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseFrom(input));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests that if we read an string that contains invalid UTF-8, no exception
|
||||||
|
/// is thrown. Instead, the invalid bytes are replaced with the Unicode
|
||||||
|
/// "replacement character" U+FFFD.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void ReadInvalidUtf8()
|
||||||
|
{
|
||||||
|
MemoryStream ms = new MemoryStream();
|
||||||
|
CodedOutputStream output = new CodedOutputStream(ms);
|
||||||
|
|
||||||
|
uint tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteRawVarint32(tag);
|
||||||
|
output.WriteRawVarint32(1);
|
||||||
|
output.WriteRawBytes(new byte[] {0x80});
|
||||||
|
output.Flush();
|
||||||
|
ms.Position = 0;
|
||||||
|
|
||||||
|
CodedInputStream input = new CodedInputStream(ms);
|
||||||
|
|
||||||
|
Assert.AreEqual(tag, input.ReadTag());
|
||||||
|
string text = input.ReadString();
|
||||||
|
Assert.AreEqual('\ufffd', text[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A stream which limits the number of bytes it reads at a time.
|
||||||
|
/// We use this to make sure that CodedInputStream doesn't screw up when
|
||||||
|
/// reading in small blocks.
|
||||||
|
/// </summary>
|
||||||
|
private sealed class SmallBlockInputStream : MemoryStream
|
||||||
|
{
|
||||||
|
private readonly int blockSize;
|
||||||
|
|
||||||
|
public SmallBlockInputStream(byte[] data, int blockSize)
|
||||||
|
: base(data)
|
||||||
|
{
|
||||||
|
this.blockSize = blockSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override int Read(byte[] buffer, int offset, int count)
|
||||||
|
{
|
||||||
|
return base.Read(buffer, offset, Math.Min(count, blockSize));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestNegativeEnum()
|
||||||
|
{
|
||||||
|
byte[] bytes = { 0xFE, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x01 };
|
||||||
|
CodedInputStream input = new CodedInputStream(bytes);
|
||||||
|
Assert.AreEqual((int)SampleEnum.NegativeValue, input.ReadEnum());
|
||||||
|
Assert.IsTrue(input.IsAtEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Issue 71: CodedInputStream.ReadBytes go to slow path unnecessarily
|
||||||
|
[Test]
|
||||||
|
public void TestSlowPathAvoidance()
|
||||||
|
{
|
||||||
|
using (var ms = new MemoryStream())
|
||||||
|
{
|
||||||
|
CodedOutputStream output = new CodedOutputStream(ms);
|
||||||
|
output.WriteTag(1, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteBytes(ByteString.CopyFrom(new byte[100]));
|
||||||
|
output.WriteTag(2, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteBytes(ByteString.CopyFrom(new byte[100]));
|
||||||
|
output.Flush();
|
||||||
|
|
||||||
|
ms.Position = 0;
|
||||||
|
CodedInputStream input = new CodedInputStream(ms, new byte[ms.Length / 2], 0, 0, false);
|
||||||
|
|
||||||
|
uint tag = input.ReadTag();
|
||||||
|
Assert.AreEqual(1, WireFormat.GetTagFieldNumber(tag));
|
||||||
|
Assert.AreEqual(100, input.ReadBytes().Length);
|
||||||
|
|
||||||
|
tag = input.ReadTag();
|
||||||
|
Assert.AreEqual(2, WireFormat.GetTagFieldNumber(tag));
|
||||||
|
Assert.AreEqual(100, input.ReadBytes().Length);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Tag0Throws()
|
||||||
|
{
|
||||||
|
var input = new CodedInputStream(new byte[] { 0 });
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => input.ReadTag());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SkipGroup()
|
||||||
|
{
|
||||||
|
// Create an output stream with a group in:
|
||||||
|
// Field 1: string "field 1"
|
||||||
|
// Field 2: group containing:
|
||||||
|
// Field 1: fixed int32 value 100
|
||||||
|
// Field 2: string "ignore me"
|
||||||
|
// Field 3: nested group containing
|
||||||
|
// Field 1: fixed int64 value 1000
|
||||||
|
// Field 3: string "field 3"
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(stream);
|
||||||
|
output.WriteTag(1, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteString("field 1");
|
||||||
|
|
||||||
|
// The outer group...
|
||||||
|
output.WriteTag(2, WireFormat.WireType.StartGroup);
|
||||||
|
output.WriteTag(1, WireFormat.WireType.Fixed32);
|
||||||
|
output.WriteFixed32(100);
|
||||||
|
output.WriteTag(2, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteString("ignore me");
|
||||||
|
// The nested group...
|
||||||
|
output.WriteTag(3, WireFormat.WireType.StartGroup);
|
||||||
|
output.WriteTag(1, WireFormat.WireType.Fixed64);
|
||||||
|
output.WriteFixed64(1000);
|
||||||
|
// Note: Not sure the field number is relevant for end group...
|
||||||
|
output.WriteTag(3, WireFormat.WireType.EndGroup);
|
||||||
|
|
||||||
|
// End the outer group
|
||||||
|
output.WriteTag(2, WireFormat.WireType.EndGroup);
|
||||||
|
|
||||||
|
output.WriteTag(3, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteString("field 3");
|
||||||
|
output.Flush();
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
// Now act like a generated client
|
||||||
|
var input = new CodedInputStream(stream);
|
||||||
|
Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited), input.ReadTag());
|
||||||
|
Assert.AreEqual("field 1", input.ReadString());
|
||||||
|
Assert.AreEqual(WireFormat.MakeTag(2, WireFormat.WireType.StartGroup), input.ReadTag());
|
||||||
|
input.SkipLastField(); // Should consume the whole group, including the nested one.
|
||||||
|
Assert.AreEqual(WireFormat.MakeTag(3, WireFormat.WireType.LengthDelimited), input.ReadTag());
|
||||||
|
Assert.AreEqual("field 3", input.ReadString());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SkipGroup_WrongEndGroupTag()
|
||||||
|
{
|
||||||
|
// Create an output stream with:
|
||||||
|
// Field 1: string "field 1"
|
||||||
|
// Start group 2
|
||||||
|
// Field 3: fixed int32
|
||||||
|
// End group 4 (should give an error)
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(stream);
|
||||||
|
output.WriteTag(1, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteString("field 1");
|
||||||
|
|
||||||
|
// The outer group...
|
||||||
|
output.WriteTag(2, WireFormat.WireType.StartGroup);
|
||||||
|
output.WriteTag(3, WireFormat.WireType.Fixed32);
|
||||||
|
output.WriteFixed32(100);
|
||||||
|
output.WriteTag(4, WireFormat.WireType.EndGroup);
|
||||||
|
output.Flush();
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
// Now act like a generated client
|
||||||
|
var input = new CodedInputStream(stream);
|
||||||
|
Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited), input.ReadTag());
|
||||||
|
Assert.AreEqual("field 1", input.ReadString());
|
||||||
|
Assert.AreEqual(WireFormat.MakeTag(2, WireFormat.WireType.StartGroup), input.ReadTag());
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(input.SkipLastField);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void RogueEndGroupTag()
|
||||||
|
{
|
||||||
|
// If we have an end-group tag without a leading start-group tag, generated
|
||||||
|
// code will just call SkipLastField... so that should fail.
|
||||||
|
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(stream);
|
||||||
|
output.WriteTag(1, WireFormat.WireType.EndGroup);
|
||||||
|
output.Flush();
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
var input = new CodedInputStream(stream);
|
||||||
|
Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.EndGroup), input.ReadTag());
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(input.SkipLastField);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EndOfStreamReachedWhileSkippingGroup()
|
||||||
|
{
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(stream);
|
||||||
|
output.WriteTag(1, WireFormat.WireType.StartGroup);
|
||||||
|
output.WriteTag(2, WireFormat.WireType.StartGroup);
|
||||||
|
output.WriteTag(2, WireFormat.WireType.EndGroup);
|
||||||
|
|
||||||
|
output.Flush();
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
// Now act like a generated client
|
||||||
|
var input = new CodedInputStream(stream);
|
||||||
|
input.ReadTag();
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(input.SkipLastField);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void RecursionLimitAppliedWhileSkippingGroup()
|
||||||
|
{
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(stream);
|
||||||
|
for (int i = 0; i < CodedInputStream.DefaultRecursionLimit + 1; i++)
|
||||||
|
{
|
||||||
|
output.WriteTag(1, WireFormat.WireType.StartGroup);
|
||||||
|
}
|
||||||
|
for (int i = 0; i < CodedInputStream.DefaultRecursionLimit + 1; i++)
|
||||||
|
{
|
||||||
|
output.WriteTag(1, WireFormat.WireType.EndGroup);
|
||||||
|
}
|
||||||
|
output.Flush();
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
// Now act like a generated client
|
||||||
|
var input = new CodedInputStream(stream);
|
||||||
|
Assert.AreEqual(WireFormat.MakeTag(1, WireFormat.WireType.StartGroup), input.ReadTag());
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(input.SkipLastField);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Construction_Invalid()
|
||||||
|
{
|
||||||
|
Assert.Throws<ArgumentNullException>(() => new CodedInputStream((byte[]) null));
|
||||||
|
Assert.Throws<ArgumentNullException>(() => new CodedInputStream(null, 0, 0));
|
||||||
|
Assert.Throws<ArgumentNullException>(() => new CodedInputStream((Stream) null));
|
||||||
|
Assert.Throws<ArgumentOutOfRangeException>(() => new CodedInputStream(new byte[10], 100, 0));
|
||||||
|
Assert.Throws<ArgumentOutOfRangeException>(() => new CodedInputStream(new byte[10], 5, 10));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CreateWithLimits_InvalidLimits()
|
||||||
|
{
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
Assert.Throws<ArgumentOutOfRangeException>(() => CodedInputStream.CreateWithLimits(stream, 0, 1));
|
||||||
|
Assert.Throws<ArgumentOutOfRangeException>(() => CodedInputStream.CreateWithLimits(stream, 1, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Dispose_DisposesUnderlyingStream()
|
||||||
|
{
|
||||||
|
var memoryStream = new MemoryStream();
|
||||||
|
Assert.IsTrue(memoryStream.CanRead);
|
||||||
|
using (var cis = new CodedInputStream(memoryStream))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
Assert.IsFalse(memoryStream.CanRead); // Disposed
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Dispose_WithLeaveOpen()
|
||||||
|
{
|
||||||
|
var memoryStream = new MemoryStream();
|
||||||
|
Assert.IsTrue(memoryStream.CanRead);
|
||||||
|
using (var cis = new CodedInputStream(memoryStream, true))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
Assert.IsTrue(memoryStream.CanRead); // We left the stream open
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,419 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// 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.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using Google.Protobuf.TestProtos;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Google.Protobuf
|
||||||
|
{
|
||||||
|
public class CodedOutputStreamTest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Writes the given value using WriteRawVarint32() and WriteRawVarint64() and
|
||||||
|
/// checks that the result matches the given bytes
|
||||||
|
/// </summary>
|
||||||
|
private static void AssertWriteVarint(byte[] data, ulong value)
|
||||||
|
{
|
||||||
|
// Only do 32-bit write if the value fits in 32 bits.
|
||||||
|
if ((value >> 32) == 0)
|
||||||
|
{
|
||||||
|
MemoryStream rawOutput = new MemoryStream();
|
||||||
|
CodedOutputStream output = new CodedOutputStream(rawOutput);
|
||||||
|
output.WriteRawVarint32((uint) value);
|
||||||
|
output.Flush();
|
||||||
|
Assert.AreEqual(data, rawOutput.ToArray());
|
||||||
|
// Also try computing size.
|
||||||
|
Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint32Size((uint) value));
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
MemoryStream rawOutput = new MemoryStream();
|
||||||
|
CodedOutputStream output = new CodedOutputStream(rawOutput);
|
||||||
|
output.WriteRawVarint64(value);
|
||||||
|
output.Flush();
|
||||||
|
Assert.AreEqual(data, rawOutput.ToArray());
|
||||||
|
|
||||||
|
// Also try computing size.
|
||||||
|
Assert.AreEqual(data.Length, CodedOutputStream.ComputeRawVarint64Size(value));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Try different buffer sizes.
|
||||||
|
for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2)
|
||||||
|
{
|
||||||
|
// Only do 32-bit write if the value fits in 32 bits.
|
||||||
|
if ((value >> 32) == 0)
|
||||||
|
{
|
||||||
|
MemoryStream rawOutput = new MemoryStream();
|
||||||
|
CodedOutputStream output =
|
||||||
|
new CodedOutputStream(rawOutput, bufferSize);
|
||||||
|
output.WriteRawVarint32((uint) value);
|
||||||
|
output.Flush();
|
||||||
|
Assert.AreEqual(data, rawOutput.ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
MemoryStream rawOutput = new MemoryStream();
|
||||||
|
CodedOutputStream output = new CodedOutputStream(rawOutput, bufferSize);
|
||||||
|
output.WriteRawVarint64(value);
|
||||||
|
output.Flush();
|
||||||
|
Assert.AreEqual(data, rawOutput.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests WriteRawVarint32() and WriteRawVarint64()
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void WriteVarint()
|
||||||
|
{
|
||||||
|
AssertWriteVarint(new byte[] {0x00}, 0);
|
||||||
|
AssertWriteVarint(new byte[] {0x01}, 1);
|
||||||
|
AssertWriteVarint(new byte[] {0x7f}, 127);
|
||||||
|
// 14882
|
||||||
|
AssertWriteVarint(new byte[] {0xa2, 0x74}, (0x22 << 0) | (0x74 << 7));
|
||||||
|
// 2961488830
|
||||||
|
AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x0b},
|
||||||
|
(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
|
||||||
|
(0x0bL << 28));
|
||||||
|
|
||||||
|
// 64-bit
|
||||||
|
// 7256456126
|
||||||
|
AssertWriteVarint(new byte[] {0xbe, 0xf7, 0x92, 0x84, 0x1b},
|
||||||
|
(0x3e << 0) | (0x77 << 7) | (0x12 << 14) | (0x04 << 21) |
|
||||||
|
(0x1bL << 28));
|
||||||
|
// 41256202580718336
|
||||||
|
AssertWriteVarint(
|
||||||
|
new byte[] {0x80, 0xe6, 0xeb, 0x9c, 0xc3, 0xc9, 0xa4, 0x49},
|
||||||
|
(0x00 << 0) | (0x66 << 7) | (0x6b << 14) | (0x1c << 21) |
|
||||||
|
(0x43UL << 28) | (0x49L << 35) | (0x24UL << 42) | (0x49UL << 49));
|
||||||
|
// 11964378330978735131
|
||||||
|
AssertWriteVarint(
|
||||||
|
new byte[] {0x9b, 0xa8, 0xf9, 0xc2, 0xbb, 0xd6, 0x80, 0x85, 0xa6, 0x01},
|
||||||
|
unchecked((ulong)
|
||||||
|
((0x1b << 0) | (0x28 << 7) | (0x79 << 14) | (0x42 << 21) |
|
||||||
|
(0x3bL << 28) | (0x56L << 35) | (0x00L << 42) |
|
||||||
|
(0x05L << 49) | (0x26L << 56) | (0x01L << 63))));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses the given bytes using WriteRawLittleEndian32() and checks
|
||||||
|
/// that the result matches the given value.
|
||||||
|
/// </summary>
|
||||||
|
private static void AssertWriteLittleEndian32(byte[] data, uint value)
|
||||||
|
{
|
||||||
|
MemoryStream rawOutput = new MemoryStream();
|
||||||
|
CodedOutputStream output = new CodedOutputStream(rawOutput);
|
||||||
|
output.WriteRawLittleEndian32(value);
|
||||||
|
output.Flush();
|
||||||
|
Assert.AreEqual(data, rawOutput.ToArray());
|
||||||
|
|
||||||
|
// Try different buffer sizes.
|
||||||
|
for (int bufferSize = 1; bufferSize <= 16; bufferSize *= 2)
|
||||||
|
{
|
||||||
|
rawOutput = new MemoryStream();
|
||||||
|
output = new CodedOutputStream(rawOutput, bufferSize);
|
||||||
|
output.WriteRawLittleEndian32(value);
|
||||||
|
output.Flush();
|
||||||
|
Assert.AreEqual(data, rawOutput.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parses the given bytes using WriteRawLittleEndian64() and checks
|
||||||
|
/// that the result matches the given value.
|
||||||
|
/// </summary>
|
||||||
|
private static void AssertWriteLittleEndian64(byte[] data, ulong value)
|
||||||
|
{
|
||||||
|
MemoryStream rawOutput = new MemoryStream();
|
||||||
|
CodedOutputStream output = new CodedOutputStream(rawOutput);
|
||||||
|
output.WriteRawLittleEndian64(value);
|
||||||
|
output.Flush();
|
||||||
|
Assert.AreEqual(data, rawOutput.ToArray());
|
||||||
|
|
||||||
|
// Try different block sizes.
|
||||||
|
for (int blockSize = 1; blockSize <= 16; blockSize *= 2)
|
||||||
|
{
|
||||||
|
rawOutput = new MemoryStream();
|
||||||
|
output = new CodedOutputStream(rawOutput, blockSize);
|
||||||
|
output.WriteRawLittleEndian64(value);
|
||||||
|
output.Flush();
|
||||||
|
Assert.AreEqual(data, rawOutput.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tests writeRawLittleEndian32() and writeRawLittleEndian64().
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void WriteLittleEndian()
|
||||||
|
{
|
||||||
|
AssertWriteLittleEndian32(new byte[] {0x78, 0x56, 0x34, 0x12}, 0x12345678);
|
||||||
|
AssertWriteLittleEndian32(new byte[] {0xf0, 0xde, 0xbc, 0x9a}, 0x9abcdef0);
|
||||||
|
|
||||||
|
AssertWriteLittleEndian64(
|
||||||
|
new byte[] {0xf0, 0xde, 0xbc, 0x9a, 0x78, 0x56, 0x34, 0x12},
|
||||||
|
0x123456789abcdef0L);
|
||||||
|
AssertWriteLittleEndian64(
|
||||||
|
new byte[] {0x78, 0x56, 0x34, 0x12, 0xf0, 0xde, 0xbc, 0x9a},
|
||||||
|
0x9abcdef012345678UL);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void WriteWholeMessage_VaryingBlockSizes()
|
||||||
|
{
|
||||||
|
TestAllTypes message = SampleMessages.CreateFullTestAllTypes();
|
||||||
|
|
||||||
|
byte[] rawBytes = message.ToByteArray();
|
||||||
|
|
||||||
|
// Try different block sizes.
|
||||||
|
for (int blockSize = 1; blockSize < 256; blockSize *= 2)
|
||||||
|
{
|
||||||
|
MemoryStream rawOutput = new MemoryStream();
|
||||||
|
CodedOutputStream output = new CodedOutputStream(rawOutput, blockSize);
|
||||||
|
message.WriteTo(output);
|
||||||
|
output.Flush();
|
||||||
|
Assert.AreEqual(rawBytes, rawOutput.ToArray());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EncodeZigZag32()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(0u, CodedOutputStream.EncodeZigZag32(0));
|
||||||
|
Assert.AreEqual(1u, CodedOutputStream.EncodeZigZag32(-1));
|
||||||
|
Assert.AreEqual(2u, CodedOutputStream.EncodeZigZag32(1));
|
||||||
|
Assert.AreEqual(3u, CodedOutputStream.EncodeZigZag32(-2));
|
||||||
|
Assert.AreEqual(0x7FFFFFFEu, CodedOutputStream.EncodeZigZag32(0x3FFFFFFF));
|
||||||
|
Assert.AreEqual(0x7FFFFFFFu, CodedOutputStream.EncodeZigZag32(unchecked((int) 0xC0000000)));
|
||||||
|
Assert.AreEqual(0xFFFFFFFEu, CodedOutputStream.EncodeZigZag32(0x7FFFFFFF));
|
||||||
|
Assert.AreEqual(0xFFFFFFFFu, CodedOutputStream.EncodeZigZag32(unchecked((int) 0x80000000)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EncodeZigZag64()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(0u, CodedOutputStream.EncodeZigZag64(0));
|
||||||
|
Assert.AreEqual(1u, CodedOutputStream.EncodeZigZag64(-1));
|
||||||
|
Assert.AreEqual(2u, CodedOutputStream.EncodeZigZag64(1));
|
||||||
|
Assert.AreEqual(3u, CodedOutputStream.EncodeZigZag64(-2));
|
||||||
|
Assert.AreEqual(0x000000007FFFFFFEuL,
|
||||||
|
CodedOutputStream.EncodeZigZag64(unchecked((long) 0x000000003FFFFFFFUL)));
|
||||||
|
Assert.AreEqual(0x000000007FFFFFFFuL,
|
||||||
|
CodedOutputStream.EncodeZigZag64(unchecked((long) 0xFFFFFFFFC0000000UL)));
|
||||||
|
Assert.AreEqual(0x00000000FFFFFFFEuL,
|
||||||
|
CodedOutputStream.EncodeZigZag64(unchecked((long) 0x000000007FFFFFFFUL)));
|
||||||
|
Assert.AreEqual(0x00000000FFFFFFFFuL,
|
||||||
|
CodedOutputStream.EncodeZigZag64(unchecked((long) 0xFFFFFFFF80000000UL)));
|
||||||
|
Assert.AreEqual(0xFFFFFFFFFFFFFFFEL,
|
||||||
|
CodedOutputStream.EncodeZigZag64(unchecked((long) 0x7FFFFFFFFFFFFFFFUL)));
|
||||||
|
Assert.AreEqual(0xFFFFFFFFFFFFFFFFL,
|
||||||
|
CodedOutputStream.EncodeZigZag64(unchecked((long) 0x8000000000000000UL)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void RoundTripZigZag32()
|
||||||
|
{
|
||||||
|
// Some easier-to-verify round-trip tests. The inputs (other than 0, 1, -1)
|
||||||
|
// were chosen semi-randomly via keyboard bashing.
|
||||||
|
Assert.AreEqual(0, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(0)));
|
||||||
|
Assert.AreEqual(1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(1)));
|
||||||
|
Assert.AreEqual(-1, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-1)));
|
||||||
|
Assert.AreEqual(14927, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(14927)));
|
||||||
|
Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag32(CodedOutputStream.EncodeZigZag32(-3612)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void RoundTripZigZag64()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(0, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(0)));
|
||||||
|
Assert.AreEqual(1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(1)));
|
||||||
|
Assert.AreEqual(-1, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-1)));
|
||||||
|
Assert.AreEqual(14927, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(14927)));
|
||||||
|
Assert.AreEqual(-3612, CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-3612)));
|
||||||
|
|
||||||
|
Assert.AreEqual(856912304801416L,
|
||||||
|
CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(856912304801416L)));
|
||||||
|
Assert.AreEqual(-75123905439571256L,
|
||||||
|
CodedInputStream.DecodeZigZag64(CodedOutputStream.EncodeZigZag64(-75123905439571256L)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestNegativeEnumNoTag()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(10, CodedOutputStream.ComputeInt32Size(-2));
|
||||||
|
Assert.AreEqual(10, CodedOutputStream.ComputeEnumSize((int) SampleEnum.NegativeValue));
|
||||||
|
|
||||||
|
byte[] bytes = new byte[10];
|
||||||
|
CodedOutputStream output = new CodedOutputStream(bytes);
|
||||||
|
output.WriteEnum((int) SampleEnum.NegativeValue);
|
||||||
|
|
||||||
|
Assert.AreEqual(0, output.SpaceLeft);
|
||||||
|
Assert.AreEqual("FE-FF-FF-FF-FF-FF-FF-FF-FF-01", BitConverter.ToString(bytes));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCodedInputOutputPosition()
|
||||||
|
{
|
||||||
|
byte[] content = new byte[110];
|
||||||
|
for (int i = 0; i < content.Length; i++)
|
||||||
|
content[i] = (byte)i;
|
||||||
|
|
||||||
|
byte[] child = new byte[120];
|
||||||
|
{
|
||||||
|
MemoryStream ms = new MemoryStream(child);
|
||||||
|
CodedOutputStream cout = new CodedOutputStream(ms, 20);
|
||||||
|
// Field 11: numeric value: 500
|
||||||
|
cout.WriteTag(11, WireFormat.WireType.Varint);
|
||||||
|
Assert.AreEqual(1, cout.Position);
|
||||||
|
cout.WriteInt32(500);
|
||||||
|
Assert.AreEqual(3, cout.Position);
|
||||||
|
//Field 12: length delimited 120 bytes
|
||||||
|
cout.WriteTag(12, WireFormat.WireType.LengthDelimited);
|
||||||
|
Assert.AreEqual(4, cout.Position);
|
||||||
|
cout.WriteBytes(ByteString.CopyFrom(content));
|
||||||
|
Assert.AreEqual(115, cout.Position);
|
||||||
|
// Field 13: fixed numeric value: 501
|
||||||
|
cout.WriteTag(13, WireFormat.WireType.Fixed32);
|
||||||
|
Assert.AreEqual(116, cout.Position);
|
||||||
|
cout.WriteSFixed32(501);
|
||||||
|
Assert.AreEqual(120, cout.Position);
|
||||||
|
cout.Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
byte[] bytes = new byte[130];
|
||||||
|
{
|
||||||
|
CodedOutputStream cout = new CodedOutputStream(bytes);
|
||||||
|
// Field 1: numeric value: 500
|
||||||
|
cout.WriteTag(1, WireFormat.WireType.Varint);
|
||||||
|
Assert.AreEqual(1, cout.Position);
|
||||||
|
cout.WriteInt32(500);
|
||||||
|
Assert.AreEqual(3, cout.Position);
|
||||||
|
//Field 2: length delimited 120 bytes
|
||||||
|
cout.WriteTag(2, WireFormat.WireType.LengthDelimited);
|
||||||
|
Assert.AreEqual(4, cout.Position);
|
||||||
|
cout.WriteBytes(ByteString.CopyFrom(child));
|
||||||
|
Assert.AreEqual(125, cout.Position);
|
||||||
|
// Field 3: fixed numeric value: 500
|
||||||
|
cout.WriteTag(3, WireFormat.WireType.Fixed32);
|
||||||
|
Assert.AreEqual(126, cout.Position);
|
||||||
|
cout.WriteSFixed32(501);
|
||||||
|
Assert.AreEqual(130, cout.Position);
|
||||||
|
cout.Flush();
|
||||||
|
}
|
||||||
|
// Now test Input stream:
|
||||||
|
{
|
||||||
|
CodedInputStream cin = new CodedInputStream(new MemoryStream(bytes), new byte[50], 0, 0, false);
|
||||||
|
Assert.AreEqual(0, cin.Position);
|
||||||
|
// Field 1:
|
||||||
|
uint tag = cin.ReadTag();
|
||||||
|
Assert.AreEqual(1, tag >> 3);
|
||||||
|
Assert.AreEqual(1, cin.Position);
|
||||||
|
Assert.AreEqual(500, cin.ReadInt32());
|
||||||
|
Assert.AreEqual(3, cin.Position);
|
||||||
|
//Field 2:
|
||||||
|
tag = cin.ReadTag();
|
||||||
|
Assert.AreEqual(2, tag >> 3);
|
||||||
|
Assert.AreEqual(4, cin.Position);
|
||||||
|
int childlen = cin.ReadLength();
|
||||||
|
Assert.AreEqual(120, childlen);
|
||||||
|
Assert.AreEqual(5, cin.Position);
|
||||||
|
int oldlimit = cin.PushLimit((int)childlen);
|
||||||
|
Assert.AreEqual(5, cin.Position);
|
||||||
|
// Now we are reading child message
|
||||||
|
{
|
||||||
|
// Field 11: numeric value: 500
|
||||||
|
tag = cin.ReadTag();
|
||||||
|
Assert.AreEqual(11, tag >> 3);
|
||||||
|
Assert.AreEqual(6, cin.Position);
|
||||||
|
Assert.AreEqual(500, cin.ReadInt32());
|
||||||
|
Assert.AreEqual(8, cin.Position);
|
||||||
|
//Field 12: length delimited 120 bytes
|
||||||
|
tag = cin.ReadTag();
|
||||||
|
Assert.AreEqual(12, tag >> 3);
|
||||||
|
Assert.AreEqual(9, cin.Position);
|
||||||
|
ByteString bstr = cin.ReadBytes();
|
||||||
|
Assert.AreEqual(110, bstr.Length);
|
||||||
|
Assert.AreEqual((byte) 109, bstr[109]);
|
||||||
|
Assert.AreEqual(120, cin.Position);
|
||||||
|
// Field 13: fixed numeric value: 501
|
||||||
|
tag = cin.ReadTag();
|
||||||
|
Assert.AreEqual(13, tag >> 3);
|
||||||
|
// ROK - Previously broken here, this returned 126 failing to account for bufferSizeAfterLimit
|
||||||
|
Assert.AreEqual(121, cin.Position);
|
||||||
|
Assert.AreEqual(501, cin.ReadSFixed32());
|
||||||
|
Assert.AreEqual(125, cin.Position);
|
||||||
|
Assert.IsTrue(cin.IsAtEnd);
|
||||||
|
}
|
||||||
|
cin.PopLimit(oldlimit);
|
||||||
|
Assert.AreEqual(125, cin.Position);
|
||||||
|
// Field 3: fixed numeric value: 501
|
||||||
|
tag = cin.ReadTag();
|
||||||
|
Assert.AreEqual(3, tag >> 3);
|
||||||
|
Assert.AreEqual(126, cin.Position);
|
||||||
|
Assert.AreEqual(501, cin.ReadSFixed32());
|
||||||
|
Assert.AreEqual(130, cin.Position);
|
||||||
|
Assert.IsTrue(cin.IsAtEnd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Dispose_DisposesUnderlyingStream()
|
||||||
|
{
|
||||||
|
var memoryStream = new MemoryStream();
|
||||||
|
Assert.IsTrue(memoryStream.CanWrite);
|
||||||
|
using (var cos = new CodedOutputStream(memoryStream))
|
||||||
|
{
|
||||||
|
cos.WriteRawByte(0);
|
||||||
|
Assert.AreEqual(0, memoryStream.Position); // Not flushed yet
|
||||||
|
}
|
||||||
|
Assert.AreEqual(1, memoryStream.ToArray().Length); // Flushed data from CodedOutputStream to MemoryStream
|
||||||
|
Assert.IsFalse(memoryStream.CanWrite); // Disposed
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Dispose_WithLeaveOpen()
|
||||||
|
{
|
||||||
|
var memoryStream = new MemoryStream();
|
||||||
|
Assert.IsTrue(memoryStream.CanWrite);
|
||||||
|
using (var cos = new CodedOutputStream(memoryStream, true))
|
||||||
|
{
|
||||||
|
cos.WriteRawByte(0);
|
||||||
|
Assert.AreEqual(0, memoryStream.Position); // Not flushed yet
|
||||||
|
}
|
||||||
|
Assert.AreEqual(1, memoryStream.Position); // Flushed data from CodedOutputStream to MemoryStream
|
||||||
|
Assert.IsTrue(memoryStream.CanWrite); // We left the stream open
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,532 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2015 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.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Google.Protobuf.TestProtos;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Google.Protobuf.Collections
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Tests for MapField which aren't reliant on the encoded format -
|
||||||
|
/// tests for serialization/deserialization are part of GeneratedMessageTest.
|
||||||
|
/// </summary>
|
||||||
|
public class MapFieldTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void Clone_ClonesMessages()
|
||||||
|
{
|
||||||
|
var message = new ForeignMessage { C = 20 };
|
||||||
|
var map = new MapField<string, ForeignMessage> { { "x", message } };
|
||||||
|
var clone = map.Clone();
|
||||||
|
map["x"].C = 30;
|
||||||
|
Assert.AreEqual(20, clone["x"].C);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void NullValuesProhibited()
|
||||||
|
{
|
||||||
|
TestNullValues<int?>(0);
|
||||||
|
TestNullValues("");
|
||||||
|
TestNullValues(new TestAllTypes());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TestNullValues<T>(T nonNullValue)
|
||||||
|
{
|
||||||
|
var map = new MapField<int, T>();
|
||||||
|
var nullValue = (T) (object) null;
|
||||||
|
Assert.Throws<ArgumentNullException>(() => map.Add(0, nullValue));
|
||||||
|
Assert.Throws<ArgumentNullException>(() => map[0] = nullValue);
|
||||||
|
map.Add(1, nonNullValue);
|
||||||
|
map[1] = nonNullValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Add_ForbidsNullKeys()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, ForeignMessage>();
|
||||||
|
Assert.Throws<ArgumentNullException>(() => map.Add(null, new ForeignMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Indexer_ForbidsNullKeys()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, ForeignMessage>();
|
||||||
|
Assert.Throws<ArgumentNullException>(() => map[null] = new ForeignMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddPreservesInsertionOrder()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string>();
|
||||||
|
map.Add("a", "v1");
|
||||||
|
map.Add("b", "v2");
|
||||||
|
map.Add("c", "v3");
|
||||||
|
map.Remove("b");
|
||||||
|
map.Add("d", "v4");
|
||||||
|
CollectionAssert.AreEqual(new[] { "a", "c", "d" }, map.Keys);
|
||||||
|
CollectionAssert.AreEqual(new[] { "v1", "v3", "v4" }, map.Values);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EqualityIsOrderInsensitive()
|
||||||
|
{
|
||||||
|
var map1 = new MapField<string, string>();
|
||||||
|
map1.Add("a", "v1");
|
||||||
|
map1.Add("b", "v2");
|
||||||
|
|
||||||
|
var map2 = new MapField<string, string>();
|
||||||
|
map2.Add("b", "v2");
|
||||||
|
map2.Add("a", "v1");
|
||||||
|
|
||||||
|
EqualityTester.AssertEquality(map1, map2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EqualityIsKeySensitive()
|
||||||
|
{
|
||||||
|
var map1 = new MapField<string, string>();
|
||||||
|
map1.Add("first key", "v1");
|
||||||
|
map1.Add("second key", "v2");
|
||||||
|
|
||||||
|
var map2 = new MapField<string, string>();
|
||||||
|
map2.Add("third key", "v1");
|
||||||
|
map2.Add("fourth key", "v2");
|
||||||
|
|
||||||
|
EqualityTester.AssertInequality(map1, map2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Equality_Simple()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string>();
|
||||||
|
EqualityTester.AssertEquality(map, map);
|
||||||
|
EqualityTester.AssertInequality(map, null);
|
||||||
|
Assert.IsFalse(map.Equals(new object()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EqualityIsValueSensitive()
|
||||||
|
{
|
||||||
|
// Note: Without some care, it's a little easier than one might
|
||||||
|
// hope to see hash collisions, but only in some environments...
|
||||||
|
var map1 = new MapField<string, string>();
|
||||||
|
map1.Add("a", "first value");
|
||||||
|
map1.Add("b", "second value");
|
||||||
|
|
||||||
|
var map2 = new MapField<string, string>();
|
||||||
|
map2.Add("a", "third value");
|
||||||
|
map2.Add("b", "fourth value");
|
||||||
|
|
||||||
|
EqualityTester.AssertInequality(map1, map2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Add_Dictionary()
|
||||||
|
{
|
||||||
|
var map1 = new MapField<string, string>
|
||||||
|
{
|
||||||
|
{ "x", "y" },
|
||||||
|
{ "a", "b" }
|
||||||
|
};
|
||||||
|
var map2 = new MapField<string, string>
|
||||||
|
{
|
||||||
|
{ "before", "" },
|
||||||
|
map1,
|
||||||
|
{ "after", "" }
|
||||||
|
};
|
||||||
|
var expected = new MapField<string, string>
|
||||||
|
{
|
||||||
|
{ "before", "" },
|
||||||
|
{ "x", "y" },
|
||||||
|
{ "a", "b" },
|
||||||
|
{ "after", "" }
|
||||||
|
};
|
||||||
|
Assert.AreEqual(expected, map2);
|
||||||
|
CollectionAssert.AreEqual(new[] { "before", "x", "a", "after" }, map2.Keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
// General IDictionary<TKey, TValue> behavior tests
|
||||||
|
[Test]
|
||||||
|
public void Add_KeyAlreadyExists()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string>();
|
||||||
|
map.Add("foo", "bar");
|
||||||
|
Assert.Throws<ArgumentException>(() => map.Add("foo", "baz"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Add_Pair()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string>();
|
||||||
|
ICollection<KeyValuePair<string, string>> collection = map;
|
||||||
|
collection.Add(NewKeyValuePair("x", "y"));
|
||||||
|
Assert.AreEqual("y", map["x"]);
|
||||||
|
Assert.Throws<ArgumentException>(() => collection.Add(NewKeyValuePair("x", "z")));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Contains_Pair()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string> { { "x", "y" } };
|
||||||
|
ICollection<KeyValuePair<string, string>> collection = map;
|
||||||
|
Assert.IsTrue(collection.Contains(NewKeyValuePair("x", "y")));
|
||||||
|
Assert.IsFalse(collection.Contains(NewKeyValuePair("x", "z")));
|
||||||
|
Assert.IsFalse(collection.Contains(NewKeyValuePair("z", "y")));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Remove_Key()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string>();
|
||||||
|
map.Add("foo", "bar");
|
||||||
|
Assert.AreEqual(1, map.Count);
|
||||||
|
Assert.IsFalse(map.Remove("missing"));
|
||||||
|
Assert.AreEqual(1, map.Count);
|
||||||
|
Assert.IsTrue(map.Remove("foo"));
|
||||||
|
Assert.AreEqual(0, map.Count);
|
||||||
|
Assert.Throws<ArgumentNullException>(() => map.Remove(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Remove_Pair()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string>();
|
||||||
|
map.Add("foo", "bar");
|
||||||
|
ICollection<KeyValuePair<string, string>> collection = map;
|
||||||
|
Assert.AreEqual(1, map.Count);
|
||||||
|
Assert.IsFalse(collection.Remove(NewKeyValuePair("wrong key", "bar")));
|
||||||
|
Assert.AreEqual(1, map.Count);
|
||||||
|
Assert.IsFalse(collection.Remove(NewKeyValuePair("foo", "wrong value")));
|
||||||
|
Assert.AreEqual(1, map.Count);
|
||||||
|
Assert.IsTrue(collection.Remove(NewKeyValuePair("foo", "bar")));
|
||||||
|
Assert.AreEqual(0, map.Count);
|
||||||
|
Assert.Throws<ArgumentException>(() => collection.Remove(new KeyValuePair<string, string>(null, "")));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CopyTo_Pair()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string>();
|
||||||
|
map.Add("foo", "bar");
|
||||||
|
ICollection<KeyValuePair<string, string>> collection = map;
|
||||||
|
KeyValuePair<string, string>[] array = new KeyValuePair<string, string>[3];
|
||||||
|
collection.CopyTo(array, 1);
|
||||||
|
Assert.AreEqual(NewKeyValuePair("foo", "bar"), array[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string> { { "x", "y" } };
|
||||||
|
Assert.AreEqual(1, map.Count);
|
||||||
|
map.Clear();
|
||||||
|
Assert.AreEqual(0, map.Count);
|
||||||
|
map.Add("x", "y");
|
||||||
|
Assert.AreEqual(1, map.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Indexer_Get()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string> { { "x", "y" } };
|
||||||
|
Assert.AreEqual("y", map["x"]);
|
||||||
|
Assert.Throws<KeyNotFoundException>(() => { var ignored = map["z"]; });
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Indexer_Set()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string>();
|
||||||
|
map["x"] = "y";
|
||||||
|
Assert.AreEqual("y", map["x"]);
|
||||||
|
map["x"] = "z"; // This won't throw, unlike Add.
|
||||||
|
Assert.AreEqual("z", map["x"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetEnumerator_NonGeneric()
|
||||||
|
{
|
||||||
|
IEnumerable map = new MapField<string, string> { { "x", "y" } };
|
||||||
|
CollectionAssert.AreEqual(new[] { new KeyValuePair<string, string>("x", "y") },
|
||||||
|
map.Cast<object>().ToList());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test for the explicitly-implemented non-generic IDictionary interface
|
||||||
|
[Test]
|
||||||
|
public void IDictionary_GetEnumerator()
|
||||||
|
{
|
||||||
|
IDictionary map = new MapField<string, string> { { "x", "y" } };
|
||||||
|
var enumerator = map.GetEnumerator();
|
||||||
|
|
||||||
|
// Commented assertions show an ideal situation - it looks like
|
||||||
|
// the LinkedList enumerator doesn't throw when you ask for the current entry
|
||||||
|
// at an inappropriate time; fixing this would be more work than it's worth.
|
||||||
|
// Assert.Throws<InvalidOperationException>(() => enumerator.Current.GetHashCode());
|
||||||
|
Assert.IsTrue(enumerator.MoveNext());
|
||||||
|
Assert.AreEqual("x", enumerator.Key);
|
||||||
|
Assert.AreEqual("y", enumerator.Value);
|
||||||
|
Assert.AreEqual(new DictionaryEntry("x", "y"), enumerator.Current);
|
||||||
|
Assert.AreEqual(new DictionaryEntry("x", "y"), enumerator.Entry);
|
||||||
|
Assert.IsFalse(enumerator.MoveNext());
|
||||||
|
// Assert.Throws<InvalidOperationException>(() => enumerator.Current.GetHashCode());
|
||||||
|
enumerator.Reset();
|
||||||
|
// Assert.Throws<InvalidOperationException>(() => enumerator.Current.GetHashCode());
|
||||||
|
Assert.IsTrue(enumerator.MoveNext());
|
||||||
|
Assert.AreEqual("x", enumerator.Key); // Assume the rest are okay
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IDictionary_Add()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string> { { "x", "y" } };
|
||||||
|
IDictionary dictionary = map;
|
||||||
|
dictionary.Add("a", "b");
|
||||||
|
Assert.AreEqual("b", map["a"]);
|
||||||
|
Assert.Throws<ArgumentException>(() => dictionary.Add("a", "duplicate"));
|
||||||
|
Assert.Throws<InvalidCastException>(() => dictionary.Add(new object(), "key is bad"));
|
||||||
|
Assert.Throws<InvalidCastException>(() => dictionary.Add("value is bad", new object()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IDictionary_Contains()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string> { { "x", "y" } };
|
||||||
|
IDictionary dictionary = map;
|
||||||
|
|
||||||
|
Assert.IsFalse(dictionary.Contains("a"));
|
||||||
|
Assert.IsFalse(dictionary.Contains(5));
|
||||||
|
// Surprising, but IDictionary.Contains is only about keys.
|
||||||
|
Assert.IsFalse(dictionary.Contains(new DictionaryEntry("x", "y")));
|
||||||
|
Assert.IsTrue(dictionary.Contains("x"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IDictionary_Remove()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string> { { "x", "y" } };
|
||||||
|
IDictionary dictionary = map;
|
||||||
|
dictionary.Remove("a");
|
||||||
|
Assert.AreEqual(1, dictionary.Count);
|
||||||
|
dictionary.Remove(5);
|
||||||
|
Assert.AreEqual(1, dictionary.Count);
|
||||||
|
dictionary.Remove(new DictionaryEntry("x", "y"));
|
||||||
|
Assert.AreEqual(1, dictionary.Count);
|
||||||
|
dictionary.Remove("x");
|
||||||
|
Assert.AreEqual(0, dictionary.Count);
|
||||||
|
Assert.Throws<ArgumentNullException>(() => dictionary.Remove(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IDictionary_CopyTo()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string> { { "x", "y" } };
|
||||||
|
IDictionary dictionary = map;
|
||||||
|
var array = new DictionaryEntry[3];
|
||||||
|
dictionary.CopyTo(array, 1);
|
||||||
|
CollectionAssert.AreEqual(new[] { default(DictionaryEntry), new DictionaryEntry("x", "y"), default(DictionaryEntry) },
|
||||||
|
array);
|
||||||
|
var objectArray = new object[3];
|
||||||
|
dictionary.CopyTo(objectArray, 1);
|
||||||
|
CollectionAssert.AreEqual(new object[] { null, new DictionaryEntry("x", "y"), null },
|
||||||
|
objectArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IDictionary_IsFixedSize()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string> { { "x", "y" } };
|
||||||
|
IDictionary dictionary = map;
|
||||||
|
Assert.IsFalse(dictionary.IsFixedSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IDictionary_Keys()
|
||||||
|
{
|
||||||
|
IDictionary dictionary = new MapField<string, string> { { "x", "y" } };
|
||||||
|
CollectionAssert.AreEqual(new[] { "x" }, dictionary.Keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IDictionary_Values()
|
||||||
|
{
|
||||||
|
IDictionary dictionary = new MapField<string, string> { { "x", "y" } };
|
||||||
|
CollectionAssert.AreEqual(new[] { "y" }, dictionary.Values);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IDictionary_IsSynchronized()
|
||||||
|
{
|
||||||
|
IDictionary dictionary = new MapField<string, string> { { "x", "y" } };
|
||||||
|
Assert.IsFalse(dictionary.IsSynchronized);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IDictionary_SyncRoot()
|
||||||
|
{
|
||||||
|
IDictionary dictionary = new MapField<string, string> { { "x", "y" } };
|
||||||
|
Assert.AreSame(dictionary, dictionary.SyncRoot);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IDictionary_Indexer_Get()
|
||||||
|
{
|
||||||
|
IDictionary dictionary = new MapField<string, string> { { "x", "y" } };
|
||||||
|
Assert.AreEqual("y", dictionary["x"]);
|
||||||
|
Assert.IsNull(dictionary["a"]);
|
||||||
|
Assert.IsNull(dictionary[5]);
|
||||||
|
Assert.Throws<ArgumentNullException>(() => dictionary[null].GetHashCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IDictionary_Indexer_Set()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string> { { "x", "y" } };
|
||||||
|
IDictionary dictionary = map;
|
||||||
|
map["a"] = "b";
|
||||||
|
Assert.AreEqual("b", map["a"]);
|
||||||
|
map["a"] = "c";
|
||||||
|
Assert.AreEqual("c", map["a"]);
|
||||||
|
Assert.Throws<InvalidCastException>(() => dictionary[5] = "x");
|
||||||
|
Assert.Throws<InvalidCastException>(() => dictionary["x"] = 5);
|
||||||
|
Assert.Throws<ArgumentNullException>(() => dictionary[null] = "z");
|
||||||
|
Assert.Throws<ArgumentNullException>(() => dictionary["x"] = null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void KeysReturnsLiveView()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string>();
|
||||||
|
var keys = map.Keys;
|
||||||
|
CollectionAssert.AreEqual(new string[0], keys);
|
||||||
|
map["foo"] = "bar";
|
||||||
|
map["x"] = "y";
|
||||||
|
CollectionAssert.AreEqual(new[] { "foo", "x" }, keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ValuesReturnsLiveView()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string>();
|
||||||
|
var values = map.Values;
|
||||||
|
CollectionAssert.AreEqual(new string[0], values);
|
||||||
|
map["foo"] = "bar";
|
||||||
|
map["x"] = "y";
|
||||||
|
CollectionAssert.AreEqual(new[] { "bar", "y" }, values);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Just test keys - we know the implementation is the same for values
|
||||||
|
[Test]
|
||||||
|
public void ViewsAreReadOnly()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string>();
|
||||||
|
var keys = map.Keys;
|
||||||
|
Assert.IsTrue(keys.IsReadOnly);
|
||||||
|
Assert.Throws<NotSupportedException>(() => keys.Clear());
|
||||||
|
Assert.Throws<NotSupportedException>(() => keys.Remove("a"));
|
||||||
|
Assert.Throws<NotSupportedException>(() => keys.Add("a"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Just test keys - we know the implementation is the same for values
|
||||||
|
[Test]
|
||||||
|
public void ViewCopyTo()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
|
||||||
|
var keys = map.Keys;
|
||||||
|
var array = new string[4];
|
||||||
|
Assert.Throws<ArgumentException>(() => keys.CopyTo(array, 3));
|
||||||
|
Assert.Throws<ArgumentOutOfRangeException>(() => keys.CopyTo(array, -1));
|
||||||
|
keys.CopyTo(array, 1);
|
||||||
|
CollectionAssert.AreEqual(new[] { null, "foo", "x", null }, array);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Just test keys - we know the implementation is the same for values
|
||||||
|
[Test]
|
||||||
|
public void NonGenericViewCopyTo()
|
||||||
|
{
|
||||||
|
IDictionary map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
|
||||||
|
ICollection keys = map.Keys;
|
||||||
|
// Note the use of the Array type here rather than string[]
|
||||||
|
Array array = new string[4];
|
||||||
|
Assert.Throws<ArgumentException>(() => keys.CopyTo(array, 3));
|
||||||
|
Assert.Throws<ArgumentOutOfRangeException>(() => keys.CopyTo(array, -1));
|
||||||
|
keys.CopyTo(array, 1);
|
||||||
|
CollectionAssert.AreEqual(new[] { null, "foo", "x", null }, array);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void KeysContains()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
|
||||||
|
var keys = map.Keys;
|
||||||
|
Assert.IsTrue(keys.Contains("foo"));
|
||||||
|
Assert.IsFalse(keys.Contains("bar")); // It's a value!
|
||||||
|
Assert.IsFalse(keys.Contains("1"));
|
||||||
|
// Keys can't be null, so we should prevent contains check
|
||||||
|
Assert.Throws<ArgumentNullException>(() => keys.Contains(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ValuesContains()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
|
||||||
|
var values = map.Values;
|
||||||
|
Assert.IsTrue(values.Contains("bar"));
|
||||||
|
Assert.IsFalse(values.Contains("foo")); // It's a key!
|
||||||
|
Assert.IsFalse(values.Contains("1"));
|
||||||
|
// Values can be null, so this makes sense
|
||||||
|
Assert.IsFalse(values.Contains(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ToString_StringToString()
|
||||||
|
{
|
||||||
|
var map = new MapField<string, string> { { "foo", "bar" }, { "x", "y" } };
|
||||||
|
Assert.AreEqual("{ \"foo\": \"bar\", \"x\": \"y\" }", map.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ToString_UnsupportedKeyType()
|
||||||
|
{
|
||||||
|
var map = new MapField<byte, string> { { 10, "foo" } };
|
||||||
|
Assert.Throws<ArgumentException>(() => map.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static KeyValuePair<TKey, TValue> NewKeyValuePair<TKey, TValue>(TKey key, TValue value)
|
||||||
|
{
|
||||||
|
return new KeyValuePair<TKey, TValue>(key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,746 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2015 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.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Google.Protobuf.TestProtos;
|
||||||
|
using Google.Protobuf.WellKnownTypes;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Google.Protobuf.Collections
|
||||||
|
{
|
||||||
|
public class RepeatedFieldTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void NullValuesRejected()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string>();
|
||||||
|
Assert.Throws<ArgumentNullException>(() => list.Add((string)null));
|
||||||
|
Assert.Throws<ArgumentNullException>(() => list.Add((IEnumerable<string>)null));
|
||||||
|
Assert.Throws<ArgumentNullException>(() => list.Add((RepeatedField<string>)null));
|
||||||
|
Assert.Throws<ArgumentNullException>(() => list.Contains(null));
|
||||||
|
Assert.Throws<ArgumentNullException>(() => list.IndexOf(null));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Add_SingleItem()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string>();
|
||||||
|
list.Add("foo");
|
||||||
|
Assert.AreEqual(1, list.Count);
|
||||||
|
Assert.AreEqual("foo", list[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Add_Sequence()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string>();
|
||||||
|
list.Add(new[] { "foo", "bar" });
|
||||||
|
Assert.AreEqual(2, list.Count);
|
||||||
|
Assert.AreEqual("foo", list[0]);
|
||||||
|
Assert.AreEqual("bar", list[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddRange_SlowPath()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string>();
|
||||||
|
list.AddRange(new[] { "foo", "bar" }.Select(x => x));
|
||||||
|
Assert.AreEqual(2, list.Count);
|
||||||
|
Assert.AreEqual("foo", list[0]);
|
||||||
|
Assert.AreEqual("bar", list[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddRange_SlowPath_NullsProhibited_ReferenceType()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string>();
|
||||||
|
// It's okay for this to throw ArgumentNullException if necessary.
|
||||||
|
// It's not ideal, but not awful.
|
||||||
|
Assert.Catch<ArgumentException>(() => list.AddRange(new[] { "foo", null }.Select(x => x)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddRange_SlowPath_NullsProhibited_NullableValueType()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<int?>();
|
||||||
|
// It's okay for this to throw ArgumentNullException if necessary.
|
||||||
|
// It's not ideal, but not awful.
|
||||||
|
Assert.Catch<ArgumentException>(() => list.AddRange(new[] { 20, (int?)null }.Select(x => x)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddRange_Optimized_NonNullableValueType()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<int>();
|
||||||
|
list.AddRange(new List<int> { 20, 30 });
|
||||||
|
Assert.AreEqual(2, list.Count);
|
||||||
|
Assert.AreEqual(20, list[0]);
|
||||||
|
Assert.AreEqual(30, list[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddRange_Optimized_ReferenceType()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string>();
|
||||||
|
list.AddRange(new List<string> { "foo", "bar" });
|
||||||
|
Assert.AreEqual(2, list.Count);
|
||||||
|
Assert.AreEqual("foo", list[0]);
|
||||||
|
Assert.AreEqual("bar", list[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddRange_Optimized_NullableValueType()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<int?>();
|
||||||
|
list.AddRange(new List<int?> { 20, 30 });
|
||||||
|
Assert.AreEqual(2, list.Count);
|
||||||
|
Assert.AreEqual((int?) 20, list[0]);
|
||||||
|
Assert.AreEqual((int?) 30, list[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddRange_Optimized_NullsProhibited_ReferenceType()
|
||||||
|
{
|
||||||
|
// We don't just trust that a collection with a nullable element type doesn't contain nulls
|
||||||
|
var list = new RepeatedField<string>();
|
||||||
|
// It's okay for this to throw ArgumentNullException if necessary.
|
||||||
|
// It's not ideal, but not awful.
|
||||||
|
Assert.Catch<ArgumentException>(() => list.AddRange(new List<string> { "foo", null }));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddRange_Optimized_NullsProhibited_NullableValueType()
|
||||||
|
{
|
||||||
|
// We don't just trust that a collection with a nullable element type doesn't contain nulls
|
||||||
|
var list = new RepeatedField<int?>();
|
||||||
|
// It's okay for this to throw ArgumentNullException if necessary.
|
||||||
|
// It's not ideal, but not awful.
|
||||||
|
Assert.Catch<ArgumentException>(() => list.AddRange(new List<int?> { 20, null }));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddRange_AlreadyNotEmpty()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<int> { 1, 2, 3 };
|
||||||
|
list.AddRange(new List<int> { 4, 5, 6 });
|
||||||
|
CollectionAssert.AreEqual(new[] { 1, 2, 3, 4, 5, 6 }, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddRange_RepeatedField()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string> { "original" };
|
||||||
|
list.AddRange(new RepeatedField<string> { "foo", "bar" });
|
||||||
|
Assert.AreEqual(3, list.Count);
|
||||||
|
Assert.AreEqual("original", list[0]);
|
||||||
|
Assert.AreEqual("foo", list[1]);
|
||||||
|
Assert.AreEqual("bar", list[2]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void RemoveAt_Valid()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string> { "first", "second", "third" };
|
||||||
|
list.RemoveAt(1);
|
||||||
|
CollectionAssert.AreEqual(new[] { "first", "third" }, list);
|
||||||
|
// Just check that these don't throw...
|
||||||
|
list.RemoveAt(list.Count - 1); // Now the count will be 1...
|
||||||
|
list.RemoveAt(0);
|
||||||
|
Assert.AreEqual(0, list.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void RemoveAt_Invalid()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string> { "first", "second", "third" };
|
||||||
|
Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(-1));
|
||||||
|
Assert.Throws<ArgumentOutOfRangeException>(() => list.RemoveAt(3));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Insert_Valid()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string> { "first", "second" };
|
||||||
|
list.Insert(1, "middle");
|
||||||
|
CollectionAssert.AreEqual(new[] { "first", "middle", "second" }, list);
|
||||||
|
list.Insert(3, "end");
|
||||||
|
CollectionAssert.AreEqual(new[] { "first", "middle", "second", "end" }, list);
|
||||||
|
list.Insert(0, "start");
|
||||||
|
CollectionAssert.AreEqual(new[] { "start", "first", "middle", "second", "end" }, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Insert_Invalid()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string> { "first", "second" };
|
||||||
|
Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(-1, "foo"));
|
||||||
|
Assert.Throws<ArgumentOutOfRangeException>(() => list.Insert(3, "foo"));
|
||||||
|
Assert.Throws<ArgumentNullException>(() => list.Insert(0, null));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Equals_RepeatedField()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string> { "first", "second" };
|
||||||
|
Assert.IsFalse(list.Equals((RepeatedField<string>) null));
|
||||||
|
Assert.IsTrue(list.Equals(list));
|
||||||
|
Assert.IsFalse(list.Equals(new RepeatedField<string> { "first", "third" }));
|
||||||
|
Assert.IsFalse(list.Equals(new RepeatedField<string> { "first" }));
|
||||||
|
Assert.IsTrue(list.Equals(new RepeatedField<string> { "first", "second" }));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Equals_Object()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string> { "first", "second" };
|
||||||
|
Assert.IsFalse(list.Equals((object) null));
|
||||||
|
Assert.IsTrue(list.Equals((object) list));
|
||||||
|
Assert.IsFalse(list.Equals((object) new RepeatedField<string> { "first", "third" }));
|
||||||
|
Assert.IsFalse(list.Equals((object) new RepeatedField<string> { "first" }));
|
||||||
|
Assert.IsTrue(list.Equals((object) new RepeatedField<string> { "first", "second" }));
|
||||||
|
Assert.IsFalse(list.Equals(new object()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetEnumerator_GenericInterface()
|
||||||
|
{
|
||||||
|
IEnumerable<string> list = new RepeatedField<string> { "first", "second" };
|
||||||
|
// Select gets rid of the optimizations in ToList...
|
||||||
|
CollectionAssert.AreEqual(new[] { "first", "second" }, list.Select(x => x).ToList());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetEnumerator_NonGenericInterface()
|
||||||
|
{
|
||||||
|
IEnumerable list = new RepeatedField<string> { "first", "second" };
|
||||||
|
CollectionAssert.AreEqual(new[] { "first", "second" }, list.Cast<object>().ToList());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CopyTo()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string> { "first", "second" };
|
||||||
|
string[] stringArray = new string[4];
|
||||||
|
list.CopyTo(stringArray, 1);
|
||||||
|
CollectionAssert.AreEqual(new[] { null, "first", "second", null }, stringArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Indexer_Get()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string> { "first", "second" };
|
||||||
|
Assert.AreEqual("first", list[0]);
|
||||||
|
Assert.AreEqual("second", list[1]);
|
||||||
|
Assert.Throws<ArgumentOutOfRangeException>(() => list[-1].GetHashCode());
|
||||||
|
Assert.Throws<ArgumentOutOfRangeException>(() => list[2].GetHashCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Indexer_Set()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string> { "first", "second" };
|
||||||
|
list[0] = "changed";
|
||||||
|
Assert.AreEqual("changed", list[0]);
|
||||||
|
Assert.Throws<ArgumentNullException>(() => list[0] = null);
|
||||||
|
Assert.Throws<ArgumentOutOfRangeException>(() => list[-1] = "bad");
|
||||||
|
Assert.Throws<ArgumentOutOfRangeException>(() => list[2] = "bad");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Clone_ReturnsMutable()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<int> { 0 };
|
||||||
|
var clone = list.Clone();
|
||||||
|
clone[0] = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Enumerator()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string> { "first", "second" };
|
||||||
|
using (var enumerator = list.GetEnumerator())
|
||||||
|
{
|
||||||
|
Assert.IsTrue(enumerator.MoveNext());
|
||||||
|
Assert.AreEqual("first", enumerator.Current);
|
||||||
|
Assert.IsTrue(enumerator.MoveNext());
|
||||||
|
Assert.AreEqual("second", enumerator.Current);
|
||||||
|
Assert.IsFalse(enumerator.MoveNext());
|
||||||
|
Assert.IsFalse(enumerator.MoveNext());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddEntriesFrom_PackedInt32()
|
||||||
|
{
|
||||||
|
uint packedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(stream);
|
||||||
|
var length = CodedOutputStream.ComputeInt32Size(10)
|
||||||
|
+ CodedOutputStream.ComputeInt32Size(999)
|
||||||
|
+ CodedOutputStream.ComputeInt32Size(-1000);
|
||||||
|
output.WriteTag(packedTag);
|
||||||
|
output.WriteRawVarint32((uint) length);
|
||||||
|
output.WriteInt32(10);
|
||||||
|
output.WriteInt32(999);
|
||||||
|
output.WriteInt32(-1000);
|
||||||
|
output.Flush();
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
// Deliberately "expecting" a non-packed tag, but we detect that the data is
|
||||||
|
// actually packed.
|
||||||
|
uint nonPackedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
|
||||||
|
var field = new RepeatedField<int>();
|
||||||
|
var input = new CodedInputStream(stream);
|
||||||
|
input.AssertNextTag(packedTag);
|
||||||
|
field.AddEntriesFrom(input, FieldCodec.ForInt32(nonPackedTag));
|
||||||
|
CollectionAssert.AreEqual(new[] { 10, 999, -1000 }, field);
|
||||||
|
Assert.IsTrue(input.IsAtEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddEntriesFrom_NonPackedInt32()
|
||||||
|
{
|
||||||
|
uint nonPackedTag = WireFormat.MakeTag(10, WireFormat.WireType.Varint);
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(stream);
|
||||||
|
output.WriteTag(nonPackedTag);
|
||||||
|
output.WriteInt32(10);
|
||||||
|
output.WriteTag(nonPackedTag);
|
||||||
|
output.WriteInt32(999);
|
||||||
|
output.WriteTag(nonPackedTag);
|
||||||
|
output.WriteInt32(-1000); // Just for variety...
|
||||||
|
output.Flush();
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
// Deliberately "expecting" a packed tag, but we detect that the data is
|
||||||
|
// actually not packed.
|
||||||
|
uint packedTag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
|
||||||
|
var field = new RepeatedField<int>();
|
||||||
|
var input = new CodedInputStream(stream);
|
||||||
|
input.AssertNextTag(nonPackedTag);
|
||||||
|
field.AddEntriesFrom(input, FieldCodec.ForInt32(packedTag));
|
||||||
|
CollectionAssert.AreEqual(new[] { 10, 999, -1000 }, field);
|
||||||
|
Assert.IsTrue(input.IsAtEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddEntriesFrom_String()
|
||||||
|
{
|
||||||
|
uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(stream);
|
||||||
|
output.WriteTag(tag);
|
||||||
|
output.WriteString("Foo");
|
||||||
|
output.WriteTag(tag);
|
||||||
|
output.WriteString("");
|
||||||
|
output.WriteTag(tag);
|
||||||
|
output.WriteString("Bar");
|
||||||
|
output.Flush();
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
var field = new RepeatedField<string>();
|
||||||
|
var input = new CodedInputStream(stream);
|
||||||
|
input.AssertNextTag(tag);
|
||||||
|
field.AddEntriesFrom(input, FieldCodec.ForString(tag));
|
||||||
|
CollectionAssert.AreEqual(new[] { "Foo", "", "Bar" }, field);
|
||||||
|
Assert.IsTrue(input.IsAtEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void AddEntriesFrom_Message()
|
||||||
|
{
|
||||||
|
var message1 = new ForeignMessage { C = 2000 };
|
||||||
|
var message2 = new ForeignMessage { C = -250 };
|
||||||
|
|
||||||
|
uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(stream);
|
||||||
|
output.WriteTag(tag);
|
||||||
|
output.WriteMessage(message1);
|
||||||
|
output.WriteTag(tag);
|
||||||
|
output.WriteMessage(message2);
|
||||||
|
output.Flush();
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
var field = new RepeatedField<ForeignMessage>();
|
||||||
|
var input = new CodedInputStream(stream);
|
||||||
|
input.AssertNextTag(tag);
|
||||||
|
field.AddEntriesFrom(input, FieldCodec.ForMessage(tag, ForeignMessage.Parser));
|
||||||
|
CollectionAssert.AreEqual(new[] { message1, message2}, field);
|
||||||
|
Assert.IsTrue(input.IsAtEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void WriteTo_PackedInt32()
|
||||||
|
{
|
||||||
|
uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
|
||||||
|
var field = new RepeatedField<int> { 10, 1000, 1000000 };
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(stream);
|
||||||
|
field.WriteTo(output, FieldCodec.ForInt32(tag));
|
||||||
|
output.Flush();
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
var input = new CodedInputStream(stream);
|
||||||
|
input.AssertNextTag(tag);
|
||||||
|
var length = input.ReadLength();
|
||||||
|
Assert.AreEqual(10, input.ReadInt32());
|
||||||
|
Assert.AreEqual(1000, input.ReadInt32());
|
||||||
|
Assert.AreEqual(1000000, input.ReadInt32());
|
||||||
|
Assert.IsTrue(input.IsAtEnd);
|
||||||
|
Assert.AreEqual(1 + CodedOutputStream.ComputeLengthSize(length) + length, stream.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void WriteTo_NonPackedInt32()
|
||||||
|
{
|
||||||
|
uint tag = WireFormat.MakeTag(10, WireFormat.WireType.Varint);
|
||||||
|
var field = new RepeatedField<int> { 10, 1000, 1000000};
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(stream);
|
||||||
|
field.WriteTo(output, FieldCodec.ForInt32(tag));
|
||||||
|
output.Flush();
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
var input = new CodedInputStream(stream);
|
||||||
|
input.AssertNextTag(tag);
|
||||||
|
Assert.AreEqual(10, input.ReadInt32());
|
||||||
|
input.AssertNextTag(tag);
|
||||||
|
Assert.AreEqual(1000, input.ReadInt32());
|
||||||
|
input.AssertNextTag(tag);
|
||||||
|
Assert.AreEqual(1000000, input.ReadInt32());
|
||||||
|
Assert.IsTrue(input.IsAtEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void WriteTo_String()
|
||||||
|
{
|
||||||
|
uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
|
||||||
|
var field = new RepeatedField<string> { "Foo", "", "Bar" };
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(stream);
|
||||||
|
field.WriteTo(output, FieldCodec.ForString(tag));
|
||||||
|
output.Flush();
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
var input = new CodedInputStream(stream);
|
||||||
|
input.AssertNextTag(tag);
|
||||||
|
Assert.AreEqual("Foo", input.ReadString());
|
||||||
|
input.AssertNextTag(tag);
|
||||||
|
Assert.AreEqual("", input.ReadString());
|
||||||
|
input.AssertNextTag(tag);
|
||||||
|
Assert.AreEqual("Bar", input.ReadString());
|
||||||
|
Assert.IsTrue(input.IsAtEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void WriteTo_Message()
|
||||||
|
{
|
||||||
|
var message1 = new ForeignMessage { C = 20 };
|
||||||
|
var message2 = new ForeignMessage { C = 25 };
|
||||||
|
uint tag = WireFormat.MakeTag(10, WireFormat.WireType.LengthDelimited);
|
||||||
|
var field = new RepeatedField<ForeignMessage> { message1, message2 };
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(stream);
|
||||||
|
field.WriteTo(output, FieldCodec.ForMessage(tag, ForeignMessage.Parser));
|
||||||
|
output.Flush();
|
||||||
|
stream.Position = 0;
|
||||||
|
|
||||||
|
var input = new CodedInputStream(stream);
|
||||||
|
input.AssertNextTag(tag);
|
||||||
|
Assert.AreEqual(message1, input.ReadMessage(ForeignMessage.Parser));
|
||||||
|
input.AssertNextTag(tag);
|
||||||
|
Assert.AreEqual(message2, input.ReadMessage(ForeignMessage.Parser));
|
||||||
|
Assert.IsTrue(input.IsAtEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CalculateSize_VariableSizeNonPacked()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<int> { 1, 500, 1 };
|
||||||
|
var tag = WireFormat.MakeTag(1, WireFormat.WireType.Varint);
|
||||||
|
// 2 bytes for the first entry, 3 bytes for the second, 2 bytes for the third
|
||||||
|
Assert.AreEqual(7, list.CalculateSize(FieldCodec.ForInt32(tag)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CalculateSize_FixedSizeNonPacked()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<int> { 1, 500, 1 };
|
||||||
|
var tag = WireFormat.MakeTag(1, WireFormat.WireType.Fixed32);
|
||||||
|
// 5 bytes for the each entry
|
||||||
|
Assert.AreEqual(15, list.CalculateSize(FieldCodec.ForSFixed32(tag)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CalculateSize_VariableSizePacked()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<int> { 1, 500, 1};
|
||||||
|
var tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited);
|
||||||
|
// 1 byte for the tag, 1 byte for the length,
|
||||||
|
// 1 byte for the first entry, 2 bytes for the second, 1 byte for the third
|
||||||
|
Assert.AreEqual(6, list.CalculateSize(FieldCodec.ForInt32(tag)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CalculateSize_FixedSizePacked()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<int> { 1, 500, 1 };
|
||||||
|
var tag = WireFormat.MakeTag(1, WireFormat.WireType.LengthDelimited);
|
||||||
|
// 1 byte for the tag, 1 byte for the length, 4 bytes per entry
|
||||||
|
Assert.AreEqual(14, list.CalculateSize(FieldCodec.ForSFixed32(tag)));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestNegativeEnumArray()
|
||||||
|
{
|
||||||
|
int arraySize = 1 + 1 + (11 * 5);
|
||||||
|
int msgSize = arraySize;
|
||||||
|
byte[] bytes = new byte[msgSize];
|
||||||
|
CodedOutputStream output = new CodedOutputStream(bytes);
|
||||||
|
uint tag = WireFormat.MakeTag(8, WireFormat.WireType.Varint);
|
||||||
|
for (int i = 0; i >= -5; i--)
|
||||||
|
{
|
||||||
|
output.WriteTag(tag);
|
||||||
|
output.WriteEnum(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.AreEqual(0, output.SpaceLeft);
|
||||||
|
|
||||||
|
CodedInputStream input = new CodedInputStream(bytes);
|
||||||
|
tag = input.ReadTag();
|
||||||
|
|
||||||
|
RepeatedField<SampleEnum> values = new RepeatedField<SampleEnum>();
|
||||||
|
values.AddEntriesFrom(input, FieldCodec.ForEnum(tag, x => (int)x, x => (SampleEnum)x));
|
||||||
|
|
||||||
|
Assert.AreEqual(6, values.Count);
|
||||||
|
Assert.AreEqual(SampleEnum.None, values[0]);
|
||||||
|
Assert.AreEqual(((SampleEnum)(-1)), values[1]);
|
||||||
|
Assert.AreEqual(SampleEnum.NegativeValue, values[2]);
|
||||||
|
Assert.AreEqual(((SampleEnum)(-3)), values[3]);
|
||||||
|
Assert.AreEqual(((SampleEnum)(-4)), values[4]);
|
||||||
|
Assert.AreEqual(((SampleEnum)(-5)), values[5]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestNegativeEnumPackedArray()
|
||||||
|
{
|
||||||
|
int arraySize = 1 + (10 * 5);
|
||||||
|
int msgSize = 1 + 1 + arraySize;
|
||||||
|
byte[] bytes = new byte[msgSize];
|
||||||
|
CodedOutputStream output = new CodedOutputStream(bytes);
|
||||||
|
// Length-delimited to show we want the packed representation
|
||||||
|
uint tag = WireFormat.MakeTag(8, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteTag(tag);
|
||||||
|
int size = 0;
|
||||||
|
for (int i = 0; i >= -5; i--)
|
||||||
|
{
|
||||||
|
size += CodedOutputStream.ComputeEnumSize(i);
|
||||||
|
}
|
||||||
|
output.WriteRawVarint32((uint)size);
|
||||||
|
for (int i = 0; i >= -5; i--)
|
||||||
|
{
|
||||||
|
output.WriteEnum(i);
|
||||||
|
}
|
||||||
|
Assert.AreEqual(0, output.SpaceLeft);
|
||||||
|
|
||||||
|
CodedInputStream input = new CodedInputStream(bytes);
|
||||||
|
tag = input.ReadTag();
|
||||||
|
|
||||||
|
RepeatedField<SampleEnum> values = new RepeatedField<SampleEnum>();
|
||||||
|
values.AddEntriesFrom(input, FieldCodec.ForEnum(tag, x => (int)x, x => (SampleEnum)x));
|
||||||
|
|
||||||
|
Assert.AreEqual(6, values.Count);
|
||||||
|
Assert.AreEqual(SampleEnum.None, values[0]);
|
||||||
|
Assert.AreEqual(((SampleEnum)(-1)), values[1]);
|
||||||
|
Assert.AreEqual(SampleEnum.NegativeValue, values[2]);
|
||||||
|
Assert.AreEqual(((SampleEnum)(-3)), values[3]);
|
||||||
|
Assert.AreEqual(((SampleEnum)(-4)), values[4]);
|
||||||
|
Assert.AreEqual(((SampleEnum)(-5)), values[5]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fairly perfunctory tests for the non-generic IList implementation
|
||||||
|
[Test]
|
||||||
|
public void IList_Indexer()
|
||||||
|
{
|
||||||
|
var field = new RepeatedField<string> { "first", "second" };
|
||||||
|
IList list = field;
|
||||||
|
Assert.AreEqual("first", list[0]);
|
||||||
|
list[1] = "changed";
|
||||||
|
Assert.AreEqual("changed", field[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IList_Contains()
|
||||||
|
{
|
||||||
|
IList list = new RepeatedField<string> { "first", "second" };
|
||||||
|
Assert.IsTrue(list.Contains("second"));
|
||||||
|
Assert.IsFalse(list.Contains("third"));
|
||||||
|
Assert.IsFalse(list.Contains(new object()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IList_Add()
|
||||||
|
{
|
||||||
|
IList list = new RepeatedField<string> { "first", "second" };
|
||||||
|
list.Add("third");
|
||||||
|
CollectionAssert.AreEqual(new[] { "first", "second", "third" }, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IList_Remove()
|
||||||
|
{
|
||||||
|
IList list = new RepeatedField<string> { "first", "second" };
|
||||||
|
list.Remove("third"); // No-op, no exception
|
||||||
|
list.Remove(new object()); // No-op, no exception
|
||||||
|
list.Remove("first");
|
||||||
|
CollectionAssert.AreEqual(new[] { "second" }, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IList_IsFixedSize()
|
||||||
|
{
|
||||||
|
var field = new RepeatedField<string> { "first", "second" };
|
||||||
|
IList list = field;
|
||||||
|
Assert.IsFalse(list.IsFixedSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IList_IndexOf()
|
||||||
|
{
|
||||||
|
IList list = new RepeatedField<string> { "first", "second" };
|
||||||
|
Assert.AreEqual(1, list.IndexOf("second"));
|
||||||
|
Assert.AreEqual(-1, list.IndexOf("third"));
|
||||||
|
Assert.AreEqual(-1, list.IndexOf(new object()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IList_SyncRoot()
|
||||||
|
{
|
||||||
|
IList list = new RepeatedField<string> { "first", "second" };
|
||||||
|
Assert.AreSame(list, list.SyncRoot);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IList_CopyTo()
|
||||||
|
{
|
||||||
|
IList list = new RepeatedField<string> { "first", "second" };
|
||||||
|
string[] stringArray = new string[4];
|
||||||
|
list.CopyTo(stringArray, 1);
|
||||||
|
CollectionAssert.AreEqual(new[] { null, "first", "second", null }, stringArray);
|
||||||
|
|
||||||
|
object[] objectArray = new object[4];
|
||||||
|
list.CopyTo(objectArray, 1);
|
||||||
|
CollectionAssert.AreEqual(new[] { null, "first", "second", null }, objectArray);
|
||||||
|
|
||||||
|
Assert.Throws<ArrayTypeMismatchException>(() => list.CopyTo(new StringBuilder[4], 1));
|
||||||
|
Assert.Throws<ArrayTypeMismatchException>(() => list.CopyTo(new int[4], 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IList_IsSynchronized()
|
||||||
|
{
|
||||||
|
IList list = new RepeatedField<string> { "first", "second" };
|
||||||
|
Assert.IsFalse(list.IsSynchronized);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IList_Insert()
|
||||||
|
{
|
||||||
|
IList list = new RepeatedField<string> { "first", "second" };
|
||||||
|
list.Insert(1, "middle");
|
||||||
|
CollectionAssert.AreEqual(new[] { "first", "middle", "second" }, list);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ToString_Integers()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<int> { 5, 10, 20 };
|
||||||
|
var text = list.ToString();
|
||||||
|
Assert.AreEqual("[ 5, 10, 20 ]", text);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ToString_Strings()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<string> { "x", "y", "z" };
|
||||||
|
var text = list.ToString();
|
||||||
|
Assert.AreEqual("[ \"x\", \"y\", \"z\" ]", text);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ToString_Messages()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<TestAllTypes> { new TestAllTypes { SingleDouble = 1.5 }, new TestAllTypes { SingleInt32 = 10 } };
|
||||||
|
var text = list.ToString();
|
||||||
|
Assert.AreEqual("[ { \"singleDouble\": 1.5 }, { \"singleInt32\": 10 } ]", text);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ToString_Empty()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<TestAllTypes> { };
|
||||||
|
var text = list.ToString();
|
||||||
|
Assert.AreEqual("[ ]", text);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ToString_InvalidElementType()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<decimal> { 15m };
|
||||||
|
Assert.Throws<ArgumentException>(() => list.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ToString_Timestamp()
|
||||||
|
{
|
||||||
|
var list = new RepeatedField<Timestamp> { Timestamp.FromDateTime(new DateTime(2015, 10, 1, 12, 34, 56, DateTimeKind.Utc)) };
|
||||||
|
var text = list.ToString();
|
||||||
|
Assert.AreEqual("[ \"2015-10-01T12:34:56Z\" ]", text);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ToString_Struct()
|
||||||
|
{
|
||||||
|
var message = new Struct { Fields = { { "foo", new Value { NumberValue = 20 } } } };
|
||||||
|
var list = new RepeatedField<Struct> { message };
|
||||||
|
var text = list.ToString();
|
||||||
|
Assert.AreEqual(text, "[ { \"foo\": 20 } ]", message.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,98 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2015 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.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using NUnit.Framework;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace Google.Protobuf.Compatibility
|
||||||
|
{
|
||||||
|
public class PropertyInfoExtensionsTest
|
||||||
|
{
|
||||||
|
public string PublicReadWrite { get; set; }
|
||||||
|
private string PrivateReadWrite { get; set; }
|
||||||
|
public string PublicReadPrivateWrite { get; private set; }
|
||||||
|
public string PrivateReadPublicWrite { private get; set; }
|
||||||
|
public string PublicReadOnly { get { return null; } }
|
||||||
|
private string PrivateReadOnly { get { return null; } }
|
||||||
|
public string PublicWriteOnly { set { } }
|
||||||
|
private string PrivateWriteOnly { set { } }
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("PublicReadWrite")]
|
||||||
|
[TestCase("PublicReadPrivateWrite")]
|
||||||
|
[TestCase("PublicReadOnly")]
|
||||||
|
public void GetGetMethod_Success(string name)
|
||||||
|
{
|
||||||
|
var propertyInfo = typeof(PropertyInfoExtensionsTest)
|
||||||
|
.GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||||
|
Assert.IsNotNull(PropertyInfoExtensions.GetGetMethod(propertyInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("PrivateReadWrite")]
|
||||||
|
[TestCase("PrivateReadPublicWrite")]
|
||||||
|
[TestCase("PrivateReadOnly")]
|
||||||
|
[TestCase("PublicWriteOnly")]
|
||||||
|
[TestCase("PrivateWriteOnly")]
|
||||||
|
public void GetGetMethod_NoAccessibleGetter(string name)
|
||||||
|
{
|
||||||
|
var propertyInfo = typeof(PropertyInfoExtensionsTest)
|
||||||
|
.GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||||
|
Assert.IsNull(PropertyInfoExtensions.GetGetMethod(propertyInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("PublicReadWrite")]
|
||||||
|
[TestCase("PrivateReadPublicWrite")]
|
||||||
|
[TestCase("PublicWriteOnly")]
|
||||||
|
public void GetSetMethod_Success(string name)
|
||||||
|
{
|
||||||
|
var propertyInfo = typeof(PropertyInfoExtensionsTest)
|
||||||
|
.GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||||
|
Assert.IsNotNull(PropertyInfoExtensions.GetSetMethod(propertyInfo));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("PublicReadPrivateWrite")]
|
||||||
|
[TestCase("PrivateReadWrite")]
|
||||||
|
[TestCase("PrivateReadOnly")]
|
||||||
|
[TestCase("PublicReadOnly")]
|
||||||
|
[TestCase("PrivateWriteOnly")]
|
||||||
|
public void GetSetMethod_NoAccessibleGetter(string name)
|
||||||
|
{
|
||||||
|
var propertyInfo = typeof(PropertyInfoExtensionsTest)
|
||||||
|
.GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);
|
||||||
|
Assert.IsNull(PropertyInfoExtensions.GetSetMethod(propertyInfo));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,117 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2015 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.
|
||||||
|
#endregion
|
||||||
|
using NUnit.Framework;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
#if !DOTNET35
|
||||||
|
namespace Google.Protobuf.Compatibility
|
||||||
|
{
|
||||||
|
public class TypeExtensionsTest
|
||||||
|
{
|
||||||
|
public class DerivedList : List<string> { }
|
||||||
|
public string PublicProperty { get; set; }
|
||||||
|
private string PrivateProperty { get; set; }
|
||||||
|
|
||||||
|
public void PublicMethod()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
private void PrivateMethod()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase(typeof(object), typeof(string), true)]
|
||||||
|
[TestCase(typeof(object), typeof(int), true)]
|
||||||
|
[TestCase(typeof(string), typeof(string), true)]
|
||||||
|
[TestCase(typeof(string), typeof(object), false)]
|
||||||
|
[TestCase(typeof(string), typeof(int), false)]
|
||||||
|
[TestCase(typeof(int), typeof(int), true)]
|
||||||
|
[TestCase(typeof(ValueType), typeof(int), true)]
|
||||||
|
[TestCase(typeof(long), typeof(int), false)] //
|
||||||
|
public void IsAssignableFrom(Type target, Type argument, bool expected)
|
||||||
|
{
|
||||||
|
Assert.AreEqual(expected, TypeExtensions.IsAssignableFrom(target, argument));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase(typeof(DerivedList), "Count")] // Go up the type hierarchy
|
||||||
|
[TestCase(typeof(List<string>), "Count")]
|
||||||
|
[TestCase(typeof(List<>), "Count")]
|
||||||
|
[TestCase(typeof(TypeExtensionsTest), "PublicProperty")]
|
||||||
|
public void GetProperty_Success(Type type, string name)
|
||||||
|
{
|
||||||
|
var property = TypeExtensions.GetProperty(type, name);
|
||||||
|
Assert.IsNotNull(property);
|
||||||
|
Assert.AreEqual(name, property.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase(typeof(TypeExtensionsTest), "PrivateProperty")]
|
||||||
|
[TestCase(typeof(TypeExtensionsTest), "Garbage")]
|
||||||
|
public void GetProperty_NoSuchProperty(Type type, string name)
|
||||||
|
{
|
||||||
|
var property = TypeExtensions.GetProperty(type, name);
|
||||||
|
Assert.IsNull(property);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase(typeof(DerivedList), "RemoveAt")] // Go up the type hierarchy
|
||||||
|
[TestCase(typeof(List<>), "RemoveAt")]
|
||||||
|
[TestCase(typeof(TypeExtensionsTest), "PublicMethod")]
|
||||||
|
public void GetMethod_Success(Type type, string name)
|
||||||
|
{
|
||||||
|
var method = TypeExtensions.GetMethod(type, name);
|
||||||
|
Assert.IsNotNull(method);
|
||||||
|
Assert.AreEqual(name, method.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase(typeof(TypeExtensionsTest), "PrivateMethod")]
|
||||||
|
[TestCase(typeof(TypeExtensionsTest), "GarbageMethod")]
|
||||||
|
public void GetMethod_NoSuchMethod(Type type, string name)
|
||||||
|
{
|
||||||
|
var method = TypeExtensions.GetMethod(type, name);
|
||||||
|
Assert.IsNull(method);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase(typeof(List<string>), "IndexOf")]
|
||||||
|
public void GetMethod_Ambiguous(Type type, string name)
|
||||||
|
{
|
||||||
|
Assert.Throws<AmbiguousMatchException>(() => TypeExtensions.GetMethod(type, name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
|
@ -1,48 +1,55 @@
|
||||||
#region Copyright notice and license
|
#region Copyright notice and license
|
||||||
// Protocol Buffers - Google's data interchange format
|
// Protocol Buffers - Google's data interchange format
|
||||||
// Copyright 2015 Google Inc. All rights reserved.
|
// Copyright 2015 Google Inc. All rights reserved.
|
||||||
// https://developers.google.com/protocol-buffers/
|
// https://developers.google.com/protocol-buffers/
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions are
|
// modification, are permitted provided that the following conditions are
|
||||||
// met:
|
// met:
|
||||||
//
|
//
|
||||||
// * Redistributions of source code must retain the above copyright
|
// * Redistributions of source code must retain the above copyright
|
||||||
// notice, this list of conditions and the following disclaimer.
|
// notice, this list of conditions and the following disclaimer.
|
||||||
// * Redistributions in binary form must reproduce the above
|
// * Redistributions in binary form must reproduce the above
|
||||||
// copyright notice, this list of conditions and the following disclaimer
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
// in the documentation and/or other materials provided with the
|
// in the documentation and/or other materials provided with the
|
||||||
// distribution.
|
// distribution.
|
||||||
// * Neither the name of Google Inc. nor the names of its
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
// contributors may be used to endorse or promote products derived from
|
// contributors may be used to endorse or promote products derived from
|
||||||
// this software without specific prior written permission.
|
// this software without specific prior written permission.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
// (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.
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Reflection;
|
using System;
|
||||||
|
using System.Reflection;
|
||||||
// General Information about an assembly is controlled through the following
|
using Google.Protobuf.TestProtos;
|
||||||
// set of attributes. Change these attribute values to modify the information
|
using NUnit.Framework;
|
||||||
// associated with an assembly.
|
|
||||||
[assembly: AssemblyTitle("Google.Protobuf.Conformance")]
|
namespace Google.Protobuf
|
||||||
[assembly: AssemblyDescription("")]
|
{
|
||||||
[assembly: AssemblyConfiguration("")]
|
public class DeprecatedMemberTest
|
||||||
[assembly: AssemblyCompany("")]
|
{
|
||||||
[assembly: AssemblyProduct("Google.Protobuf.Conformance")]
|
private static void AssertIsDeprecated(MemberInfo member)
|
||||||
[assembly: AssemblyCopyright("Copyright © 2015")]
|
{
|
||||||
[assembly: AssemblyTrademark("")]
|
Assert.NotNull(member);
|
||||||
[assembly: AssemblyCulture("")]
|
Assert.IsTrue(member.IsDefined(typeof(ObsoleteAttribute), false), "Member not obsolete: " + member);
|
||||||
|
}
|
||||||
[assembly: AssemblyVersion("3.0.0.0")]
|
|
||||||
[assembly: AssemblyFileVersion("3.0.0.0")]
|
[Test]
|
||||||
|
public void TestDepreatedPrimitiveValue()
|
||||||
|
{
|
||||||
|
AssertIsDeprecated(typeof(TestDeprecatedFields).GetProperty("DeprecatedInt32"));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,64 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2015 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.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Google.Protobuf
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Helper methods when testing equality. NUnit's Assert.AreEqual and
|
||||||
|
/// Assert.AreNotEqual methods try to be clever with collections, which can
|
||||||
|
/// be annoying...
|
||||||
|
/// </summary>
|
||||||
|
internal static class EqualityTester
|
||||||
|
{
|
||||||
|
public static void AssertEquality<T>(T first, T second) where T : IEquatable<T>
|
||||||
|
{
|
||||||
|
Assert.IsTrue(first.Equals(second));
|
||||||
|
Assert.IsTrue(first.Equals((object) second));
|
||||||
|
Assert.AreEqual(first.GetHashCode(), second.GetHashCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void AssertInequality<T>(T first, T second) where T : IEquatable<T>
|
||||||
|
{
|
||||||
|
Assert.IsFalse(first.Equals(second));
|
||||||
|
Assert.IsFalse(first.Equals((object) second));
|
||||||
|
// While this isn't a requirement, the chances of this test failing due to
|
||||||
|
// coincidence rather than a bug are very small.
|
||||||
|
if (first != null && second != null)
|
||||||
|
{
|
||||||
|
Assert.AreNotEqual(first.GetHashCode(), second.GetHashCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,196 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2015 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.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using Google.Protobuf.TestProtos;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Google.Protobuf
|
||||||
|
{
|
||||||
|
public class FieldCodecTest
|
||||||
|
{
|
||||||
|
#pragma warning disable 0414 // Used by tests via reflection - do not remove!
|
||||||
|
private static readonly List<ICodecTestData> Codecs = new List<ICodecTestData>
|
||||||
|
{
|
||||||
|
new FieldCodecTestData<bool>(FieldCodec.ForBool(100), true, "Bool"),
|
||||||
|
new FieldCodecTestData<string>(FieldCodec.ForString(100), "sample", "String"),
|
||||||
|
new FieldCodecTestData<ByteString>(FieldCodec.ForBytes(100), ByteString.CopyFrom(1, 2, 3), "Bytes"),
|
||||||
|
new FieldCodecTestData<int>(FieldCodec.ForInt32(100), -1000, "Int32"),
|
||||||
|
new FieldCodecTestData<int>(FieldCodec.ForSInt32(100), -1000, "SInt32"),
|
||||||
|
new FieldCodecTestData<int>(FieldCodec.ForSFixed32(100), -1000, "SFixed32"),
|
||||||
|
new FieldCodecTestData<uint>(FieldCodec.ForUInt32(100), 1234, "UInt32"),
|
||||||
|
new FieldCodecTestData<uint>(FieldCodec.ForFixed32(100), 1234, "Fixed32"),
|
||||||
|
new FieldCodecTestData<long>(FieldCodec.ForInt64(100), -1000, "Int64"),
|
||||||
|
new FieldCodecTestData<long>(FieldCodec.ForSInt64(100), -1000, "SInt64"),
|
||||||
|
new FieldCodecTestData<long>(FieldCodec.ForSFixed64(100), -1000, "SFixed64"),
|
||||||
|
new FieldCodecTestData<ulong>(FieldCodec.ForUInt64(100), 1234, "UInt64"),
|
||||||
|
new FieldCodecTestData<ulong>(FieldCodec.ForFixed64(100), 1234, "Fixed64"),
|
||||||
|
new FieldCodecTestData<float>(FieldCodec.ForFloat(100), 1234.5f, "Float"),
|
||||||
|
new FieldCodecTestData<double>(FieldCodec.ForDouble(100), 1234567890.5d, "Double"),
|
||||||
|
new FieldCodecTestData<ForeignEnum>(
|
||||||
|
FieldCodec.ForEnum(100, t => (int) t, t => (ForeignEnum) t), ForeignEnum.ForeignBaz, "Enum"),
|
||||||
|
new FieldCodecTestData<ForeignMessage>(
|
||||||
|
FieldCodec.ForMessage(100, ForeignMessage.Parser), new ForeignMessage { C = 10 }, "Message"),
|
||||||
|
};
|
||||||
|
#pragma warning restore 0414
|
||||||
|
|
||||||
|
[Test, TestCaseSource("Codecs")]
|
||||||
|
public void RoundTripWithTag(ICodecTestData codec)
|
||||||
|
{
|
||||||
|
codec.TestRoundTripWithTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test, TestCaseSource("Codecs")]
|
||||||
|
public void RoundTripRaw(ICodecTestData codec)
|
||||||
|
{
|
||||||
|
codec.TestRoundTripRaw();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test, TestCaseSource("Codecs")]
|
||||||
|
public void CalculateSize(ICodecTestData codec)
|
||||||
|
{
|
||||||
|
codec.TestCalculateSizeWithTag();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test, TestCaseSource("Codecs")]
|
||||||
|
public void DefaultValue(ICodecTestData codec)
|
||||||
|
{
|
||||||
|
codec.TestDefaultValue();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test, TestCaseSource("Codecs")]
|
||||||
|
public void FixedSize(ICodecTestData codec)
|
||||||
|
{
|
||||||
|
codec.TestFixedSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is ugly, but it means we can have a non-generic interface.
|
||||||
|
// It feels like NUnit should support this better, but I don't know
|
||||||
|
// of any better ways right now.
|
||||||
|
public interface ICodecTestData
|
||||||
|
{
|
||||||
|
void TestRoundTripRaw();
|
||||||
|
void TestRoundTripWithTag();
|
||||||
|
void TestCalculateSizeWithTag();
|
||||||
|
void TestDefaultValue();
|
||||||
|
void TestFixedSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FieldCodecTestData<T> : ICodecTestData
|
||||||
|
{
|
||||||
|
private readonly FieldCodec<T> codec;
|
||||||
|
private readonly T sampleValue;
|
||||||
|
private readonly string name;
|
||||||
|
|
||||||
|
public FieldCodecTestData(FieldCodec<T> codec, T sampleValue, string name)
|
||||||
|
{
|
||||||
|
this.codec = codec;
|
||||||
|
this.sampleValue = sampleValue;
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TestRoundTripRaw()
|
||||||
|
{
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var codedOutput = new CodedOutputStream(stream);
|
||||||
|
codec.ValueWriter(codedOutput, sampleValue);
|
||||||
|
codedOutput.Flush();
|
||||||
|
stream.Position = 0;
|
||||||
|
var codedInput = new CodedInputStream(stream);
|
||||||
|
Assert.AreEqual(sampleValue, codec.ValueReader(codedInput));
|
||||||
|
Assert.IsTrue(codedInput.IsAtEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TestRoundTripWithTag()
|
||||||
|
{
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var codedOutput = new CodedOutputStream(stream);
|
||||||
|
codec.WriteTagAndValue(codedOutput, sampleValue);
|
||||||
|
codedOutput.Flush();
|
||||||
|
stream.Position = 0;
|
||||||
|
var codedInput = new CodedInputStream(stream);
|
||||||
|
codedInput.AssertNextTag(codec.Tag);
|
||||||
|
Assert.AreEqual(sampleValue, codec.Read(codedInput));
|
||||||
|
Assert.IsTrue(codedInput.IsAtEnd);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TestCalculateSizeWithTag()
|
||||||
|
{
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var codedOutput = new CodedOutputStream(stream);
|
||||||
|
codec.WriteTagAndValue(codedOutput, sampleValue);
|
||||||
|
codedOutput.Flush();
|
||||||
|
Assert.AreEqual(stream.Position, codec.CalculateSizeWithTag(sampleValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TestDefaultValue()
|
||||||
|
{
|
||||||
|
// WriteTagAndValue ignores default values
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var codedOutput = new CodedOutputStream(stream);
|
||||||
|
codec.WriteTagAndValue(codedOutput, codec.DefaultValue);
|
||||||
|
codedOutput.Flush();
|
||||||
|
Assert.AreEqual(0, stream.Position);
|
||||||
|
Assert.AreEqual(0, codec.CalculateSizeWithTag(codec.DefaultValue));
|
||||||
|
if (typeof(T).GetTypeInfo().IsValueType)
|
||||||
|
{
|
||||||
|
Assert.AreEqual(default(T), codec.DefaultValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
// The plain ValueWriter/ValueReader delegates don't.
|
||||||
|
if (codec.DefaultValue != null) // This part isn't appropriate for message types.
|
||||||
|
{
|
||||||
|
codedOutput = new CodedOutputStream(stream);
|
||||||
|
codec.ValueWriter(codedOutput, codec.DefaultValue);
|
||||||
|
codedOutput.Flush();
|
||||||
|
Assert.AreNotEqual(0, stream.Position);
|
||||||
|
Assert.AreEqual(stream.Position, codec.ValueSizeCalculator(codec.DefaultValue));
|
||||||
|
stream.Position = 0;
|
||||||
|
var codedInput = new CodedInputStream(stream);
|
||||||
|
Assert.AreEqual(codec.DefaultValue, codec.ValueReader(codedInput));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void TestFixedSize()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(name.Contains("Fixed"), codec.FixedSize != 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,723 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2015 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.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using Google.Protobuf.TestProtos;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Google.Protobuf.WellKnownTypes;
|
||||||
|
|
||||||
|
namespace Google.Protobuf
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Tests around the generated TestAllTypes message.
|
||||||
|
/// </summary>
|
||||||
|
public class GeneratedMessageTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void EmptyMessageFieldDistinctFromMissingMessageField()
|
||||||
|
{
|
||||||
|
// This demonstrates what we're really interested in...
|
||||||
|
var message1 = new TestAllTypes { SingleForeignMessage = new ForeignMessage() };
|
||||||
|
var message2 = new TestAllTypes(); // SingleForeignMessage is null
|
||||||
|
EqualityTester.AssertInequality(message1, message2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DefaultValues()
|
||||||
|
{
|
||||||
|
// Single fields
|
||||||
|
var message = new TestAllTypes();
|
||||||
|
Assert.AreEqual(false, message.SingleBool);
|
||||||
|
Assert.AreEqual(ByteString.Empty, message.SingleBytes);
|
||||||
|
Assert.AreEqual(0.0, message.SingleDouble);
|
||||||
|
Assert.AreEqual(0, message.SingleFixed32);
|
||||||
|
Assert.AreEqual(0L, message.SingleFixed64);
|
||||||
|
Assert.AreEqual(0.0f, message.SingleFloat);
|
||||||
|
Assert.AreEqual(ForeignEnum.ForeignUnspecified, message.SingleForeignEnum);
|
||||||
|
Assert.IsNull(message.SingleForeignMessage);
|
||||||
|
Assert.AreEqual(ImportEnum.Unspecified, message.SingleImportEnum);
|
||||||
|
Assert.IsNull(message.SingleImportMessage);
|
||||||
|
Assert.AreEqual(0, message.SingleInt32);
|
||||||
|
Assert.AreEqual(0L, message.SingleInt64);
|
||||||
|
Assert.AreEqual(TestAllTypes.Types.NestedEnum.Unspecified, message.SingleNestedEnum);
|
||||||
|
Assert.IsNull(message.SingleNestedMessage);
|
||||||
|
Assert.IsNull(message.SinglePublicImportMessage);
|
||||||
|
Assert.AreEqual(0, message.SingleSfixed32);
|
||||||
|
Assert.AreEqual(0L, message.SingleSfixed64);
|
||||||
|
Assert.AreEqual(0, message.SingleSint32);
|
||||||
|
Assert.AreEqual(0L, message.SingleSint64);
|
||||||
|
Assert.AreEqual("", message.SingleString);
|
||||||
|
Assert.AreEqual(0U, message.SingleUint32);
|
||||||
|
Assert.AreEqual(0UL, message.SingleUint64);
|
||||||
|
|
||||||
|
// Repeated fields
|
||||||
|
Assert.AreEqual(0, message.RepeatedBool.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedBytes.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedDouble.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedFixed32.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedFixed64.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedFloat.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedForeignEnum.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedForeignMessage.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedImportEnum.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedImportMessage.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedNestedEnum.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedNestedMessage.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedPublicImportMessage.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedSfixed32.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedSfixed64.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedSint32.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedSint64.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedString.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedUint32.Count);
|
||||||
|
Assert.AreEqual(0, message.RepeatedUint64.Count);
|
||||||
|
|
||||||
|
// Oneof fields
|
||||||
|
Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase);
|
||||||
|
Assert.AreEqual(0, message.OneofUint32);
|
||||||
|
Assert.AreEqual("", message.OneofString);
|
||||||
|
Assert.AreEqual(ByteString.Empty, message.OneofBytes);
|
||||||
|
Assert.IsNull(message.OneofNestedMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void NullStringAndBytesRejected()
|
||||||
|
{
|
||||||
|
var message = new TestAllTypes();
|
||||||
|
Assert.Throws<ArgumentNullException>(() => message.SingleString = null);
|
||||||
|
Assert.Throws<ArgumentNullException>(() => message.OneofString = null);
|
||||||
|
Assert.Throws<ArgumentNullException>(() => message.SingleBytes = null);
|
||||||
|
Assert.Throws<ArgumentNullException>(() => message.OneofBytes = null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void RoundTrip_Empty()
|
||||||
|
{
|
||||||
|
var message = new TestAllTypes();
|
||||||
|
// Without setting any values, there's nothing to write.
|
||||||
|
byte[] bytes = message.ToByteArray();
|
||||||
|
Assert.AreEqual(0, bytes.Length);
|
||||||
|
TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes);
|
||||||
|
Assert.AreEqual(message, parsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void RoundTrip_SingleValues()
|
||||||
|
{
|
||||||
|
var message = new TestAllTypes
|
||||||
|
{
|
||||||
|
SingleBool = true,
|
||||||
|
SingleBytes = ByteString.CopyFrom(1, 2, 3, 4),
|
||||||
|
SingleDouble = 23.5,
|
||||||
|
SingleFixed32 = 23,
|
||||||
|
SingleFixed64 = 1234567890123,
|
||||||
|
SingleFloat = 12.25f,
|
||||||
|
SingleForeignEnum = ForeignEnum.ForeignBar,
|
||||||
|
SingleForeignMessage = new ForeignMessage { C = 10 },
|
||||||
|
SingleImportEnum = ImportEnum.ImportBaz,
|
||||||
|
SingleImportMessage = new ImportMessage { D = 20 },
|
||||||
|
SingleInt32 = 100,
|
||||||
|
SingleInt64 = 3210987654321,
|
||||||
|
SingleNestedEnum = TestAllTypes.Types.NestedEnum.Foo,
|
||||||
|
SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 35 },
|
||||||
|
SinglePublicImportMessage = new PublicImportMessage { E = 54 },
|
||||||
|
SingleSfixed32 = -123,
|
||||||
|
SingleSfixed64 = -12345678901234,
|
||||||
|
SingleSint32 = -456,
|
||||||
|
SingleSint64 = -12345678901235,
|
||||||
|
SingleString = "test",
|
||||||
|
SingleUint32 = uint.MaxValue,
|
||||||
|
SingleUint64 = ulong.MaxValue
|
||||||
|
};
|
||||||
|
|
||||||
|
byte[] bytes = message.ToByteArray();
|
||||||
|
TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes);
|
||||||
|
Assert.AreEqual(message, parsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void RoundTrip_RepeatedValues()
|
||||||
|
{
|
||||||
|
var message = new TestAllTypes
|
||||||
|
{
|
||||||
|
RepeatedBool = { true, false },
|
||||||
|
RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6) },
|
||||||
|
RepeatedDouble = { -12.25, 23.5 },
|
||||||
|
RepeatedFixed32 = { uint.MaxValue, 23 },
|
||||||
|
RepeatedFixed64 = { ulong.MaxValue, 1234567890123 },
|
||||||
|
RepeatedFloat = { 100f, 12.25f },
|
||||||
|
RepeatedForeignEnum = { ForeignEnum.ForeignFoo, ForeignEnum.ForeignBar },
|
||||||
|
RepeatedForeignMessage = { new ForeignMessage(), new ForeignMessage { C = 10 } },
|
||||||
|
RepeatedImportEnum = { ImportEnum.ImportBaz, ImportEnum.Unspecified },
|
||||||
|
RepeatedImportMessage = { new ImportMessage { D = 20 }, new ImportMessage { D = 25 } },
|
||||||
|
RepeatedInt32 = { 100, 200 },
|
||||||
|
RepeatedInt64 = { 3210987654321, long.MaxValue },
|
||||||
|
RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.Foo, TestAllTypes.Types.NestedEnum.Neg },
|
||||||
|
RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 35 }, new TestAllTypes.Types.NestedMessage { Bb = 10 } },
|
||||||
|
RepeatedPublicImportMessage = { new PublicImportMessage { E = 54 }, new PublicImportMessage { E = -1 } },
|
||||||
|
RepeatedSfixed32 = { -123, 123 },
|
||||||
|
RepeatedSfixed64 = { -12345678901234, 12345678901234 },
|
||||||
|
RepeatedSint32 = { -456, 100 },
|
||||||
|
RepeatedSint64 = { -12345678901235, 123 },
|
||||||
|
RepeatedString = { "foo", "bar" },
|
||||||
|
RepeatedUint32 = { uint.MaxValue, uint.MinValue },
|
||||||
|
RepeatedUint64 = { ulong.MaxValue, uint.MinValue }
|
||||||
|
};
|
||||||
|
|
||||||
|
byte[] bytes = message.ToByteArray();
|
||||||
|
TestAllTypes parsed = TestAllTypes.Parser.ParseFrom(bytes);
|
||||||
|
Assert.AreEqual(message, parsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Note that not every map within map_unittest_proto3 is used. They all go through very
|
||||||
|
// similar code paths. The fact that all maps are present is validation that we have codecs
|
||||||
|
// for every type.
|
||||||
|
[Test]
|
||||||
|
public void RoundTrip_Maps()
|
||||||
|
{
|
||||||
|
var message = new TestMap
|
||||||
|
{
|
||||||
|
MapBoolBool = {
|
||||||
|
{ false, true },
|
||||||
|
{ true, false }
|
||||||
|
},
|
||||||
|
MapInt32Bytes = {
|
||||||
|
{ 5, ByteString.CopyFrom(6, 7, 8) },
|
||||||
|
{ 25, ByteString.CopyFrom(1, 2, 3, 4, 5) },
|
||||||
|
{ 10, ByteString.Empty }
|
||||||
|
},
|
||||||
|
MapInt32ForeignMessage = {
|
||||||
|
{ 0, new ForeignMessage { C = 10 } },
|
||||||
|
{ 5, new ForeignMessage() },
|
||||||
|
},
|
||||||
|
MapInt32Enum = {
|
||||||
|
{ 1, MapEnum.Bar },
|
||||||
|
{ 2000, MapEnum.Foo }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
byte[] bytes = message.ToByteArray();
|
||||||
|
TestMap parsed = TestMap.Parser.ParseFrom(bytes);
|
||||||
|
Assert.AreEqual(message, parsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MapWithEmptyEntry()
|
||||||
|
{
|
||||||
|
var message = new TestMap
|
||||||
|
{
|
||||||
|
MapInt32Bytes = { { 0, ByteString.Empty } }
|
||||||
|
};
|
||||||
|
|
||||||
|
byte[] bytes = message.ToByteArray();
|
||||||
|
Assert.AreEqual(2, bytes.Length); // Tag for field entry (1 byte), length of entry (0; 1 byte)
|
||||||
|
|
||||||
|
var parsed = TestMap.Parser.ParseFrom(bytes);
|
||||||
|
Assert.AreEqual(1, parsed.MapInt32Bytes.Count);
|
||||||
|
Assert.AreEqual(ByteString.Empty, parsed.MapInt32Bytes[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MapWithOnlyValue()
|
||||||
|
{
|
||||||
|
// Hand-craft the stream to contain a single entry with just a value.
|
||||||
|
var memoryStream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(memoryStream);
|
||||||
|
output.WriteTag(TestMap.MapInt32ForeignMessageFieldNumber, WireFormat.WireType.LengthDelimited);
|
||||||
|
var nestedMessage = new ForeignMessage { C = 20 };
|
||||||
|
// Size of the entry (tag, size written by WriteMessage, data written by WriteMessage)
|
||||||
|
output.WriteLength(2 + nestedMessage.CalculateSize());
|
||||||
|
output.WriteTag(2, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteMessage(nestedMessage);
|
||||||
|
output.Flush();
|
||||||
|
|
||||||
|
var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray());
|
||||||
|
Assert.AreEqual(nestedMessage, parsed.MapInt32ForeignMessage[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MapWithOnlyKey_PrimitiveValue()
|
||||||
|
{
|
||||||
|
// Hand-craft the stream to contain a single entry with just a key.
|
||||||
|
var memoryStream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(memoryStream);
|
||||||
|
output.WriteTag(TestMap.MapInt32DoubleFieldNumber, WireFormat.WireType.LengthDelimited);
|
||||||
|
int key = 10;
|
||||||
|
output.WriteLength(1 + CodedOutputStream.ComputeInt32Size(key));
|
||||||
|
output.WriteTag(1, WireFormat.WireType.Varint);
|
||||||
|
output.WriteInt32(key);
|
||||||
|
output.Flush();
|
||||||
|
|
||||||
|
var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray());
|
||||||
|
Assert.AreEqual(0.0, parsed.MapInt32Double[key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MapWithOnlyKey_MessageValue()
|
||||||
|
{
|
||||||
|
// Hand-craft the stream to contain a single entry with just a key.
|
||||||
|
var memoryStream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(memoryStream);
|
||||||
|
output.WriteTag(TestMap.MapInt32ForeignMessageFieldNumber, WireFormat.WireType.LengthDelimited);
|
||||||
|
int key = 10;
|
||||||
|
output.WriteLength(1 + CodedOutputStream.ComputeInt32Size(key));
|
||||||
|
output.WriteTag(1, WireFormat.WireType.Varint);
|
||||||
|
output.WriteInt32(key);
|
||||||
|
output.Flush();
|
||||||
|
|
||||||
|
var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray());
|
||||||
|
Assert.AreEqual(new ForeignMessage(), parsed.MapInt32ForeignMessage[key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MapIgnoresExtraFieldsWithinEntryMessages()
|
||||||
|
{
|
||||||
|
// Hand-craft the stream to contain a single entry with three fields
|
||||||
|
var memoryStream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(memoryStream);
|
||||||
|
|
||||||
|
output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited);
|
||||||
|
|
||||||
|
var key = 10; // Field 1
|
||||||
|
var value = 20; // Field 2
|
||||||
|
var extra = 30; // Field 3
|
||||||
|
|
||||||
|
// Each field can be represented in a single byte, with a single byte tag.
|
||||||
|
// Total message size: 6 bytes.
|
||||||
|
output.WriteLength(6);
|
||||||
|
output.WriteTag(1, WireFormat.WireType.Varint);
|
||||||
|
output.WriteInt32(key);
|
||||||
|
output.WriteTag(2, WireFormat.WireType.Varint);
|
||||||
|
output.WriteInt32(value);
|
||||||
|
output.WriteTag(3, WireFormat.WireType.Varint);
|
||||||
|
output.WriteInt32(extra);
|
||||||
|
output.Flush();
|
||||||
|
|
||||||
|
var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray());
|
||||||
|
Assert.AreEqual(value, parsed.MapInt32Int32[key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MapFieldOrderIsIrrelevant()
|
||||||
|
{
|
||||||
|
var memoryStream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(memoryStream);
|
||||||
|
|
||||||
|
output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited);
|
||||||
|
|
||||||
|
var key = 10;
|
||||||
|
var value = 20;
|
||||||
|
|
||||||
|
// Each field can be represented in a single byte, with a single byte tag.
|
||||||
|
// Total message size: 4 bytes.
|
||||||
|
output.WriteLength(4);
|
||||||
|
output.WriteTag(2, WireFormat.WireType.Varint);
|
||||||
|
output.WriteInt32(value);
|
||||||
|
output.WriteTag(1, WireFormat.WireType.Varint);
|
||||||
|
output.WriteInt32(key);
|
||||||
|
output.Flush();
|
||||||
|
|
||||||
|
var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray());
|
||||||
|
Assert.AreEqual(value, parsed.MapInt32Int32[key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MapNonContiguousEntries()
|
||||||
|
{
|
||||||
|
var memoryStream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(memoryStream);
|
||||||
|
|
||||||
|
// Message structure:
|
||||||
|
// Entry for MapInt32Int32
|
||||||
|
// Entry for MapStringString
|
||||||
|
// Entry for MapInt32Int32
|
||||||
|
|
||||||
|
// First entry
|
||||||
|
var key1 = 10;
|
||||||
|
var value1 = 20;
|
||||||
|
output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteLength(4);
|
||||||
|
output.WriteTag(1, WireFormat.WireType.Varint);
|
||||||
|
output.WriteInt32(key1);
|
||||||
|
output.WriteTag(2, WireFormat.WireType.Varint);
|
||||||
|
output.WriteInt32(value1);
|
||||||
|
|
||||||
|
// Second entry
|
||||||
|
var key2 = "a";
|
||||||
|
var value2 = "b";
|
||||||
|
output.WriteTag(TestMap.MapStringStringFieldNumber, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteLength(6); // 3 bytes per entry: tag, size, character
|
||||||
|
output.WriteTag(1, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteString(key2);
|
||||||
|
output.WriteTag(2, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteString(value2);
|
||||||
|
|
||||||
|
// Third entry
|
||||||
|
var key3 = 15;
|
||||||
|
var value3 = 25;
|
||||||
|
output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteLength(4);
|
||||||
|
output.WriteTag(1, WireFormat.WireType.Varint);
|
||||||
|
output.WriteInt32(key3);
|
||||||
|
output.WriteTag(2, WireFormat.WireType.Varint);
|
||||||
|
output.WriteInt32(value3);
|
||||||
|
|
||||||
|
output.Flush();
|
||||||
|
var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray());
|
||||||
|
var expected = new TestMap
|
||||||
|
{
|
||||||
|
MapInt32Int32 = { { key1, value1 }, { key3, value3 } },
|
||||||
|
MapStringString = { { key2, value2 } }
|
||||||
|
};
|
||||||
|
Assert.AreEqual(expected, parsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DuplicateKeys_LastEntryWins()
|
||||||
|
{
|
||||||
|
var memoryStream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(memoryStream);
|
||||||
|
|
||||||
|
var key = 10;
|
||||||
|
var value1 = 20;
|
||||||
|
var value2 = 30;
|
||||||
|
|
||||||
|
// First entry
|
||||||
|
output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteLength(4);
|
||||||
|
output.WriteTag(1, WireFormat.WireType.Varint);
|
||||||
|
output.WriteInt32(key);
|
||||||
|
output.WriteTag(2, WireFormat.WireType.Varint);
|
||||||
|
output.WriteInt32(value1);
|
||||||
|
|
||||||
|
// Second entry - same key, different value
|
||||||
|
output.WriteTag(TestMap.MapInt32Int32FieldNumber, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteLength(4);
|
||||||
|
output.WriteTag(1, WireFormat.WireType.Varint);
|
||||||
|
output.WriteInt32(key);
|
||||||
|
output.WriteTag(2, WireFormat.WireType.Varint);
|
||||||
|
output.WriteInt32(value2);
|
||||||
|
output.Flush();
|
||||||
|
|
||||||
|
var parsed = TestMap.Parser.ParseFrom(memoryStream.ToArray());
|
||||||
|
Assert.AreEqual(value2, parsed.MapInt32Int32[key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CloneSingleNonMessageValues()
|
||||||
|
{
|
||||||
|
var original = new TestAllTypes
|
||||||
|
{
|
||||||
|
SingleBool = true,
|
||||||
|
SingleBytes = ByteString.CopyFrom(1, 2, 3, 4),
|
||||||
|
SingleDouble = 23.5,
|
||||||
|
SingleFixed32 = 23,
|
||||||
|
SingleFixed64 = 1234567890123,
|
||||||
|
SingleFloat = 12.25f,
|
||||||
|
SingleInt32 = 100,
|
||||||
|
SingleInt64 = 3210987654321,
|
||||||
|
SingleNestedEnum = TestAllTypes.Types.NestedEnum.Foo,
|
||||||
|
SingleSfixed32 = -123,
|
||||||
|
SingleSfixed64 = -12345678901234,
|
||||||
|
SingleSint32 = -456,
|
||||||
|
SingleSint64 = -12345678901235,
|
||||||
|
SingleString = "test",
|
||||||
|
SingleUint32 = uint.MaxValue,
|
||||||
|
SingleUint64 = ulong.MaxValue
|
||||||
|
};
|
||||||
|
var clone = original.Clone();
|
||||||
|
Assert.AreNotSame(original, clone);
|
||||||
|
Assert.AreEqual(original, clone);
|
||||||
|
// Just as a single example
|
||||||
|
clone.SingleInt32 = 150;
|
||||||
|
Assert.AreNotEqual(original, clone);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CloneRepeatedNonMessageValues()
|
||||||
|
{
|
||||||
|
var original = new TestAllTypes
|
||||||
|
{
|
||||||
|
RepeatedBool = { true, false },
|
||||||
|
RepeatedBytes = { ByteString.CopyFrom(1, 2, 3, 4), ByteString.CopyFrom(5, 6) },
|
||||||
|
RepeatedDouble = { -12.25, 23.5 },
|
||||||
|
RepeatedFixed32 = { uint.MaxValue, 23 },
|
||||||
|
RepeatedFixed64 = { ulong.MaxValue, 1234567890123 },
|
||||||
|
RepeatedFloat = { 100f, 12.25f },
|
||||||
|
RepeatedInt32 = { 100, 200 },
|
||||||
|
RepeatedInt64 = { 3210987654321, long.MaxValue },
|
||||||
|
RepeatedNestedEnum = { TestAllTypes.Types.NestedEnum.Foo, TestAllTypes.Types.NestedEnum.Neg },
|
||||||
|
RepeatedSfixed32 = { -123, 123 },
|
||||||
|
RepeatedSfixed64 = { -12345678901234, 12345678901234 },
|
||||||
|
RepeatedSint32 = { -456, 100 },
|
||||||
|
RepeatedSint64 = { -12345678901235, 123 },
|
||||||
|
RepeatedString = { "foo", "bar" },
|
||||||
|
RepeatedUint32 = { uint.MaxValue, uint.MinValue },
|
||||||
|
RepeatedUint64 = { ulong.MaxValue, uint.MinValue }
|
||||||
|
};
|
||||||
|
|
||||||
|
var clone = original.Clone();
|
||||||
|
Assert.AreNotSame(original, clone);
|
||||||
|
Assert.AreEqual(original, clone);
|
||||||
|
// Just as a single example
|
||||||
|
clone.RepeatedDouble.Add(25.5);
|
||||||
|
Assert.AreNotEqual(original, clone);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CloneSingleMessageField()
|
||||||
|
{
|
||||||
|
var original = new TestAllTypes
|
||||||
|
{
|
||||||
|
SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 }
|
||||||
|
};
|
||||||
|
|
||||||
|
var clone = original.Clone();
|
||||||
|
Assert.AreNotSame(original, clone);
|
||||||
|
Assert.AreNotSame(original.SingleNestedMessage, clone.SingleNestedMessage);
|
||||||
|
Assert.AreEqual(original, clone);
|
||||||
|
|
||||||
|
clone.SingleNestedMessage.Bb = 30;
|
||||||
|
Assert.AreNotEqual(original, clone);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CloneRepeatedMessageField()
|
||||||
|
{
|
||||||
|
var original = new TestAllTypes
|
||||||
|
{
|
||||||
|
RepeatedNestedMessage = { new TestAllTypes.Types.NestedMessage { Bb = 20 } }
|
||||||
|
};
|
||||||
|
|
||||||
|
var clone = original.Clone();
|
||||||
|
Assert.AreNotSame(original, clone);
|
||||||
|
Assert.AreNotSame(original.RepeatedNestedMessage, clone.RepeatedNestedMessage);
|
||||||
|
Assert.AreNotSame(original.RepeatedNestedMessage[0], clone.RepeatedNestedMessage[0]);
|
||||||
|
Assert.AreEqual(original, clone);
|
||||||
|
|
||||||
|
clone.RepeatedNestedMessage[0].Bb = 30;
|
||||||
|
Assert.AreNotEqual(original, clone);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CloneOneofField()
|
||||||
|
{
|
||||||
|
var original = new TestAllTypes
|
||||||
|
{
|
||||||
|
OneofNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 }
|
||||||
|
};
|
||||||
|
|
||||||
|
var clone = original.Clone();
|
||||||
|
Assert.AreNotSame(original, clone);
|
||||||
|
Assert.AreEqual(original, clone);
|
||||||
|
|
||||||
|
// We should have cloned the message
|
||||||
|
original.OneofNestedMessage.Bb = 30;
|
||||||
|
Assert.AreNotEqual(original, clone);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void OneofProperties()
|
||||||
|
{
|
||||||
|
// Switch the oneof case between each of the different options, and check everything behaves
|
||||||
|
// as expected in each case.
|
||||||
|
var message = new TestAllTypes();
|
||||||
|
Assert.AreEqual("", message.OneofString);
|
||||||
|
Assert.AreEqual(0, message.OneofUint32);
|
||||||
|
Assert.AreEqual(ByteString.Empty, message.OneofBytes);
|
||||||
|
Assert.IsNull(message.OneofNestedMessage);
|
||||||
|
Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase);
|
||||||
|
|
||||||
|
message.OneofString = "sample";
|
||||||
|
Assert.AreEqual("sample", message.OneofString);
|
||||||
|
Assert.AreEqual(0, message.OneofUint32);
|
||||||
|
Assert.AreEqual(ByteString.Empty, message.OneofBytes);
|
||||||
|
Assert.IsNull(message.OneofNestedMessage);
|
||||||
|
Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofString, message.OneofFieldCase);
|
||||||
|
|
||||||
|
var bytes = ByteString.CopyFrom(1, 2, 3);
|
||||||
|
message.OneofBytes = bytes;
|
||||||
|
Assert.AreEqual("", message.OneofString);
|
||||||
|
Assert.AreEqual(0, message.OneofUint32);
|
||||||
|
Assert.AreEqual(bytes, message.OneofBytes);
|
||||||
|
Assert.IsNull(message.OneofNestedMessage);
|
||||||
|
Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofBytes, message.OneofFieldCase);
|
||||||
|
|
||||||
|
message.OneofUint32 = 20;
|
||||||
|
Assert.AreEqual("", message.OneofString);
|
||||||
|
Assert.AreEqual(20, message.OneofUint32);
|
||||||
|
Assert.AreEqual(ByteString.Empty, message.OneofBytes);
|
||||||
|
Assert.IsNull(message.OneofNestedMessage);
|
||||||
|
Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message.OneofFieldCase);
|
||||||
|
|
||||||
|
var nestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 25 };
|
||||||
|
message.OneofNestedMessage = nestedMessage;
|
||||||
|
Assert.AreEqual("", message.OneofString);
|
||||||
|
Assert.AreEqual(0, message.OneofUint32);
|
||||||
|
Assert.AreEqual(ByteString.Empty, message.OneofBytes);
|
||||||
|
Assert.AreEqual(nestedMessage, message.OneofNestedMessage);
|
||||||
|
Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofNestedMessage, message.OneofFieldCase);
|
||||||
|
|
||||||
|
message.ClearOneofField();
|
||||||
|
Assert.AreEqual("", message.OneofString);
|
||||||
|
Assert.AreEqual(0, message.OneofUint32);
|
||||||
|
Assert.AreEqual(ByteString.Empty, message.OneofBytes);
|
||||||
|
Assert.IsNull(message.OneofNestedMessage);
|
||||||
|
Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Oneof_DefaultValuesNotEqual()
|
||||||
|
{
|
||||||
|
var message1 = new TestAllTypes { OneofString = "" };
|
||||||
|
var message2 = new TestAllTypes { OneofUint32 = 0 };
|
||||||
|
Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofString, message1.OneofFieldCase);
|
||||||
|
Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase);
|
||||||
|
Assert.AreNotEqual(message1, message2);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void OneofSerialization_NonDefaultValue()
|
||||||
|
{
|
||||||
|
var message = new TestAllTypes();
|
||||||
|
message.OneofString = "this would take a bit of space";
|
||||||
|
message.OneofUint32 = 10;
|
||||||
|
var bytes = message.ToByteArray();
|
||||||
|
Assert.AreEqual(3, bytes.Length); // 2 bytes for the tag + 1 for the value - no string!
|
||||||
|
|
||||||
|
var message2 = TestAllTypes.Parser.ParseFrom(bytes);
|
||||||
|
Assert.AreEqual(message, message2);
|
||||||
|
Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void OneofSerialization_DefaultValue()
|
||||||
|
{
|
||||||
|
var message = new TestAllTypes();
|
||||||
|
message.OneofString = "this would take a bit of space";
|
||||||
|
message.OneofUint32 = 0; // This is the default value for UInt32; normally wouldn't be serialized
|
||||||
|
var bytes = message.ToByteArray();
|
||||||
|
Assert.AreEqual(3, bytes.Length); // 2 bytes for the tag + 1 for the value - it's still serialized
|
||||||
|
|
||||||
|
var message2 = TestAllTypes.Parser.ParseFrom(bytes);
|
||||||
|
Assert.AreEqual(message, message2);
|
||||||
|
Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.OneofUint32, message2.OneofFieldCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IgnoreUnknownFields_RealDataStillRead()
|
||||||
|
{
|
||||||
|
var message = SampleMessages.CreateFullTestAllTypes();
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(stream);
|
||||||
|
var unusedFieldNumber = 23456;
|
||||||
|
Assert.IsFalse(TestAllTypes.Descriptor.Fields.InDeclarationOrder().Select(x => x.FieldNumber).Contains(unusedFieldNumber));
|
||||||
|
output.WriteTag(unusedFieldNumber, WireFormat.WireType.LengthDelimited);
|
||||||
|
output.WriteString("ignore me");
|
||||||
|
message.WriteTo(output);
|
||||||
|
output.Flush();
|
||||||
|
|
||||||
|
stream.Position = 0;
|
||||||
|
var parsed = TestAllTypes.Parser.ParseFrom(stream);
|
||||||
|
Assert.AreEqual(message, parsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IgnoreUnknownFields_AllTypes()
|
||||||
|
{
|
||||||
|
// Simple way of ensuring we can skip all kinds of fields.
|
||||||
|
var data = SampleMessages.CreateFullTestAllTypes().ToByteArray();
|
||||||
|
var empty = Empty.Parser.ParseFrom(data);
|
||||||
|
Assert.AreEqual(new Empty(), empty);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This was originally seen as a conformance test failure.
|
||||||
|
[Test]
|
||||||
|
public void TruncatedMessageFieldThrows()
|
||||||
|
{
|
||||||
|
// 130, 3 is the message tag
|
||||||
|
// 1 is the data length - but there's no data.
|
||||||
|
var data = new byte[] { 130, 3, 1 };
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseFrom(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Demonstrates current behaviour with an extraneous end group tag - see issue 688
|
||||||
|
/// for details; we may want to change this.
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void ExtraEndGroupThrows()
|
||||||
|
{
|
||||||
|
var message = SampleMessages.CreateFullTestAllTypes();
|
||||||
|
var stream = new MemoryStream();
|
||||||
|
var output = new CodedOutputStream(stream);
|
||||||
|
|
||||||
|
output.WriteTag(TestAllTypes.SingleFixed32FieldNumber, WireFormat.WireType.Fixed32);
|
||||||
|
output.WriteFixed32(123);
|
||||||
|
output.WriteTag(100, WireFormat.WireType.EndGroup);
|
||||||
|
|
||||||
|
output.Flush();
|
||||||
|
|
||||||
|
stream.Position = 0;
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseFrom(stream));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CustomDiagnosticMessage_DirectToStringCall()
|
||||||
|
{
|
||||||
|
var message = new ForeignMessage { C = 31 };
|
||||||
|
Assert.AreEqual("{ \"c\": 31, \"@cInHex\": \"1f\" }", message.ToString());
|
||||||
|
Assert.AreEqual("{ \"c\": 31 }", JsonFormatter.Default.Format(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CustomDiagnosticMessage_Nested()
|
||||||
|
{
|
||||||
|
var message = new TestAllTypes { SingleForeignMessage = new ForeignMessage { C = 16 } };
|
||||||
|
Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16, \"@cInHex\": \"10\" } }", message.ToString());
|
||||||
|
Assert.AreEqual("{ \"singleForeignMessage\": { \"c\": 16 } }", JsonFormatter.Default.Format(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CustomDiagnosticMessage_DirectToTextWriterCall()
|
||||||
|
{
|
||||||
|
var message = new ForeignMessage { C = 31 };
|
||||||
|
var writer = new StringWriter();
|
||||||
|
JsonFormatter.Default.Format(message, writer);
|
||||||
|
Assert.AreEqual("{ \"c\": 31 }", writer.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<OutputType>Exe</OutputType>
|
||||||
|
<TargetFrameworks>net451;netcoreapp1.0</TargetFrameworks>
|
||||||
|
<AssemblyOriginatorKeyFile>../../keys/Google.Protobuf.snk</AssemblyOriginatorKeyFile>
|
||||||
|
<SignAssembly>true</SignAssembly>
|
||||||
|
<PublicSign Condition=" '$(OS)' != 'Windows_NT' ">true</PublicSign>
|
||||||
|
<IsPackable>False</IsPackable>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\Google.Protobuf\Google.Protobuf.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="NUnit" Version="3.6.1" />
|
||||||
|
<PackageReference Include="NUnitLite" Version="3.6.1" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<!--
|
||||||
|
- Override target frameworks on non-Windows to just .NET Core
|
||||||
|
- Doing this conditionally in the initial PropertyGroup confuses
|
||||||
|
- Visual Studio.
|
||||||
|
-->
|
||||||
|
<PropertyGroup Condition="'$(OS)' != 'Windows_NT'">
|
||||||
|
<TargetFrameworks>netcoreapp1.0</TargetFrameworks>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
</Project>
|
|
@ -0,0 +1,82 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// 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.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using Google.Protobuf.Reflection;
|
||||||
|
using UnitTest.Issues.TestProtos;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
|
||||||
|
namespace Google.Protobuf
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Tests for issues which aren't easily compartmentalized into other unit tests.
|
||||||
|
/// </summary>
|
||||||
|
public class IssuesTest
|
||||||
|
{
|
||||||
|
// Issue 45
|
||||||
|
[Test]
|
||||||
|
public void FieldCalledItem()
|
||||||
|
{
|
||||||
|
ItemField message = new ItemField { Item = 3 };
|
||||||
|
FieldDescriptor field = ItemField.Descriptor.FindFieldByName("item");
|
||||||
|
Assert.NotNull(field);
|
||||||
|
Assert.AreEqual(3, (int)field.Accessor.GetValue(message));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ReservedNames()
|
||||||
|
{
|
||||||
|
var message = new ReservedNames { Types_ = 10, Descriptor_ = 20 };
|
||||||
|
// Underscores aren't reflected in the JSON.
|
||||||
|
Assert.AreEqual("{ \"types\": 10, \"descriptor\": 20 }", message.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void JsonNameParseTest()
|
||||||
|
{
|
||||||
|
var settings = new JsonParser.Settings(10, TypeRegistry.FromFiles(UnittestIssuesReflection.Descriptor));
|
||||||
|
var parser = new JsonParser(settings);
|
||||||
|
|
||||||
|
// It is safe to use either original field name or explicitly specified json_name
|
||||||
|
Assert.AreEqual(new TestJsonName { Name = "test", Description = "test2", Guid = "test3" },
|
||||||
|
parser.Parse<TestJsonName>("{ \"name\": \"test\", \"desc\": \"test2\", \"guid\": \"test3\" }"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void JsonNameFormatTest()
|
||||||
|
{
|
||||||
|
var message = new TestJsonName { Name = "test", Description = "test2", Guid = "test3" };
|
||||||
|
Assert.AreEqual("{ \"name\": \"test\", \"desc\": \"test2\", \"exid\": \"test3\" }",
|
||||||
|
JsonFormatter.Default.Format(message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,939 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// 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.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using Google.Protobuf.Reflection;
|
||||||
|
using Google.Protobuf.TestProtos;
|
||||||
|
using Google.Protobuf.WellKnownTypes;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace Google.Protobuf
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Unit tests for JSON parsing.
|
||||||
|
/// </summary>
|
||||||
|
public class JsonParserTest
|
||||||
|
{
|
||||||
|
// Sanity smoke test
|
||||||
|
[Test]
|
||||||
|
public void AllTypesRoundtrip()
|
||||||
|
{
|
||||||
|
AssertRoundtrip(SampleMessages.CreateFullTestAllTypes());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Maps()
|
||||||
|
{
|
||||||
|
AssertRoundtrip(new TestMap { MapStringString = { { "with spaces", "bar" }, { "a", "b" } } });
|
||||||
|
AssertRoundtrip(new TestMap { MapInt32Int32 = { { 0, 1 }, { 2, 3 } } });
|
||||||
|
AssertRoundtrip(new TestMap { MapBoolBool = { { false, true }, { true, false } } });
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase(" 1 ")]
|
||||||
|
[TestCase("+1")]
|
||||||
|
[TestCase("1,000")]
|
||||||
|
[TestCase("1.5")]
|
||||||
|
public void IntegerMapKeysAreStrict(string keyText)
|
||||||
|
{
|
||||||
|
// Test that integer parsing is strict. We assume that if this is correct for int32,
|
||||||
|
// it's correct for other numeric key types.
|
||||||
|
var json = "{ \"mapInt32Int32\": { \"" + keyText + "\" : \"1\" } }";
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => JsonParser.Default.Parse<TestMap>(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void OriginalFieldNameAccepted()
|
||||||
|
{
|
||||||
|
var json = "{ \"single_int32\": 10 }";
|
||||||
|
var expected = new TestAllTypes { SingleInt32 = 10 };
|
||||||
|
Assert.AreEqual(expected, TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SourceContextRoundtrip()
|
||||||
|
{
|
||||||
|
AssertRoundtrip(new SourceContext { FileName = "foo.proto" });
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SingularWrappers_DefaultNonNullValues()
|
||||||
|
{
|
||||||
|
var message = new TestWellKnownTypes
|
||||||
|
{
|
||||||
|
StringField = "",
|
||||||
|
BytesField = ByteString.Empty,
|
||||||
|
BoolField = false,
|
||||||
|
FloatField = 0f,
|
||||||
|
DoubleField = 0d,
|
||||||
|
Int32Field = 0,
|
||||||
|
Int64Field = 0,
|
||||||
|
Uint32Field = 0,
|
||||||
|
Uint64Field = 0
|
||||||
|
};
|
||||||
|
AssertRoundtrip(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SingularWrappers_NonDefaultValues()
|
||||||
|
{
|
||||||
|
var message = new TestWellKnownTypes
|
||||||
|
{
|
||||||
|
StringField = "x",
|
||||||
|
BytesField = ByteString.CopyFrom(1, 2, 3),
|
||||||
|
BoolField = true,
|
||||||
|
FloatField = 12.5f,
|
||||||
|
DoubleField = 12.25d,
|
||||||
|
Int32Field = 1,
|
||||||
|
Int64Field = 2,
|
||||||
|
Uint32Field = 3,
|
||||||
|
Uint64Field = 4
|
||||||
|
};
|
||||||
|
AssertRoundtrip(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SingularWrappers_ExplicitNulls()
|
||||||
|
{
|
||||||
|
// When we parse the "valueField": null part, we remember it... basically, it's one case
|
||||||
|
// where explicit default values don't fully roundtrip.
|
||||||
|
var message = new TestWellKnownTypes { ValueField = Value.ForNull() };
|
||||||
|
var json = new JsonFormatter(new JsonFormatter.Settings(true)).Format(message);
|
||||||
|
var parsed = JsonParser.Default.Parse<TestWellKnownTypes>(json);
|
||||||
|
Assert.AreEqual(message, parsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase(typeof(BoolValue), "true", true)]
|
||||||
|
[TestCase(typeof(Int32Value), "32", 32)]
|
||||||
|
[TestCase(typeof(Int64Value), "32", 32L)]
|
||||||
|
[TestCase(typeof(Int64Value), "\"32\"", 32L)]
|
||||||
|
[TestCase(typeof(UInt32Value), "32", 32U)]
|
||||||
|
[TestCase(typeof(UInt64Value), "\"32\"", 32UL)]
|
||||||
|
[TestCase(typeof(UInt64Value), "32", 32UL)]
|
||||||
|
[TestCase(typeof(StringValue), "\"foo\"", "foo")]
|
||||||
|
[TestCase(typeof(FloatValue), "1.5", 1.5f)]
|
||||||
|
[TestCase(typeof(DoubleValue), "1.5", 1.5d)]
|
||||||
|
public void Wrappers_Standalone(System.Type wrapperType, string json, object expectedValue)
|
||||||
|
{
|
||||||
|
IMessage parsed = (IMessage)Activator.CreateInstance(wrapperType);
|
||||||
|
IMessage expected = (IMessage)Activator.CreateInstance(wrapperType);
|
||||||
|
JsonParser.Default.Merge(parsed, "null");
|
||||||
|
Assert.AreEqual(expected, parsed);
|
||||||
|
|
||||||
|
JsonParser.Default.Merge(parsed, json);
|
||||||
|
expected.Descriptor.Fields[WrappersReflection.WrapperValueFieldNumber].Accessor.SetValue(expected, expectedValue);
|
||||||
|
Assert.AreEqual(expected, parsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ExplicitNullValue()
|
||||||
|
{
|
||||||
|
string json = "{\"valueField\": null}";
|
||||||
|
var message = JsonParser.Default.Parse<TestWellKnownTypes>(json);
|
||||||
|
Assert.AreEqual(new TestWellKnownTypes { ValueField = Value.ForNull() }, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void BytesWrapper_Standalone()
|
||||||
|
{
|
||||||
|
ByteString data = ByteString.CopyFrom(1, 2, 3);
|
||||||
|
// Can't do this with attributes...
|
||||||
|
var parsed = JsonParser.Default.Parse<BytesValue>(WrapInQuotes(data.ToBase64()));
|
||||||
|
var expected = new BytesValue { Value = data };
|
||||||
|
Assert.AreEqual(expected, parsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void RepeatedWrappers()
|
||||||
|
{
|
||||||
|
var message = new RepeatedWellKnownTypes
|
||||||
|
{
|
||||||
|
BoolField = { true, false },
|
||||||
|
BytesField = { ByteString.CopyFrom(1, 2, 3), ByteString.CopyFrom(4, 5, 6), ByteString.Empty },
|
||||||
|
DoubleField = { 12.5, -1.5, 0d },
|
||||||
|
FloatField = { 123.25f, -20f, 0f },
|
||||||
|
Int32Field = { int.MaxValue, int.MinValue, 0 },
|
||||||
|
Int64Field = { long.MaxValue, long.MinValue, 0L },
|
||||||
|
StringField = { "First", "Second", "" },
|
||||||
|
Uint32Field = { uint.MaxValue, uint.MinValue, 0U },
|
||||||
|
Uint64Field = { ulong.MaxValue, ulong.MinValue, 0UL },
|
||||||
|
};
|
||||||
|
AssertRoundtrip(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void RepeatedField_NullElementProhibited()
|
||||||
|
{
|
||||||
|
string json = "{ \"repeated_foreign_message\": [null] }";
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void RepeatedField_NullOverallValueAllowed()
|
||||||
|
{
|
||||||
|
string json = "{ \"repeated_foreign_message\": null }";
|
||||||
|
Assert.AreEqual(new TestAllTypes(), TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("{ \"mapInt32Int32\": { \"10\": null }")]
|
||||||
|
[TestCase("{ \"mapStringString\": { \"abc\": null }")]
|
||||||
|
[TestCase("{ \"mapInt32ForeignMessage\": { \"10\": null }")]
|
||||||
|
public void MapField_NullValueProhibited(string json)
|
||||||
|
{
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestMap.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MapField_NullOverallValueAllowed()
|
||||||
|
{
|
||||||
|
string json = "{ \"mapInt32Int32\": null }";
|
||||||
|
Assert.AreEqual(new TestMap(), TestMap.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void IndividualWrapperTypes()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(new StringValue { Value = "foo" }, StringValue.Parser.ParseJson("\"foo\""));
|
||||||
|
Assert.AreEqual(new Int32Value { Value = 1 }, Int32Value.Parser.ParseJson("1"));
|
||||||
|
// Can parse strings directly too
|
||||||
|
Assert.AreEqual(new Int32Value { Value = 1 }, Int32Value.Parser.ParseJson("\"1\""));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void AssertRoundtrip<T>(T message) where T : IMessage<T>, new()
|
||||||
|
{
|
||||||
|
var clone = message.Clone();
|
||||||
|
var json = JsonFormatter.Default.Format(message);
|
||||||
|
var parsed = JsonParser.Default.Parse<T>(json);
|
||||||
|
Assert.AreEqual(clone, parsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("0", 0)]
|
||||||
|
[TestCase("-0", 0)] // Not entirely clear whether we intend to allow this...
|
||||||
|
[TestCase("1", 1)]
|
||||||
|
[TestCase("-1", -1)]
|
||||||
|
[TestCase("2147483647", 2147483647)]
|
||||||
|
[TestCase("-2147483648", -2147483648)]
|
||||||
|
public void StringToInt32_Valid(string jsonValue, int expectedParsedValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleInt32\": \"" + jsonValue + "\"}";
|
||||||
|
var parsed = TestAllTypes.Parser.ParseJson(json);
|
||||||
|
Assert.AreEqual(expectedParsedValue, parsed.SingleInt32);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("+0")]
|
||||||
|
[TestCase(" 1")]
|
||||||
|
[TestCase("1 ")]
|
||||||
|
[TestCase("00")]
|
||||||
|
[TestCase("-00")]
|
||||||
|
[TestCase("--1")]
|
||||||
|
[TestCase("+1")]
|
||||||
|
[TestCase("1.5")]
|
||||||
|
[TestCase("1e10")]
|
||||||
|
[TestCase("2147483648")]
|
||||||
|
[TestCase("-2147483649")]
|
||||||
|
public void StringToInt32_Invalid(string jsonValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleInt32\": \"" + jsonValue + "\"}";
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("0", 0U)]
|
||||||
|
[TestCase("1", 1U)]
|
||||||
|
[TestCase("4294967295", 4294967295U)]
|
||||||
|
public void StringToUInt32_Valid(string jsonValue, uint expectedParsedValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleUint32\": \"" + jsonValue + "\"}";
|
||||||
|
var parsed = TestAllTypes.Parser.ParseJson(json);
|
||||||
|
Assert.AreEqual(expectedParsedValue, parsed.SingleUint32);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assume that anything non-bounds-related is covered in the Int32 case
|
||||||
|
[Test]
|
||||||
|
[TestCase("-1")]
|
||||||
|
[TestCase("4294967296")]
|
||||||
|
public void StringToUInt32_Invalid(string jsonValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleUint32\": \"" + jsonValue + "\"}";
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("0", 0L)]
|
||||||
|
[TestCase("1", 1L)]
|
||||||
|
[TestCase("-1", -1L)]
|
||||||
|
[TestCase("9223372036854775807", 9223372036854775807)]
|
||||||
|
[TestCase("-9223372036854775808", -9223372036854775808)]
|
||||||
|
public void StringToInt64_Valid(string jsonValue, long expectedParsedValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleInt64\": \"" + jsonValue + "\"}";
|
||||||
|
var parsed = TestAllTypes.Parser.ParseJson(json);
|
||||||
|
Assert.AreEqual(expectedParsedValue, parsed.SingleInt64);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assume that anything non-bounds-related is covered in the Int32 case
|
||||||
|
[Test]
|
||||||
|
[TestCase("-9223372036854775809")]
|
||||||
|
[TestCase("9223372036854775808")]
|
||||||
|
public void StringToInt64_Invalid(string jsonValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleInt64\": \"" + jsonValue + "\"}";
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("0", 0UL)]
|
||||||
|
[TestCase("1", 1UL)]
|
||||||
|
[TestCase("18446744073709551615", 18446744073709551615)]
|
||||||
|
public void StringToUInt64_Valid(string jsonValue, ulong expectedParsedValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleUint64\": \"" + jsonValue + "\"}";
|
||||||
|
var parsed = TestAllTypes.Parser.ParseJson(json);
|
||||||
|
Assert.AreEqual(expectedParsedValue, parsed.SingleUint64);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assume that anything non-bounds-related is covered in the Int32 case
|
||||||
|
[Test]
|
||||||
|
[TestCase("-1")]
|
||||||
|
[TestCase("18446744073709551616")]
|
||||||
|
public void StringToUInt64_Invalid(string jsonValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleUint64\": \"" + jsonValue + "\"}";
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("0", 0d)]
|
||||||
|
[TestCase("1", 1d)]
|
||||||
|
[TestCase("1.000000", 1d)]
|
||||||
|
[TestCase("1.0000000000000000000000001", 1d)] // We don't notice that we haven't preserved the exact value
|
||||||
|
[TestCase("-1", -1d)]
|
||||||
|
[TestCase("1e1", 10d)]
|
||||||
|
[TestCase("1e01", 10d)] // Leading decimals are allowed in exponents
|
||||||
|
[TestCase("1E1", 10d)] // Either case is fine
|
||||||
|
[TestCase("-1e1", -10d)]
|
||||||
|
[TestCase("1.5e1", 15d)]
|
||||||
|
[TestCase("-1.5e1", -15d)]
|
||||||
|
[TestCase("15e-1", 1.5d)]
|
||||||
|
[TestCase("-15e-1", -1.5d)]
|
||||||
|
[TestCase("1.79769e308", 1.79769e308)]
|
||||||
|
[TestCase("-1.79769e308", -1.79769e308)]
|
||||||
|
[TestCase("Infinity", double.PositiveInfinity)]
|
||||||
|
[TestCase("-Infinity", double.NegativeInfinity)]
|
||||||
|
[TestCase("NaN", double.NaN)]
|
||||||
|
public void StringToDouble_Valid(string jsonValue, double expectedParsedValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleDouble\": \"" + jsonValue + "\"}";
|
||||||
|
var parsed = TestAllTypes.Parser.ParseJson(json);
|
||||||
|
Assert.AreEqual(expectedParsedValue, parsed.SingleDouble);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("1.7977e308")]
|
||||||
|
[TestCase("-1.7977e308")]
|
||||||
|
[TestCase("1e309")]
|
||||||
|
[TestCase("1,0")]
|
||||||
|
[TestCase("1.0.0")]
|
||||||
|
[TestCase("+1")]
|
||||||
|
[TestCase("00")]
|
||||||
|
[TestCase("01")]
|
||||||
|
[TestCase("-00")]
|
||||||
|
[TestCase("-01")]
|
||||||
|
[TestCase("--1")]
|
||||||
|
[TestCase(" Infinity")]
|
||||||
|
[TestCase(" -Infinity")]
|
||||||
|
[TestCase("NaN ")]
|
||||||
|
[TestCase("Infinity ")]
|
||||||
|
[TestCase("-Infinity ")]
|
||||||
|
[TestCase(" NaN")]
|
||||||
|
[TestCase("INFINITY")]
|
||||||
|
[TestCase("nan")]
|
||||||
|
[TestCase("\u00BD")] // 1/2 as a single Unicode character. Just sanity checking...
|
||||||
|
public void StringToDouble_Invalid(string jsonValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleDouble\": \"" + jsonValue + "\"}";
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("0", 0f)]
|
||||||
|
[TestCase("1", 1f)]
|
||||||
|
[TestCase("1.000000", 1f)]
|
||||||
|
[TestCase("-1", -1f)]
|
||||||
|
[TestCase("3.402823e38", 3.402823e38f)]
|
||||||
|
[TestCase("-3.402823e38", -3.402823e38f)]
|
||||||
|
[TestCase("1.5e1", 15f)]
|
||||||
|
[TestCase("15e-1", 1.5f)]
|
||||||
|
public void StringToFloat_Valid(string jsonValue, float expectedParsedValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleFloat\": \"" + jsonValue + "\"}";
|
||||||
|
var parsed = TestAllTypes.Parser.ParseJson(json);
|
||||||
|
Assert.AreEqual(expectedParsedValue, parsed.SingleFloat);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("3.402824e38")]
|
||||||
|
[TestCase("-3.402824e38")]
|
||||||
|
[TestCase("1,0")]
|
||||||
|
[TestCase("1.0.0")]
|
||||||
|
[TestCase("+1")]
|
||||||
|
[TestCase("00")]
|
||||||
|
[TestCase("--1")]
|
||||||
|
public void StringToFloat_Invalid(string jsonValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleFloat\": \"" + jsonValue + "\"}";
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("0", 0)]
|
||||||
|
[TestCase("-0", 0)] // Not entirely clear whether we intend to allow this...
|
||||||
|
[TestCase("1", 1)]
|
||||||
|
[TestCase("-1", -1)]
|
||||||
|
[TestCase("2147483647", 2147483647)]
|
||||||
|
[TestCase("-2147483648", -2147483648)]
|
||||||
|
[TestCase("1e1", 10)]
|
||||||
|
[TestCase("-1e1", -10)]
|
||||||
|
[TestCase("10.00", 10)]
|
||||||
|
[TestCase("-10.00", -10)]
|
||||||
|
public void NumberToInt32_Valid(string jsonValue, int expectedParsedValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleInt32\": " + jsonValue + "}";
|
||||||
|
var parsed = TestAllTypes.Parser.ParseJson(json);
|
||||||
|
Assert.AreEqual(expectedParsedValue, parsed.SingleInt32);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("+0", typeof(InvalidJsonException))]
|
||||||
|
[TestCase("00", typeof(InvalidJsonException))]
|
||||||
|
[TestCase("-00", typeof(InvalidJsonException))]
|
||||||
|
[TestCase("--1", typeof(InvalidJsonException))]
|
||||||
|
[TestCase("+1", typeof(InvalidJsonException))]
|
||||||
|
[TestCase("1.5", typeof(InvalidProtocolBufferException))]
|
||||||
|
// Value is out of range
|
||||||
|
[TestCase("1e10", typeof(InvalidProtocolBufferException))]
|
||||||
|
[TestCase("2147483648", typeof(InvalidProtocolBufferException))]
|
||||||
|
[TestCase("-2147483649", typeof(InvalidProtocolBufferException))]
|
||||||
|
public void NumberToInt32_Invalid(string jsonValue, System.Type expectedExceptionType)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleInt32\": " + jsonValue + "}";
|
||||||
|
Assert.Throws(expectedExceptionType, () => TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("0", 0U)]
|
||||||
|
[TestCase("1", 1U)]
|
||||||
|
[TestCase("4294967295", 4294967295U)]
|
||||||
|
public void NumberToUInt32_Valid(string jsonValue, uint expectedParsedValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleUint32\": " + jsonValue + "}";
|
||||||
|
var parsed = TestAllTypes.Parser.ParseJson(json);
|
||||||
|
Assert.AreEqual(expectedParsedValue, parsed.SingleUint32);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assume that anything non-bounds-related is covered in the Int32 case
|
||||||
|
[Test]
|
||||||
|
[TestCase("-1")]
|
||||||
|
[TestCase("4294967296")]
|
||||||
|
public void NumberToUInt32_Invalid(string jsonValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleUint32\": " + jsonValue + "}";
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("0", 0L)]
|
||||||
|
[TestCase("1", 1L)]
|
||||||
|
[TestCase("-1", -1L)]
|
||||||
|
// long.MaxValue isn't actually representable as a double. This string value is the highest
|
||||||
|
// representable value which isn't greater than long.MaxValue.
|
||||||
|
[TestCase("9223372036854774784", 9223372036854774784)]
|
||||||
|
[TestCase("-9223372036854775808", -9223372036854775808)]
|
||||||
|
public void NumberToInt64_Valid(string jsonValue, long expectedParsedValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleInt64\": " + jsonValue + "}";
|
||||||
|
var parsed = TestAllTypes.Parser.ParseJson(json);
|
||||||
|
Assert.AreEqual(expectedParsedValue, parsed.SingleInt64);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assume that anything non-bounds-related is covered in the Int32 case
|
||||||
|
[Test]
|
||||||
|
[TestCase("9223372036854775808")]
|
||||||
|
// Theoretical bound would be -9223372036854775809, but when that is parsed to a double
|
||||||
|
// we end up with the exact value of long.MinValue due to lack of precision. The value here
|
||||||
|
// is the "next double down".
|
||||||
|
[TestCase("-9223372036854780000")]
|
||||||
|
public void NumberToInt64_Invalid(string jsonValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleInt64\": " + jsonValue + "}";
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("0", 0UL)]
|
||||||
|
[TestCase("1", 1UL)]
|
||||||
|
// ulong.MaxValue isn't representable as a double. This value is the largest double within
|
||||||
|
// the range of ulong.
|
||||||
|
[TestCase("18446744073709549568", 18446744073709549568UL)]
|
||||||
|
public void NumberToUInt64_Valid(string jsonValue, ulong expectedParsedValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleUint64\": " + jsonValue + "}";
|
||||||
|
var parsed = TestAllTypes.Parser.ParseJson(json);
|
||||||
|
Assert.AreEqual(expectedParsedValue, parsed.SingleUint64);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assume that anything non-bounds-related is covered in the Int32 case
|
||||||
|
[Test]
|
||||||
|
[TestCase("-1")]
|
||||||
|
[TestCase("18446744073709551616")]
|
||||||
|
public void NumberToUInt64_Invalid(string jsonValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleUint64\": " + jsonValue + "}";
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("0", 0d)]
|
||||||
|
[TestCase("1", 1d)]
|
||||||
|
[TestCase("1.000000", 1d)]
|
||||||
|
[TestCase("1.0000000000000000000000001", 1d)] // We don't notice that we haven't preserved the exact value
|
||||||
|
[TestCase("-1", -1d)]
|
||||||
|
[TestCase("1e1", 10d)]
|
||||||
|
[TestCase("1e01", 10d)] // Leading decimals are allowed in exponents
|
||||||
|
[TestCase("1E1", 10d)] // Either case is fine
|
||||||
|
[TestCase("-1e1", -10d)]
|
||||||
|
[TestCase("1.5e1", 15d)]
|
||||||
|
[TestCase("-1.5e1", -15d)]
|
||||||
|
[TestCase("15e-1", 1.5d)]
|
||||||
|
[TestCase("-15e-1", -1.5d)]
|
||||||
|
[TestCase("1.79769e308", 1.79769e308)]
|
||||||
|
[TestCase("-1.79769e308", -1.79769e308)]
|
||||||
|
public void NumberToDouble_Valid(string jsonValue, double expectedParsedValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleDouble\": " + jsonValue + "}";
|
||||||
|
var parsed = TestAllTypes.Parser.ParseJson(json);
|
||||||
|
Assert.AreEqual(expectedParsedValue, parsed.SingleDouble);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("1.7977e308")]
|
||||||
|
[TestCase("-1.7977e308")]
|
||||||
|
[TestCase("1e309")]
|
||||||
|
[TestCase("1,0")]
|
||||||
|
[TestCase("1.0.0")]
|
||||||
|
[TestCase("+1")]
|
||||||
|
[TestCase("00")]
|
||||||
|
[TestCase("--1")]
|
||||||
|
[TestCase("\u00BD")] // 1/2 as a single Unicode character. Just sanity checking...
|
||||||
|
public void NumberToDouble_Invalid(string jsonValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleDouble\": " + jsonValue + "}";
|
||||||
|
Assert.Throws<InvalidJsonException>(() => TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("0", 0f)]
|
||||||
|
[TestCase("1", 1f)]
|
||||||
|
[TestCase("1.000000", 1f)]
|
||||||
|
[TestCase("-1", -1f)]
|
||||||
|
[TestCase("3.402823e38", 3.402823e38f)]
|
||||||
|
[TestCase("-3.402823e38", -3.402823e38f)]
|
||||||
|
[TestCase("1.5e1", 15f)]
|
||||||
|
[TestCase("15e-1", 1.5f)]
|
||||||
|
public void NumberToFloat_Valid(string jsonValue, float expectedParsedValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleFloat\": " + jsonValue + "}";
|
||||||
|
var parsed = TestAllTypes.Parser.ParseJson(json);
|
||||||
|
Assert.AreEqual(expectedParsedValue, parsed.SingleFloat);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("3.402824e38", typeof(InvalidProtocolBufferException))]
|
||||||
|
[TestCase("-3.402824e38", typeof(InvalidProtocolBufferException))]
|
||||||
|
[TestCase("1,0", typeof(InvalidJsonException))]
|
||||||
|
[TestCase("1.0.0", typeof(InvalidJsonException))]
|
||||||
|
[TestCase("+1", typeof(InvalidJsonException))]
|
||||||
|
[TestCase("00", typeof(InvalidJsonException))]
|
||||||
|
[TestCase("--1", typeof(InvalidJsonException))]
|
||||||
|
public void NumberToFloat_Invalid(string jsonValue, System.Type expectedExceptionType)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleFloat\": " + jsonValue + "}";
|
||||||
|
Assert.Throws(expectedExceptionType, () => TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
// The simplest way of testing that the value has parsed correctly is to reformat it,
|
||||||
|
// as we trust the formatting. In many cases that will give the same result as the input,
|
||||||
|
// so in those cases we accept an expectedFormatted value of null. Sometimes the results
|
||||||
|
// will be different though, due to a different number of digits being provided.
|
||||||
|
[Test]
|
||||||
|
// Z offset
|
||||||
|
[TestCase("2015-10-09T14:46:23.123456789Z", null)]
|
||||||
|
[TestCase("2015-10-09T14:46:23.123456Z", null)]
|
||||||
|
[TestCase("2015-10-09T14:46:23.123Z", null)]
|
||||||
|
[TestCase("2015-10-09T14:46:23Z", null)]
|
||||||
|
[TestCase("2015-10-09T14:46:23.123456000Z", "2015-10-09T14:46:23.123456Z")]
|
||||||
|
[TestCase("2015-10-09T14:46:23.1234560Z", "2015-10-09T14:46:23.123456Z")]
|
||||||
|
[TestCase("2015-10-09T14:46:23.123000000Z", "2015-10-09T14:46:23.123Z")]
|
||||||
|
[TestCase("2015-10-09T14:46:23.1230Z", "2015-10-09T14:46:23.123Z")]
|
||||||
|
[TestCase("2015-10-09T14:46:23.00Z", "2015-10-09T14:46:23Z")]
|
||||||
|
|
||||||
|
// +00:00 offset
|
||||||
|
[TestCase("2015-10-09T14:46:23.123456789+00:00", "2015-10-09T14:46:23.123456789Z")]
|
||||||
|
[TestCase("2015-10-09T14:46:23.123456+00:00", "2015-10-09T14:46:23.123456Z")]
|
||||||
|
[TestCase("2015-10-09T14:46:23.123+00:00", "2015-10-09T14:46:23.123Z")]
|
||||||
|
[TestCase("2015-10-09T14:46:23+00:00", "2015-10-09T14:46:23Z")]
|
||||||
|
[TestCase("2015-10-09T14:46:23.123456000+00:00", "2015-10-09T14:46:23.123456Z")]
|
||||||
|
[TestCase("2015-10-09T14:46:23.1234560+00:00", "2015-10-09T14:46:23.123456Z")]
|
||||||
|
[TestCase("2015-10-09T14:46:23.123000000+00:00", "2015-10-09T14:46:23.123Z")]
|
||||||
|
[TestCase("2015-10-09T14:46:23.1230+00:00", "2015-10-09T14:46:23.123Z")]
|
||||||
|
[TestCase("2015-10-09T14:46:23.00+00:00", "2015-10-09T14:46:23Z")]
|
||||||
|
|
||||||
|
// Other offsets (assume by now that the subsecond handling is okay)
|
||||||
|
[TestCase("2015-10-09T15:46:23.123456789+01:00", "2015-10-09T14:46:23.123456789Z")]
|
||||||
|
[TestCase("2015-10-09T13:46:23.123456789-01:00", "2015-10-09T14:46:23.123456789Z")]
|
||||||
|
[TestCase("2015-10-09T15:16:23.123456789+00:30", "2015-10-09T14:46:23.123456789Z")]
|
||||||
|
[TestCase("2015-10-09T14:16:23.123456789-00:30", "2015-10-09T14:46:23.123456789Z")]
|
||||||
|
[TestCase("2015-10-09T16:31:23.123456789+01:45", "2015-10-09T14:46:23.123456789Z")]
|
||||||
|
[TestCase("2015-10-09T13:01:23.123456789-01:45", "2015-10-09T14:46:23.123456789Z")]
|
||||||
|
[TestCase("2015-10-10T08:46:23.123456789+18:00", "2015-10-09T14:46:23.123456789Z")]
|
||||||
|
[TestCase("2015-10-08T20:46:23.123456789-18:00", "2015-10-09T14:46:23.123456789Z")]
|
||||||
|
|
||||||
|
// Leap years and min/max
|
||||||
|
[TestCase("2016-02-29T14:46:23.123456789Z", null)]
|
||||||
|
[TestCase("2000-02-29T14:46:23.123456789Z", null)]
|
||||||
|
[TestCase("0001-01-01T00:00:00Z", null)]
|
||||||
|
[TestCase("9999-12-31T23:59:59.999999999Z", null)]
|
||||||
|
public void Timestamp_Valid(string jsonValue, string expectedFormatted)
|
||||||
|
{
|
||||||
|
expectedFormatted = expectedFormatted ?? jsonValue;
|
||||||
|
string json = WrapInQuotes(jsonValue);
|
||||||
|
var parsed = Timestamp.Parser.ParseJson(json);
|
||||||
|
Assert.AreEqual(WrapInQuotes(expectedFormatted), parsed.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("2015-10-09 14:46:23.123456789Z", Description = "No T between date and time")]
|
||||||
|
[TestCase("2015/10/09T14:46:23.123456789Z", Description = "Wrong date separators")]
|
||||||
|
[TestCase("2015-10-09T14.46.23.123456789Z", Description = "Wrong time separators")]
|
||||||
|
[TestCase("2015-10-09T14:46:23,123456789Z", Description = "Wrong fractional second separators (valid ISO-8601 though)")]
|
||||||
|
[TestCase(" 2015-10-09T14:46:23.123456789Z", Description = "Whitespace at start")]
|
||||||
|
[TestCase("2015-10-09T14:46:23.123456789Z ", Description = "Whitespace at end")]
|
||||||
|
[TestCase("2015-10-09T14:46:23.1234567890", Description = "Too many digits")]
|
||||||
|
[TestCase("2015-10-09T14:46:23.123456789", Description = "No offset")]
|
||||||
|
[TestCase("2015-13-09T14:46:23.123456789Z", Description = "Invalid month")]
|
||||||
|
[TestCase("2015-10-32T14:46:23.123456789Z", Description = "Invalid day")]
|
||||||
|
[TestCase("2015-10-09T24:00:00.000000000Z", Description = "Invalid hour (valid ISO-8601 though)")]
|
||||||
|
[TestCase("2015-10-09T14:60:23.123456789Z", Description = "Invalid minutes")]
|
||||||
|
[TestCase("2015-10-09T14:46:60.123456789Z", Description = "Invalid seconds")]
|
||||||
|
[TestCase("2015-10-09T14:46:23.123456789+18:01", Description = "Offset too large (positive)")]
|
||||||
|
[TestCase("2015-10-09T14:46:23.123456789-18:01", Description = "Offset too large (negative)")]
|
||||||
|
[TestCase("2015-10-09T14:46:23.123456789-00:00", Description = "Local offset (-00:00) makes no sense here")]
|
||||||
|
[TestCase("0001-01-01T00:00:00+00:01", Description = "Value before earliest when offset applied")]
|
||||||
|
[TestCase("9999-12-31T23:59:59.999999999-00:01", Description = "Value after latest when offset applied")]
|
||||||
|
[TestCase("2100-02-29T14:46:23.123456789Z", Description = "Feb 29th on a non-leap-year")]
|
||||||
|
public void Timestamp_Invalid(string jsonValue)
|
||||||
|
{
|
||||||
|
string json = WrapInQuotes(jsonValue);
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => Timestamp.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void StructValue_Null()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(new Value { NullValue = 0 }, Value.Parser.ParseJson("null"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void StructValue_String()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(new Value { StringValue = "hi" }, Value.Parser.ParseJson("\"hi\""));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void StructValue_Bool()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(new Value { BoolValue = true }, Value.Parser.ParseJson("true"));
|
||||||
|
Assert.AreEqual(new Value { BoolValue = false }, Value.Parser.ParseJson("false"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void StructValue_List()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(Value.ForList(Value.ForNumber(1), Value.ForString("x")), Value.Parser.ParseJson("[1, \"x\"]"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ParseListValue()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(new ListValue { Values = { Value.ForNumber(1), Value.ForString("x") } }, ListValue.Parser.ParseJson("[1, \"x\"]"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void StructValue_Struct()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(
|
||||||
|
Value.ForStruct(new Struct { Fields = { { "x", Value.ForNumber(1) }, { "y", Value.ForString("z") } } }),
|
||||||
|
Value.Parser.ParseJson("{ \"x\": 1, \"y\": \"z\" }"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ParseStruct()
|
||||||
|
{
|
||||||
|
Assert.AreEqual(new Struct { Fields = { { "x", Value.ForNumber(1) }, { "y", Value.ForString("z") } } },
|
||||||
|
Struct.Parser.ParseJson("{ \"x\": 1, \"y\": \"z\" }"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO for duration parsing: upper and lower bounds.
|
||||||
|
// +/- 315576000000 seconds
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("1.123456789s", null)]
|
||||||
|
[TestCase("1.123456s", null)]
|
||||||
|
[TestCase("1.123s", null)]
|
||||||
|
[TestCase("1.12300s", "1.123s")]
|
||||||
|
[TestCase("1.12345s", "1.123450s")]
|
||||||
|
[TestCase("1s", null)]
|
||||||
|
[TestCase("-1.123456789s", null)]
|
||||||
|
[TestCase("-1.123456s", null)]
|
||||||
|
[TestCase("-1.123s", null)]
|
||||||
|
[TestCase("-1s", null)]
|
||||||
|
[TestCase("0.123s", null)]
|
||||||
|
[TestCase("-0.123s", null)]
|
||||||
|
[TestCase("123456.123s", null)]
|
||||||
|
[TestCase("-123456.123s", null)]
|
||||||
|
// Upper and lower bounds
|
||||||
|
[TestCase("315576000000s", null)]
|
||||||
|
[TestCase("-315576000000s", null)]
|
||||||
|
public void Duration_Valid(string jsonValue, string expectedFormatted)
|
||||||
|
{
|
||||||
|
expectedFormatted = expectedFormatted ?? jsonValue;
|
||||||
|
string json = WrapInQuotes(jsonValue);
|
||||||
|
var parsed = Duration.Parser.ParseJson(json);
|
||||||
|
Assert.AreEqual(WrapInQuotes(expectedFormatted), parsed.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
// The simplest way of testing that the value has parsed correctly is to reformat it,
|
||||||
|
// as we trust the formatting. In many cases that will give the same result as the input,
|
||||||
|
// so in those cases we accept an expectedFormatted value of null. Sometimes the results
|
||||||
|
// will be different though, due to a different number of digits being provided.
|
||||||
|
[Test]
|
||||||
|
[TestCase("1.1234567890s", Description = "Too many digits")]
|
||||||
|
[TestCase("1.123456789", Description = "No suffix")]
|
||||||
|
[TestCase("1.123456789ss", Description = "Too much suffix")]
|
||||||
|
[TestCase("1.123456789S", Description = "Upper case suffix")]
|
||||||
|
[TestCase("+1.123456789s", Description = "Leading +")]
|
||||||
|
[TestCase(".123456789s", Description = "No integer before the fraction")]
|
||||||
|
[TestCase("1,123456789s", Description = "Comma as decimal separator")]
|
||||||
|
[TestCase("1x1.123456789s", Description = "Non-digit in integer part")]
|
||||||
|
[TestCase("1.1x3456789s", Description = "Non-digit in fractional part")]
|
||||||
|
[TestCase(" 1.123456789s", Description = "Whitespace before fraction")]
|
||||||
|
[TestCase("1.123456789s ", Description = "Whitespace after value")]
|
||||||
|
[TestCase("01.123456789s", Description = "Leading zero (positive)")]
|
||||||
|
[TestCase("-01.123456789s", Description = "Leading zero (negative)")]
|
||||||
|
[TestCase("--0.123456789s", Description = "Double minus sign")]
|
||||||
|
// Violate upper/lower bounds in various ways
|
||||||
|
[TestCase("315576000001s", Description = "Integer part too large")]
|
||||||
|
[TestCase("3155760000000s", Description = "Integer part too long (positive)")]
|
||||||
|
[TestCase("-3155760000000s", Description = "Integer part too long (negative)")]
|
||||||
|
public void Duration_Invalid(string jsonValue)
|
||||||
|
{
|
||||||
|
string json = WrapInQuotes(jsonValue);
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => Duration.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Not as many tests for field masks as I'd like; more to be added when we have more
|
||||||
|
// detailed specifications.
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("")]
|
||||||
|
[TestCase("foo", "foo")]
|
||||||
|
[TestCase("foo,bar", "foo", "bar")]
|
||||||
|
[TestCase("foo.bar", "foo.bar")]
|
||||||
|
[TestCase("fooBar", "foo_bar")]
|
||||||
|
[TestCase("fooBar.bazQux", "foo_bar.baz_qux")]
|
||||||
|
public void FieldMask_Valid(string jsonValue, params string[] expectedPaths)
|
||||||
|
{
|
||||||
|
string json = WrapInQuotes(jsonValue);
|
||||||
|
var parsed = FieldMask.Parser.ParseJson(json);
|
||||||
|
CollectionAssert.AreEqual(expectedPaths, parsed.Paths);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("foo_bar")]
|
||||||
|
public void FieldMask_Invalid(string jsonValue)
|
||||||
|
{
|
||||||
|
string json = WrapInQuotes(jsonValue);
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => FieldMask.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Any_RegularMessage()
|
||||||
|
{
|
||||||
|
var registry = TypeRegistry.FromMessages(TestAllTypes.Descriptor);
|
||||||
|
var formatter = new JsonFormatter(new JsonFormatter.Settings(false, TypeRegistry.FromMessages(TestAllTypes.Descriptor)));
|
||||||
|
var message = new TestAllTypes { SingleInt32 = 10, SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 } };
|
||||||
|
var original = Any.Pack(message);
|
||||||
|
var json = formatter.Format(original); // This is tested in JsonFormatterTest
|
||||||
|
var parser = new JsonParser(new JsonParser.Settings(10, registry));
|
||||||
|
Assert.AreEqual(original, parser.Parse<Any>(json));
|
||||||
|
string valueFirstJson = "{ \"singleInt32\": 10, \"singleNestedMessage\": { \"bb\": 20 }, \"@type\": \"type.googleapis.com/protobuf_unittest.TestAllTypes\" }";
|
||||||
|
Assert.AreEqual(original, parser.Parse<Any>(valueFirstJson));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Any_CustomPrefix()
|
||||||
|
{
|
||||||
|
var registry = TypeRegistry.FromMessages(TestAllTypes.Descriptor);
|
||||||
|
var message = new TestAllTypes { SingleInt32 = 10 };
|
||||||
|
var original = Any.Pack(message, "custom.prefix/middle-part");
|
||||||
|
var parser = new JsonParser(new JsonParser.Settings(10, registry));
|
||||||
|
string json = "{ \"@type\": \"custom.prefix/middle-part/protobuf_unittest.TestAllTypes\", \"singleInt32\": 10 }";
|
||||||
|
Assert.AreEqual(original, parser.Parse<Any>(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Any_UnknownType()
|
||||||
|
{
|
||||||
|
string json = "{ \"@type\": \"type.googleapis.com/bogus\" }";
|
||||||
|
Assert.Throws<InvalidOperationException>(() => Any.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Any_NoTypeUrl()
|
||||||
|
{
|
||||||
|
string json = "{ \"foo\": \"bar\" }";
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => Any.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Any_WellKnownType()
|
||||||
|
{
|
||||||
|
var registry = TypeRegistry.FromMessages(Timestamp.Descriptor);
|
||||||
|
var formatter = new JsonFormatter(new JsonFormatter.Settings(false, registry));
|
||||||
|
var timestamp = new DateTime(1673, 6, 19, 12, 34, 56, DateTimeKind.Utc).ToTimestamp();
|
||||||
|
var original = Any.Pack(timestamp);
|
||||||
|
var json = formatter.Format(original); // This is tested in JsonFormatterTest
|
||||||
|
var parser = new JsonParser(new JsonParser.Settings(10, registry));
|
||||||
|
Assert.AreEqual(original, parser.Parse<Any>(json));
|
||||||
|
string valueFirstJson = "{ \"value\": \"1673-06-19T12:34:56Z\", \"@type\": \"type.googleapis.com/google.protobuf.Timestamp\" }";
|
||||||
|
Assert.AreEqual(original, parser.Parse<Any>(valueFirstJson));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Any_Nested()
|
||||||
|
{
|
||||||
|
var registry = TypeRegistry.FromMessages(TestWellKnownTypes.Descriptor, TestAllTypes.Descriptor);
|
||||||
|
var formatter = new JsonFormatter(new JsonFormatter.Settings(false, registry));
|
||||||
|
var parser = new JsonParser(new JsonParser.Settings(10, registry));
|
||||||
|
var doubleNestedMessage = new TestAllTypes { SingleInt32 = 20 };
|
||||||
|
var nestedMessage = Any.Pack(doubleNestedMessage);
|
||||||
|
var message = new TestWellKnownTypes { AnyField = Any.Pack(nestedMessage) };
|
||||||
|
var json = formatter.Format(message);
|
||||||
|
// Use the descriptor-based parser just for a change.
|
||||||
|
Assert.AreEqual(message, parser.Parse(json, TestWellKnownTypes.Descriptor));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DataAfterObject()
|
||||||
|
{
|
||||||
|
string json = "{} 10";
|
||||||
|
Assert.Throws<InvalidJsonException>(() => TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// JSON equivalent to <see cref="CodedInputStreamTest.MaliciousRecursion"/>
|
||||||
|
/// </summary>
|
||||||
|
[Test]
|
||||||
|
public void MaliciousRecursion()
|
||||||
|
{
|
||||||
|
string data64 = CodedInputStreamTest.MakeRecursiveMessage(64).ToString();
|
||||||
|
string data65 = CodedInputStreamTest.MakeRecursiveMessage(65).ToString();
|
||||||
|
|
||||||
|
var parser64 = new JsonParser(new JsonParser.Settings(64));
|
||||||
|
CodedInputStreamTest.AssertMessageDepth(parser64.Parse<TestRecursiveMessage>(data64), 64);
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => parser64.Parse<TestRecursiveMessage>(data65));
|
||||||
|
|
||||||
|
var parser63 = new JsonParser(new JsonParser.Settings(63));
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => parser63.Parse<TestRecursiveMessage>(data64));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("AQI")]
|
||||||
|
[TestCase("_-==")]
|
||||||
|
public void Bytes_InvalidBase64(string badBase64)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleBytes\": \"" + badBase64 + "\" }";
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("\"FOREIGN_BAR\"", ForeignEnum.ForeignBar)]
|
||||||
|
[TestCase("5", ForeignEnum.ForeignBar)]
|
||||||
|
[TestCase("100", (ForeignEnum)100)]
|
||||||
|
public void EnumValid(string value, ForeignEnum expectedValue)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleForeignEnum\": " + value + " }";
|
||||||
|
var parsed = TestAllTypes.Parser.ParseJson(json);
|
||||||
|
Assert.AreEqual(new TestAllTypes { SingleForeignEnum = expectedValue }, parsed);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("\"NOT_A_VALID_VALUE\"")]
|
||||||
|
[TestCase("5.5")]
|
||||||
|
public void Enum_Invalid(string value)
|
||||||
|
{
|
||||||
|
string json = "{ \"singleForeignEnum\": " + value + " }";
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void OneofDuplicate_Invalid()
|
||||||
|
{
|
||||||
|
string json = "{ \"oneofString\": \"x\", \"oneofUint32\": 10 }";
|
||||||
|
Assert.Throws<InvalidProtocolBufferException>(() => TestAllTypes.Parser.ParseJson(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Various tests use strings which have quotes round them for parsing or as the result
|
||||||
|
/// of formatting, but without those quotes being specified in the tests (for the sake of readability).
|
||||||
|
/// This method simply returns the input, wrapped in double quotes.
|
||||||
|
/// </summary>
|
||||||
|
internal static string WrapInQuotes(string text)
|
||||||
|
{
|
||||||
|
return '"' + text + '"';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,408 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// 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.
|
||||||
|
#endregion
|
||||||
|
using NUnit.Framework;
|
||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace Google.Protobuf
|
||||||
|
{
|
||||||
|
public class JsonTokenizerTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void EmptyObjectValue()
|
||||||
|
{
|
||||||
|
AssertTokens("{}", JsonToken.StartObject, JsonToken.EndObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EmptyArrayValue()
|
||||||
|
{
|
||||||
|
AssertTokens("[]", JsonToken.StartArray, JsonToken.EndArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("foo", "foo")]
|
||||||
|
[TestCase("tab\\t", "tab\t")]
|
||||||
|
[TestCase("line\\nfeed", "line\nfeed")]
|
||||||
|
[TestCase("carriage\\rreturn", "carriage\rreturn")]
|
||||||
|
[TestCase("back\\bspace", "back\bspace")]
|
||||||
|
[TestCase("form\\ffeed", "form\ffeed")]
|
||||||
|
[TestCase("escaped\\/slash", "escaped/slash")]
|
||||||
|
[TestCase("escaped\\\\backslash", "escaped\\backslash")]
|
||||||
|
[TestCase("escaped\\\"quote", "escaped\"quote")]
|
||||||
|
[TestCase("foo {}[] bar", "foo {}[] bar")]
|
||||||
|
[TestCase("foo\\u09aFbar", "foo\u09afbar")] // Digits, upper hex, lower hex
|
||||||
|
[TestCase("ab\ud800\udc00cd", "ab\ud800\udc00cd")]
|
||||||
|
[TestCase("ab\\ud800\\udc00cd", "ab\ud800\udc00cd")]
|
||||||
|
public void StringValue(string json, string expectedValue)
|
||||||
|
{
|
||||||
|
AssertTokensNoReplacement("\"" + json + "\"", JsonToken.Value(expectedValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Valid surrogate pairs, with mixed escaping. These test cases can't be expressed
|
||||||
|
// using TestCase as they have no valid UTF-8 representation.
|
||||||
|
// It's unclear exactly how we should handle a mixture of escaped or not: that can't
|
||||||
|
// come from UTF-8 text, but could come from a .NET string. For the moment,
|
||||||
|
// treat it as valid in the obvious way.
|
||||||
|
[Test]
|
||||||
|
public void MixedSurrogatePairs()
|
||||||
|
{
|
||||||
|
string expected = "\ud800\udc00";
|
||||||
|
AssertTokens("'\\ud800\udc00'", JsonToken.Value(expected));
|
||||||
|
AssertTokens("'\ud800\\udc00'", JsonToken.Value(expected));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ObjectDepth()
|
||||||
|
{
|
||||||
|
string json = "{ \"foo\": { \"x\": 1, \"y\": [ 0 ] } }";
|
||||||
|
var tokenizer = JsonTokenizer.FromTextReader(new StringReader(json));
|
||||||
|
// If we had more tests like this, I'd introduce a helper method... but for one test, it's not worth it.
|
||||||
|
Assert.AreEqual(0, tokenizer.ObjectDepth);
|
||||||
|
Assert.AreEqual(JsonToken.StartObject, tokenizer.Next());
|
||||||
|
Assert.AreEqual(1, tokenizer.ObjectDepth);
|
||||||
|
Assert.AreEqual(JsonToken.Name("foo"), tokenizer.Next());
|
||||||
|
Assert.AreEqual(1, tokenizer.ObjectDepth);
|
||||||
|
Assert.AreEqual(JsonToken.StartObject, tokenizer.Next());
|
||||||
|
Assert.AreEqual(2, tokenizer.ObjectDepth);
|
||||||
|
Assert.AreEqual(JsonToken.Name("x"), tokenizer.Next());
|
||||||
|
Assert.AreEqual(2, tokenizer.ObjectDepth);
|
||||||
|
Assert.AreEqual(JsonToken.Value(1), tokenizer.Next());
|
||||||
|
Assert.AreEqual(2, tokenizer.ObjectDepth);
|
||||||
|
Assert.AreEqual(JsonToken.Name("y"), tokenizer.Next());
|
||||||
|
Assert.AreEqual(2, tokenizer.ObjectDepth);
|
||||||
|
Assert.AreEqual(JsonToken.StartArray, tokenizer.Next());
|
||||||
|
Assert.AreEqual(2, tokenizer.ObjectDepth); // Depth hasn't changed in array
|
||||||
|
Assert.AreEqual(JsonToken.Value(0), tokenizer.Next());
|
||||||
|
Assert.AreEqual(2, tokenizer.ObjectDepth);
|
||||||
|
Assert.AreEqual(JsonToken.EndArray, tokenizer.Next());
|
||||||
|
Assert.AreEqual(2, tokenizer.ObjectDepth);
|
||||||
|
Assert.AreEqual(JsonToken.EndObject, tokenizer.Next());
|
||||||
|
Assert.AreEqual(1, tokenizer.ObjectDepth);
|
||||||
|
Assert.AreEqual(JsonToken.EndObject, tokenizer.Next());
|
||||||
|
Assert.AreEqual(0, tokenizer.ObjectDepth);
|
||||||
|
Assert.AreEqual(JsonToken.EndDocument, tokenizer.Next());
|
||||||
|
Assert.AreEqual(0, tokenizer.ObjectDepth);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ObjectDepth_WithPushBack()
|
||||||
|
{
|
||||||
|
string json = "{}";
|
||||||
|
var tokenizer = JsonTokenizer.FromTextReader(new StringReader(json));
|
||||||
|
Assert.AreEqual(0, tokenizer.ObjectDepth);
|
||||||
|
var token = tokenizer.Next();
|
||||||
|
Assert.AreEqual(1, tokenizer.ObjectDepth);
|
||||||
|
// When we push back a "start object", we should effectively be back to the previous depth.
|
||||||
|
tokenizer.PushBack(token);
|
||||||
|
Assert.AreEqual(0, tokenizer.ObjectDepth);
|
||||||
|
// Read the same token again, and get back to depth 1
|
||||||
|
token = tokenizer.Next();
|
||||||
|
Assert.AreEqual(1, tokenizer.ObjectDepth);
|
||||||
|
|
||||||
|
// Now the same in reverse, with EndObject
|
||||||
|
token = tokenizer.Next();
|
||||||
|
Assert.AreEqual(0, tokenizer.ObjectDepth);
|
||||||
|
tokenizer.PushBack(token);
|
||||||
|
Assert.AreEqual(1, tokenizer.ObjectDepth);
|
||||||
|
tokenizer.Next();
|
||||||
|
Assert.AreEqual(0, tokenizer.ObjectDepth);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("embedded tab\t")]
|
||||||
|
[TestCase("embedded CR\r")]
|
||||||
|
[TestCase("embedded LF\n")]
|
||||||
|
[TestCase("embedded bell\u0007")]
|
||||||
|
[TestCase("bad escape\\a")]
|
||||||
|
[TestCase("incomplete escape\\")]
|
||||||
|
[TestCase("incomplete Unicode escape\\u000")]
|
||||||
|
[TestCase("invalid Unicode escape\\u000H")]
|
||||||
|
// Surrogate pair handling, both in raw .NET strings and escaped. We only need
|
||||||
|
// to detect this in strings, as non-ASCII characters anywhere other than in strings
|
||||||
|
// will already lead to parsing errors.
|
||||||
|
[TestCase("\\ud800")]
|
||||||
|
[TestCase("\\udc00")]
|
||||||
|
[TestCase("\\ud800x")]
|
||||||
|
[TestCase("\\udc00x")]
|
||||||
|
[TestCase("\\udc00\\ud800y")]
|
||||||
|
public void InvalidStringValue(string json)
|
||||||
|
{
|
||||||
|
AssertThrowsAfter("\"" + json + "\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tests for invalid strings that can't be expressed in attributes,
|
||||||
|
// as the constants can't be expressed as UTF-8 strings.
|
||||||
|
[Test]
|
||||||
|
public void InvalidSurrogatePairs()
|
||||||
|
{
|
||||||
|
AssertThrowsAfter("\"\ud800x\"");
|
||||||
|
AssertThrowsAfter("\"\udc00y\"");
|
||||||
|
AssertThrowsAfter("\"\udc00\ud800y\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("0", 0)]
|
||||||
|
[TestCase("-0", 0)] // We don't distinguish between positive and negative 0
|
||||||
|
[TestCase("1", 1)]
|
||||||
|
[TestCase("-1", -1)]
|
||||||
|
// From here on, assume leading sign is okay...
|
||||||
|
[TestCase("1.125", 1.125)]
|
||||||
|
[TestCase("1.0", 1)]
|
||||||
|
[TestCase("1e5", 100000)]
|
||||||
|
[TestCase("1e000000", 1)] // Weird, but not prohibited by the spec
|
||||||
|
[TestCase("1E5", 100000)]
|
||||||
|
[TestCase("1e+5", 100000)]
|
||||||
|
[TestCase("1E-5", 0.00001)]
|
||||||
|
[TestCase("123E-2", 1.23)]
|
||||||
|
[TestCase("123.45E3", 123450)]
|
||||||
|
[TestCase(" 1 ", 1)]
|
||||||
|
public void NumberValue(string json, double expectedValue)
|
||||||
|
{
|
||||||
|
AssertTokens(json, JsonToken.Value(expectedValue));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("00")]
|
||||||
|
[TestCase(".5")]
|
||||||
|
[TestCase("1.")]
|
||||||
|
[TestCase("1e")]
|
||||||
|
[TestCase("1e-")]
|
||||||
|
[TestCase("--")]
|
||||||
|
[TestCase("--1")]
|
||||||
|
[TestCase("-1.7977e308")]
|
||||||
|
[TestCase("1.7977e308")]
|
||||||
|
public void InvalidNumberValue(string json)
|
||||||
|
{
|
||||||
|
AssertThrowsAfter(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("nul")]
|
||||||
|
[TestCase("nothing")]
|
||||||
|
[TestCase("truth")]
|
||||||
|
[TestCase("fALSEhood")]
|
||||||
|
public void InvalidLiterals(string json)
|
||||||
|
{
|
||||||
|
AssertThrowsAfter(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void NullValue()
|
||||||
|
{
|
||||||
|
AssertTokens("null", JsonToken.Null);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TrueValue()
|
||||||
|
{
|
||||||
|
AssertTokens("true", JsonToken.True);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void FalseValue()
|
||||||
|
{
|
||||||
|
AssertTokens("false", JsonToken.False);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SimpleObject()
|
||||||
|
{
|
||||||
|
AssertTokens("{'x': 'y'}",
|
||||||
|
JsonToken.StartObject, JsonToken.Name("x"), JsonToken.Value("y"), JsonToken.EndObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
[TestCase("[10, 20", 3)]
|
||||||
|
[TestCase("[10,", 2)]
|
||||||
|
[TestCase("[10:20]", 2)]
|
||||||
|
[TestCase("[", 1)]
|
||||||
|
[TestCase("[,", 1)]
|
||||||
|
[TestCase("{", 1)]
|
||||||
|
[TestCase("{,", 1)]
|
||||||
|
[TestCase("{[", 1)]
|
||||||
|
[TestCase("{{", 1)]
|
||||||
|
[TestCase("{0", 1)]
|
||||||
|
[TestCase("{null", 1)]
|
||||||
|
[TestCase("{false", 1)]
|
||||||
|
[TestCase("{true", 1)]
|
||||||
|
[TestCase("}", 0)]
|
||||||
|
[TestCase("]", 0)]
|
||||||
|
[TestCase(",", 0)]
|
||||||
|
[TestCase("'foo' 'bar'", 1)]
|
||||||
|
[TestCase(":", 0)]
|
||||||
|
[TestCase("'foo", 0)] // Incomplete string
|
||||||
|
[TestCase("{ 'foo' }", 2)]
|
||||||
|
[TestCase("{ x:1", 1)] // Property names must be quoted
|
||||||
|
[TestCase("{]", 1)]
|
||||||
|
[TestCase("[}", 1)]
|
||||||
|
[TestCase("[1,", 2)]
|
||||||
|
[TestCase("{'x':0]", 3)]
|
||||||
|
[TestCase("{ 'foo': }", 2)]
|
||||||
|
[TestCase("{ 'foo':'bar', }", 3)]
|
||||||
|
public void InvalidStructure(string json, int expectedValidTokens)
|
||||||
|
{
|
||||||
|
// Note: we don't test that the earlier tokens are exactly as expected,
|
||||||
|
// partly because that's hard to parameterize.
|
||||||
|
var reader = new StringReader(json.Replace('\'', '"'));
|
||||||
|
var tokenizer = JsonTokenizer.FromTextReader(reader);
|
||||||
|
for (int i = 0; i < expectedValidTokens; i++)
|
||||||
|
{
|
||||||
|
Assert.IsNotNull(tokenizer.Next());
|
||||||
|
}
|
||||||
|
Assert.Throws<InvalidJsonException>(() => tokenizer.Next());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ArrayMixedType()
|
||||||
|
{
|
||||||
|
AssertTokens("[1, 'foo', null, false, true, [2], {'x':'y' }]",
|
||||||
|
JsonToken.StartArray,
|
||||||
|
JsonToken.Value(1),
|
||||||
|
JsonToken.Value("foo"),
|
||||||
|
JsonToken.Null,
|
||||||
|
JsonToken.False,
|
||||||
|
JsonToken.True,
|
||||||
|
JsonToken.StartArray,
|
||||||
|
JsonToken.Value(2),
|
||||||
|
JsonToken.EndArray,
|
||||||
|
JsonToken.StartObject,
|
||||||
|
JsonToken.Name("x"),
|
||||||
|
JsonToken.Value("y"),
|
||||||
|
JsonToken.EndObject,
|
||||||
|
JsonToken.EndArray);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void ObjectMixedType()
|
||||||
|
{
|
||||||
|
AssertTokens(@"{'a': 1, 'b': 'bar', 'c': null, 'd': false, 'e': true,
|
||||||
|
'f': [2], 'g': {'x':'y' }}",
|
||||||
|
JsonToken.StartObject,
|
||||||
|
JsonToken.Name("a"),
|
||||||
|
JsonToken.Value(1),
|
||||||
|
JsonToken.Name("b"),
|
||||||
|
JsonToken.Value("bar"),
|
||||||
|
JsonToken.Name("c"),
|
||||||
|
JsonToken.Null,
|
||||||
|
JsonToken.Name("d"),
|
||||||
|
JsonToken.False,
|
||||||
|
JsonToken.Name("e"),
|
||||||
|
JsonToken.True,
|
||||||
|
JsonToken.Name("f"),
|
||||||
|
JsonToken.StartArray,
|
||||||
|
JsonToken.Value(2),
|
||||||
|
JsonToken.EndArray,
|
||||||
|
JsonToken.Name("g"),
|
||||||
|
JsonToken.StartObject,
|
||||||
|
JsonToken.Name("x"),
|
||||||
|
JsonToken.Value("y"),
|
||||||
|
JsonToken.EndObject,
|
||||||
|
JsonToken.EndObject);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void NextAfterEndDocumentThrows()
|
||||||
|
{
|
||||||
|
var tokenizer = JsonTokenizer.FromTextReader(new StringReader("null"));
|
||||||
|
Assert.AreEqual(JsonToken.Null, tokenizer.Next());
|
||||||
|
Assert.AreEqual(JsonToken.EndDocument, tokenizer.Next());
|
||||||
|
Assert.Throws<InvalidOperationException>(() => tokenizer.Next());
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void CanPushBackEndDocument()
|
||||||
|
{
|
||||||
|
var tokenizer = JsonTokenizer.FromTextReader(new StringReader("null"));
|
||||||
|
Assert.AreEqual(JsonToken.Null, tokenizer.Next());
|
||||||
|
Assert.AreEqual(JsonToken.EndDocument, tokenizer.Next());
|
||||||
|
tokenizer.PushBack(JsonToken.EndDocument);
|
||||||
|
Assert.AreEqual(JsonToken.EndDocument, tokenizer.Next());
|
||||||
|
Assert.Throws<InvalidOperationException>(() => tokenizer.Next());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asserts that the specified JSON is tokenized into the given sequence of tokens.
|
||||||
|
/// All apostrophes are first converted to double quotes, allowing any tests
|
||||||
|
/// that don't need to check actual apostrophe handling to use apostrophes in the JSON, avoiding
|
||||||
|
/// messy string literal escaping. The "end document" token is not specified in the list of
|
||||||
|
/// expected tokens, but is implicit.
|
||||||
|
/// </summary>
|
||||||
|
private static void AssertTokens(string json, params JsonToken[] expectedTokens)
|
||||||
|
{
|
||||||
|
AssertTokensNoReplacement(json.Replace('\'', '"'), expectedTokens);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Asserts that the specified JSON is tokenized into the given sequence of tokens.
|
||||||
|
/// Unlike <see cref="AssertTokens(string, JsonToken[])"/>, this does not perform any character
|
||||||
|
/// replacement on the specified JSON, and should be used when the text contains apostrophes which
|
||||||
|
/// are expected to be used *as* apostrophes. The "end document" token is not specified in the list of
|
||||||
|
/// expected tokens, but is implicit.
|
||||||
|
/// </summary>
|
||||||
|
private static void AssertTokensNoReplacement(string json, params JsonToken[] expectedTokens)
|
||||||
|
{
|
||||||
|
var reader = new StringReader(json);
|
||||||
|
var tokenizer = JsonTokenizer.FromTextReader(reader);
|
||||||
|
for (int i = 0; i < expectedTokens.Length; i++)
|
||||||
|
{
|
||||||
|
var actualToken = tokenizer.Next();
|
||||||
|
if (actualToken == JsonToken.EndDocument)
|
||||||
|
{
|
||||||
|
Assert.Fail("Expected {0} but reached end of token stream", expectedTokens[i]);
|
||||||
|
}
|
||||||
|
Assert.AreEqual(expectedTokens[i], actualToken);
|
||||||
|
}
|
||||||
|
var finalToken = tokenizer.Next();
|
||||||
|
if (finalToken != JsonToken.EndDocument)
|
||||||
|
{
|
||||||
|
Assert.Fail("Expected token stream to be exhausted; received {0}", finalToken);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void AssertThrowsAfter(string json, params JsonToken[] expectedTokens)
|
||||||
|
{
|
||||||
|
var reader = new StringReader(json);
|
||||||
|
var tokenizer = JsonTokenizer.FromTextReader(reader);
|
||||||
|
for (int i = 0; i < expectedTokens.Length; i++)
|
||||||
|
{
|
||||||
|
var actualToken = tokenizer.Next();
|
||||||
|
if (actualToken == JsonToken.EndDocument)
|
||||||
|
{
|
||||||
|
Assert.Fail("Expected {0} but reached end of document", expectedTokens[i]);
|
||||||
|
}
|
||||||
|
Assert.AreEqual(expectedTokens[i], actualToken);
|
||||||
|
}
|
||||||
|
Assert.Throws<InvalidJsonException>(() => tokenizer.Next());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2017 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.
|
||||||
|
#endregion
|
||||||
|
using NUnitLite;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
// Note: this file wasn't in the actual 3.0, but is required due to build
|
||||||
|
// system changes
|
||||||
|
|
||||||
|
namespace Google.Protobuf.Test
|
||||||
|
{
|
||||||
|
class Program
|
||||||
|
{
|
||||||
|
public static int Main(string[] args)
|
||||||
|
{
|
||||||
|
return new AutoRun(typeof(Program).GetTypeInfo().Assembly).Execute(args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,259 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// 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.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
using Google.Protobuf.TestProtos;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using UnitTest.Issues.TestProtos;
|
||||||
|
|
||||||
|
namespace Google.Protobuf.Reflection
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Tests for descriptors. (Not in its own namespace or broken up into individual classes as the
|
||||||
|
/// size doesn't warrant it. On the other hand, this makes me feel a bit dirty...)
|
||||||
|
/// </summary>
|
||||||
|
public class DescriptorsTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void FileDescriptor()
|
||||||
|
{
|
||||||
|
FileDescriptor file = UnittestProto3Reflection.Descriptor;
|
||||||
|
|
||||||
|
Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Name);
|
||||||
|
Assert.AreEqual("protobuf_unittest", file.Package);
|
||||||
|
|
||||||
|
Assert.AreEqual("UnittestProto", file.Proto.Options.JavaOuterClassname);
|
||||||
|
Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Proto.Name);
|
||||||
|
|
||||||
|
// unittest.proto doesn't have any public imports, but unittest_import.proto does.
|
||||||
|
Assert.AreEqual(0, file.PublicDependencies.Count);
|
||||||
|
Assert.AreEqual(1, UnittestImportProto3Reflection.Descriptor.PublicDependencies.Count);
|
||||||
|
Assert.AreEqual(UnittestImportPublicProto3Reflection.Descriptor, UnittestImportProto3Reflection.Descriptor.PublicDependencies[0]);
|
||||||
|
|
||||||
|
Assert.AreEqual(1, file.Dependencies.Count);
|
||||||
|
Assert.AreEqual(UnittestImportProto3Reflection.Descriptor, file.Dependencies[0]);
|
||||||
|
|
||||||
|
MessageDescriptor messageType = TestAllTypes.Descriptor;
|
||||||
|
Assert.AreSame(typeof(TestAllTypes), messageType.ClrType);
|
||||||
|
Assert.AreSame(TestAllTypes.Parser, messageType.Parser);
|
||||||
|
Assert.AreEqual(messageType, file.MessageTypes[0]);
|
||||||
|
Assert.AreEqual(messageType, file.FindTypeByName<MessageDescriptor>("TestAllTypes"));
|
||||||
|
Assert.Null(file.FindTypeByName<MessageDescriptor>("NoSuchType"));
|
||||||
|
Assert.Null(file.FindTypeByName<MessageDescriptor>("protobuf_unittest.TestAllTypes"));
|
||||||
|
for (int i = 0; i < file.MessageTypes.Count; i++)
|
||||||
|
{
|
||||||
|
Assert.AreEqual(i, file.MessageTypes[i].Index);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.AreEqual(file.EnumTypes[0], file.FindTypeByName<EnumDescriptor>("ForeignEnum"));
|
||||||
|
Assert.Null(file.FindTypeByName<EnumDescriptor>("NoSuchType"));
|
||||||
|
Assert.Null(file.FindTypeByName<EnumDescriptor>("protobuf_unittest.ForeignEnum"));
|
||||||
|
Assert.AreEqual(1, UnittestImportProto3Reflection.Descriptor.EnumTypes.Count);
|
||||||
|
Assert.AreEqual("ImportEnum", UnittestImportProto3Reflection.Descriptor.EnumTypes[0].Name);
|
||||||
|
for (int i = 0; i < file.EnumTypes.Count; i++)
|
||||||
|
{
|
||||||
|
Assert.AreEqual(i, file.EnumTypes[i].Index);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.AreEqual(10, file.SerializedData[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MessageDescriptor()
|
||||||
|
{
|
||||||
|
MessageDescriptor messageType = TestAllTypes.Descriptor;
|
||||||
|
MessageDescriptor nestedType = TestAllTypes.Types.NestedMessage.Descriptor;
|
||||||
|
|
||||||
|
Assert.AreEqual("TestAllTypes", messageType.Name);
|
||||||
|
Assert.AreEqual("protobuf_unittest.TestAllTypes", messageType.FullName);
|
||||||
|
Assert.AreEqual(UnittestProto3Reflection.Descriptor, messageType.File);
|
||||||
|
Assert.IsNull(messageType.ContainingType);
|
||||||
|
Assert.IsNull(messageType.Proto.Options);
|
||||||
|
|
||||||
|
Assert.AreEqual("TestAllTypes", messageType.Name);
|
||||||
|
|
||||||
|
Assert.AreEqual("NestedMessage", nestedType.Name);
|
||||||
|
Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedMessage", nestedType.FullName);
|
||||||
|
Assert.AreEqual(UnittestProto3Reflection.Descriptor, nestedType.File);
|
||||||
|
Assert.AreEqual(messageType, nestedType.ContainingType);
|
||||||
|
|
||||||
|
FieldDescriptor field = messageType.Fields.InDeclarationOrder()[0];
|
||||||
|
Assert.AreEqual("single_int32", field.Name);
|
||||||
|
Assert.AreEqual(field, messageType.FindDescriptor<FieldDescriptor>("single_int32"));
|
||||||
|
Assert.Null(messageType.FindDescriptor<FieldDescriptor>("no_such_field"));
|
||||||
|
Assert.AreEqual(field, messageType.FindFieldByNumber(1));
|
||||||
|
Assert.Null(messageType.FindFieldByNumber(571283));
|
||||||
|
var fieldsInDeclarationOrder = messageType.Fields.InDeclarationOrder();
|
||||||
|
for (int i = 0; i < fieldsInDeclarationOrder.Count; i++)
|
||||||
|
{
|
||||||
|
Assert.AreEqual(i, fieldsInDeclarationOrder[i].Index);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.AreEqual(nestedType, messageType.NestedTypes[0]);
|
||||||
|
Assert.AreEqual(nestedType, messageType.FindDescriptor<MessageDescriptor>("NestedMessage"));
|
||||||
|
Assert.Null(messageType.FindDescriptor<MessageDescriptor>("NoSuchType"));
|
||||||
|
for (int i = 0; i < messageType.NestedTypes.Count; i++)
|
||||||
|
{
|
||||||
|
Assert.AreEqual(i, messageType.NestedTypes[i].Index);
|
||||||
|
}
|
||||||
|
|
||||||
|
Assert.AreEqual(messageType.EnumTypes[0], messageType.FindDescriptor<EnumDescriptor>("NestedEnum"));
|
||||||
|
Assert.Null(messageType.FindDescriptor<EnumDescriptor>("NoSuchType"));
|
||||||
|
for (int i = 0; i < messageType.EnumTypes.Count; i++)
|
||||||
|
{
|
||||||
|
Assert.AreEqual(i, messageType.EnumTypes[i].Index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void FieldDescriptor()
|
||||||
|
{
|
||||||
|
MessageDescriptor messageType = TestAllTypes.Descriptor;
|
||||||
|
FieldDescriptor primitiveField = messageType.FindDescriptor<FieldDescriptor>("single_int32");
|
||||||
|
FieldDescriptor enumField = messageType.FindDescriptor<FieldDescriptor>("single_nested_enum");
|
||||||
|
FieldDescriptor messageField = messageType.FindDescriptor<FieldDescriptor>("single_foreign_message");
|
||||||
|
|
||||||
|
Assert.AreEqual("single_int32", primitiveField.Name);
|
||||||
|
Assert.AreEqual("protobuf_unittest.TestAllTypes.single_int32",
|
||||||
|
primitiveField.FullName);
|
||||||
|
Assert.AreEqual(1, primitiveField.FieldNumber);
|
||||||
|
Assert.AreEqual(messageType, primitiveField.ContainingType);
|
||||||
|
Assert.AreEqual(UnittestProto3Reflection.Descriptor, primitiveField.File);
|
||||||
|
Assert.AreEqual(FieldType.Int32, primitiveField.FieldType);
|
||||||
|
Assert.IsNull(primitiveField.Proto.Options);
|
||||||
|
|
||||||
|
Assert.AreEqual("single_nested_enum", enumField.Name);
|
||||||
|
Assert.AreEqual(FieldType.Enum, enumField.FieldType);
|
||||||
|
// Assert.AreEqual(TestAllTypes.Types.NestedEnum.DescriptorProtoFile, enumField.EnumType);
|
||||||
|
|
||||||
|
Assert.AreEqual("single_foreign_message", messageField.Name);
|
||||||
|
Assert.AreEqual(FieldType.Message, messageField.FieldType);
|
||||||
|
Assert.AreEqual(ForeignMessage.Descriptor, messageField.MessageType);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void FieldDescriptorLabel()
|
||||||
|
{
|
||||||
|
FieldDescriptor singleField =
|
||||||
|
TestAllTypes.Descriptor.FindDescriptor<FieldDescriptor>("single_int32");
|
||||||
|
FieldDescriptor repeatedField =
|
||||||
|
TestAllTypes.Descriptor.FindDescriptor<FieldDescriptor>("repeated_int32");
|
||||||
|
|
||||||
|
Assert.IsFalse(singleField.IsRepeated);
|
||||||
|
Assert.IsTrue(repeatedField.IsRepeated);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void EnumDescriptor()
|
||||||
|
{
|
||||||
|
// Note: this test is a bit different to the Java version because there's no static way of getting to the descriptor
|
||||||
|
EnumDescriptor enumType = UnittestProto3Reflection.Descriptor.FindTypeByName<EnumDescriptor>("ForeignEnum");
|
||||||
|
EnumDescriptor nestedType = TestAllTypes.Descriptor.FindDescriptor<EnumDescriptor>("NestedEnum");
|
||||||
|
|
||||||
|
Assert.AreEqual("ForeignEnum", enumType.Name);
|
||||||
|
Assert.AreEqual("protobuf_unittest.ForeignEnum", enumType.FullName);
|
||||||
|
Assert.AreEqual(UnittestProto3Reflection.Descriptor, enumType.File);
|
||||||
|
Assert.Null(enumType.ContainingType);
|
||||||
|
Assert.Null(enumType.Proto.Options);
|
||||||
|
|
||||||
|
Assert.AreEqual("NestedEnum", nestedType.Name);
|
||||||
|
Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedEnum",
|
||||||
|
nestedType.FullName);
|
||||||
|
Assert.AreEqual(UnittestProto3Reflection.Descriptor, nestedType.File);
|
||||||
|
Assert.AreEqual(TestAllTypes.Descriptor, nestedType.ContainingType);
|
||||||
|
|
||||||
|
EnumValueDescriptor value = enumType.FindValueByName("FOREIGN_FOO");
|
||||||
|
Assert.AreEqual(value, enumType.Values[1]);
|
||||||
|
Assert.AreEqual("FOREIGN_FOO", value.Name);
|
||||||
|
Assert.AreEqual(4, value.Number);
|
||||||
|
Assert.AreEqual((int) ForeignEnum.ForeignFoo, value.Number);
|
||||||
|
Assert.AreEqual(value, enumType.FindValueByNumber(4));
|
||||||
|
Assert.Null(enumType.FindValueByName("NO_SUCH_VALUE"));
|
||||||
|
for (int i = 0; i < enumType.Values.Count; i++)
|
||||||
|
{
|
||||||
|
Assert.AreEqual(i, enumType.Values[i].Index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void OneofDescriptor()
|
||||||
|
{
|
||||||
|
OneofDescriptor descriptor = TestAllTypes.Descriptor.FindDescriptor<OneofDescriptor>("oneof_field");
|
||||||
|
Assert.AreEqual("oneof_field", descriptor.Name);
|
||||||
|
Assert.AreEqual("protobuf_unittest.TestAllTypes.oneof_field", descriptor.FullName);
|
||||||
|
|
||||||
|
var expectedFields = new[] {
|
||||||
|
TestAllTypes.OneofBytesFieldNumber,
|
||||||
|
TestAllTypes.OneofNestedMessageFieldNumber,
|
||||||
|
TestAllTypes.OneofStringFieldNumber,
|
||||||
|
TestAllTypes.OneofUint32FieldNumber }
|
||||||
|
.Select(fieldNumber => TestAllTypes.Descriptor.FindFieldByNumber(fieldNumber))
|
||||||
|
.ToList();
|
||||||
|
foreach (var field in expectedFields)
|
||||||
|
{
|
||||||
|
Assert.AreSame(descriptor, field.ContainingOneof);
|
||||||
|
}
|
||||||
|
|
||||||
|
CollectionAssert.AreEquivalent(expectedFields, descriptor.Fields);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void MapEntryMessageDescriptor()
|
||||||
|
{
|
||||||
|
var descriptor = MapWellKnownTypes.Descriptor.NestedTypes[0];
|
||||||
|
Assert.IsNull(descriptor.Parser);
|
||||||
|
Assert.IsNull(descriptor.ClrType);
|
||||||
|
Assert.IsNull(descriptor.Fields[1].Accessor);
|
||||||
|
}
|
||||||
|
|
||||||
|
// From TestFieldOrdering:
|
||||||
|
// string my_string = 11;
|
||||||
|
// int64 my_int = 1;
|
||||||
|
// float my_float = 101;
|
||||||
|
// NestedMessage single_nested_message = 200;
|
||||||
|
[Test]
|
||||||
|
public void FieldListOrderings()
|
||||||
|
{
|
||||||
|
var fields = TestFieldOrderings.Descriptor.Fields;
|
||||||
|
Assert.AreEqual(new[] { 11, 1, 101, 200 }, fields.InDeclarationOrder().Select(x => x.FieldNumber));
|
||||||
|
Assert.AreEqual(new[] { 1, 11, 101, 200 }, fields.InFieldNumberOrder().Select(x => x.FieldNumber));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DescriptorProtoFileDescriptor()
|
||||||
|
{
|
||||||
|
var descriptor = Google.Protobuf.Reflection.FileDescriptor.DescriptorProtoFileDescriptor;
|
||||||
|
Assert.AreEqual("google/protobuf/descriptor.proto", descriptor.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,218 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2015 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.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using Google.Protobuf.TestProtos;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using System;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace Google.Protobuf.Reflection
|
||||||
|
{
|
||||||
|
public class FieldAccessTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public void GetValue()
|
||||||
|
{
|
||||||
|
var message = SampleMessages.CreateFullTestAllTypes();
|
||||||
|
var fields = TestAllTypes.Descriptor.Fields;
|
||||||
|
Assert.AreEqual(message.SingleBool, fields[TestAllTypes.SingleBoolFieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleBytes, fields[TestAllTypes.SingleBytesFieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleDouble, fields[TestAllTypes.SingleDoubleFieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleFixed32, fields[TestAllTypes.SingleFixed32FieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleFixed64, fields[TestAllTypes.SingleFixed64FieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleFloat, fields[TestAllTypes.SingleFloatFieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleForeignEnum, fields[TestAllTypes.SingleForeignEnumFieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleForeignMessage, fields[TestAllTypes.SingleForeignMessageFieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleImportEnum, fields[TestAllTypes.SingleImportEnumFieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleImportMessage, fields[TestAllTypes.SingleImportMessageFieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleInt32, fields[TestAllTypes.SingleInt32FieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleInt64, fields[TestAllTypes.SingleInt64FieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleNestedEnum, fields[TestAllTypes.SingleNestedEnumFieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleNestedMessage, fields[TestAllTypes.SingleNestedMessageFieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SinglePublicImportMessage, fields[TestAllTypes.SinglePublicImportMessageFieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleSint32, fields[TestAllTypes.SingleSint32FieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleSint64, fields[TestAllTypes.SingleSint64FieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleString, fields[TestAllTypes.SingleStringFieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleSfixed32, fields[TestAllTypes.SingleSfixed32FieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleSfixed64, fields[TestAllTypes.SingleSfixed64FieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleUint32, fields[TestAllTypes.SingleUint32FieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.SingleUint64, fields[TestAllTypes.SingleUint64FieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.OneofBytes, fields[TestAllTypes.OneofBytesFieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.OneofString, fields[TestAllTypes.OneofStringFieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.OneofNestedMessage, fields[TestAllTypes.OneofNestedMessageFieldNumber].Accessor.GetValue(message));
|
||||||
|
Assert.AreEqual(message.OneofUint32, fields[TestAllTypes.OneofUint32FieldNumber].Accessor.GetValue(message));
|
||||||
|
|
||||||
|
// Just one example for repeated fields - they're all just returning the list
|
||||||
|
var list = (IList) fields[TestAllTypes.RepeatedInt32FieldNumber].Accessor.GetValue(message);
|
||||||
|
Assert.AreEqual(message.RepeatedInt32, list);
|
||||||
|
Assert.AreEqual(message.RepeatedInt32[0], list[0]); // Just in case there was any doubt...
|
||||||
|
|
||||||
|
// Just a single map field, for the same reason
|
||||||
|
var mapMessage = new TestMap { MapStringString = { { "key1", "value1" }, { "key2", "value2" } } };
|
||||||
|
fields = TestMap.Descriptor.Fields;
|
||||||
|
var dictionary = (IDictionary) fields[TestMap.MapStringStringFieldNumber].Accessor.GetValue(mapMessage);
|
||||||
|
Assert.AreEqual(mapMessage.MapStringString, dictionary);
|
||||||
|
Assert.AreEqual("value1", dictionary["key1"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Clear()
|
||||||
|
{
|
||||||
|
var message = SampleMessages.CreateFullTestAllTypes();
|
||||||
|
var fields = TestAllTypes.Descriptor.Fields;
|
||||||
|
fields[TestAllTypes.SingleBoolFieldNumber].Accessor.Clear(message);
|
||||||
|
fields[TestAllTypes.SingleInt32FieldNumber].Accessor.Clear(message);
|
||||||
|
fields[TestAllTypes.SingleStringFieldNumber].Accessor.Clear(message);
|
||||||
|
fields[TestAllTypes.SingleBytesFieldNumber].Accessor.Clear(message);
|
||||||
|
fields[TestAllTypes.SingleForeignEnumFieldNumber].Accessor.Clear(message);
|
||||||
|
fields[TestAllTypes.SingleForeignMessageFieldNumber].Accessor.Clear(message);
|
||||||
|
fields[TestAllTypes.RepeatedDoubleFieldNumber].Accessor.Clear(message);
|
||||||
|
|
||||||
|
var expected = new TestAllTypes(SampleMessages.CreateFullTestAllTypes())
|
||||||
|
{
|
||||||
|
SingleBool = false,
|
||||||
|
SingleInt32 = 0,
|
||||||
|
SingleString = "",
|
||||||
|
SingleBytes = ByteString.Empty,
|
||||||
|
SingleForeignEnum = 0,
|
||||||
|
SingleForeignMessage = null,
|
||||||
|
};
|
||||||
|
expected.RepeatedDouble.Clear();
|
||||||
|
|
||||||
|
Assert.AreEqual(expected, message);
|
||||||
|
|
||||||
|
// Separately, maps.
|
||||||
|
var mapMessage = new TestMap { MapStringString = { { "key1", "value1" }, { "key2", "value2" } } };
|
||||||
|
fields = TestMap.Descriptor.Fields;
|
||||||
|
fields[TestMap.MapStringStringFieldNumber].Accessor.Clear(mapMessage);
|
||||||
|
Assert.AreEqual(0, mapMessage.MapStringString.Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SetValue_SingleFields()
|
||||||
|
{
|
||||||
|
// Just a sample (primitives, messages, enums, strings, byte strings)
|
||||||
|
var message = SampleMessages.CreateFullTestAllTypes();
|
||||||
|
var fields = TestAllTypes.Descriptor.Fields;
|
||||||
|
fields[TestAllTypes.SingleBoolFieldNumber].Accessor.SetValue(message, false);
|
||||||
|
fields[TestAllTypes.SingleInt32FieldNumber].Accessor.SetValue(message, 500);
|
||||||
|
fields[TestAllTypes.SingleStringFieldNumber].Accessor.SetValue(message, "It's a string");
|
||||||
|
fields[TestAllTypes.SingleBytesFieldNumber].Accessor.SetValue(message, ByteString.CopyFrom(99, 98, 97));
|
||||||
|
fields[TestAllTypes.SingleForeignEnumFieldNumber].Accessor.SetValue(message, ForeignEnum.ForeignFoo);
|
||||||
|
fields[TestAllTypes.SingleForeignMessageFieldNumber].Accessor.SetValue(message, new ForeignMessage { C = 12345 });
|
||||||
|
fields[TestAllTypes.SingleDoubleFieldNumber].Accessor.SetValue(message, 20150701.5);
|
||||||
|
|
||||||
|
var expected = new TestAllTypes(SampleMessages.CreateFullTestAllTypes())
|
||||||
|
{
|
||||||
|
SingleBool = false,
|
||||||
|
SingleInt32 = 500,
|
||||||
|
SingleString = "It's a string",
|
||||||
|
SingleBytes = ByteString.CopyFrom(99, 98, 97),
|
||||||
|
SingleForeignEnum = ForeignEnum.ForeignFoo,
|
||||||
|
SingleForeignMessage = new ForeignMessage { C = 12345 },
|
||||||
|
SingleDouble = 20150701.5
|
||||||
|
};
|
||||||
|
|
||||||
|
Assert.AreEqual(expected, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SetValue_SingleFields_WrongType()
|
||||||
|
{
|
||||||
|
IMessage message = SampleMessages.CreateFullTestAllTypes();
|
||||||
|
var fields = message.Descriptor.Fields;
|
||||||
|
Assert.Throws<InvalidCastException>(() => fields[TestAllTypes.SingleBoolFieldNumber].Accessor.SetValue(message, "This isn't a bool"));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SetValue_MapFields()
|
||||||
|
{
|
||||||
|
IMessage message = new TestMap();
|
||||||
|
var fields = message.Descriptor.Fields;
|
||||||
|
Assert.Throws<InvalidOperationException>(() => fields[TestMap.MapStringStringFieldNumber].Accessor.SetValue(message, new Dictionary<string, string>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void SetValue_RepeatedFields()
|
||||||
|
{
|
||||||
|
IMessage message = SampleMessages.CreateFullTestAllTypes();
|
||||||
|
var fields = message.Descriptor.Fields;
|
||||||
|
Assert.Throws<InvalidOperationException>(() => fields[TestAllTypes.RepeatedDoubleFieldNumber].Accessor.SetValue(message, new double[10]));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void GetValue_IncorrectType()
|
||||||
|
{
|
||||||
|
IMessage message = SampleMessages.CreateFullTestAllTypes();
|
||||||
|
var fields = message.Descriptor.Fields;
|
||||||
|
Assert.Throws<InvalidCastException>(() => fields[TestAllTypes.SingleBoolFieldNumber].Accessor.GetValue(new TestMap()));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void Oneof()
|
||||||
|
{
|
||||||
|
var message = new TestAllTypes();
|
||||||
|
var descriptor = TestAllTypes.Descriptor;
|
||||||
|
Assert.AreEqual(1, descriptor.Oneofs.Count);
|
||||||
|
var oneof = descriptor.Oneofs[0];
|
||||||
|
Assert.AreEqual("oneof_field", oneof.Name);
|
||||||
|
Assert.IsNull(oneof.Accessor.GetCaseFieldDescriptor(message));
|
||||||
|
|
||||||
|
message.OneofString = "foo";
|
||||||
|
Assert.AreSame(descriptor.Fields[TestAllTypes.OneofStringFieldNumber], oneof.Accessor.GetCaseFieldDescriptor(message));
|
||||||
|
|
||||||
|
message.OneofUint32 = 10;
|
||||||
|
Assert.AreSame(descriptor.Fields[TestAllTypes.OneofUint32FieldNumber], oneof.Accessor.GetCaseFieldDescriptor(message));
|
||||||
|
|
||||||
|
oneof.Accessor.Clear(message);
|
||||||
|
Assert.AreEqual(TestAllTypes.OneofFieldOneofCase.None, message.OneofFieldCase);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void FieldDescriptor_ByName()
|
||||||
|
{
|
||||||
|
var descriptor = TestAllTypes.Descriptor;
|
||||||
|
Assert.AreSame(
|
||||||
|
descriptor.Fields[TestAllTypes.SingleBoolFieldNumber],
|
||||||
|
descriptor.Fields["single_bool"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void FieldDescriptor_NotFound()
|
||||||
|
{
|
||||||
|
var descriptor = TestAllTypes.Descriptor;
|
||||||
|
Assert.Throws<KeyNotFoundException>(() => descriptor.Fields[999999].ToString());
|
||||||
|
Assert.Throws<KeyNotFoundException>(() => descriptor.Fields["not found"].ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,94 @@
|
||||||
|
#region Copyright notice and license
|
||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2015 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.
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
using Google.Protobuf.TestProtos;
|
||||||
|
using Google.Protobuf.WellKnownTypes;
|
||||||
|
using NUnit.Framework;
|
||||||
|
|
||||||
|
namespace Google.Protobuf.Reflection
|
||||||
|
{
|
||||||
|
public class TypeRegistryTest
|
||||||
|
{
|
||||||
|
// Most of our tests use messages. Simple test that we really can use files...
|
||||||
|
[Test]
|
||||||
|
public void CreateWithFileDescriptor()
|
||||||
|
{
|
||||||
|
var registry = TypeRegistry.FromFiles(DurationReflection.Descriptor, StructReflection.Descriptor);
|
||||||
|
AssertDescriptorPresent(registry, Duration.Descriptor);
|
||||||
|
AssertDescriptorPresent(registry, ListValue.Descriptor);
|
||||||
|
AssertDescriptorAbsent(registry, Timestamp.Descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TypesFromSameFile()
|
||||||
|
{
|
||||||
|
// Just for kicks, let's start with a nested type
|
||||||
|
var registry = TypeRegistry.FromMessages(TestAllTypes.Types.NestedMessage.Descriptor);
|
||||||
|
// Top-level...
|
||||||
|
AssertDescriptorPresent(registry, TestFieldOrderings.Descriptor);
|
||||||
|
// ... and nested (not the same as the original NestedMessage!)
|
||||||
|
AssertDescriptorPresent(registry, TestFieldOrderings.Types.NestedMessage.Descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DependenciesAreIncluded()
|
||||||
|
{
|
||||||
|
var registry = TypeRegistry.FromMessages(TestAllTypes.Descriptor);
|
||||||
|
// Direct dependencies
|
||||||
|
AssertDescriptorPresent(registry, ImportMessage.Descriptor);
|
||||||
|
// Public dependencies
|
||||||
|
AssertDescriptorPresent(registry, PublicImportMessage.Descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void DuplicateFiles()
|
||||||
|
{
|
||||||
|
// Duplicates via dependencies and simply via repetition
|
||||||
|
var registry = TypeRegistry.FromFiles(
|
||||||
|
UnittestProto3Reflection.Descriptor, UnittestImportProto3Reflection.Descriptor,
|
||||||
|
TimestampReflection.Descriptor, TimestampReflection.Descriptor);
|
||||||
|
AssertDescriptorPresent(registry, TestAllTypes.Descriptor);
|
||||||
|
AssertDescriptorPresent(registry, ImportMessage.Descriptor);
|
||||||
|
AssertDescriptorPresent(registry, Timestamp.Descriptor);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void AssertDescriptorPresent(TypeRegistry registry, MessageDescriptor descriptor)
|
||||||
|
{
|
||||||
|
Assert.AreSame(descriptor, registry.Find(descriptor.FullName));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void AssertDescriptorAbsent(TypeRegistry registry, MessageDescriptor descriptor)
|
||||||
|
{
|
||||||
|
Assert.IsNull(registry.Find(descriptor.FullName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue