Merge branch 'master' into down-integrate

pull/3988/head
Adam Cozzette 7 years ago
commit 0ba8eea655
  1. 124
      .travis.yml
  2. 2
      BUILD
  3. 78
      CHANGES.txt
  4. 29
      Makefile.am
  5. 2
      Protobuf.podspec
  6. 7
      cmake/CMakeLists.txt
  7. 1
      cmake/extract_includes.bat.in
  8. 32
      cmake/install.cmake
  9. 12
      configure.ac
  10. 16
      conformance/conformance_test.cc
  11. 2
      csharp/Google.Protobuf.Tools.nuspec
  12. 30
      csharp/generate_protos.sh
  13. 3
      csharp/protos/README.md
  14. 8
      csharp/protos/map_unittest_proto3.proto
  15. 14
      csharp/protos/unittest_import_proto3.proto
  16. 1
      csharp/protos/unittest_import_public_proto3.proto
  17. 1
      csharp/protos/unittest_issues.proto
  18. 379
      csharp/protos/unittest_proto3.proto
  19. 6
      csharp/src/Google.Protobuf.Test/JsonFormatterTest.cs
  20. 4
      csharp/src/Google.Protobuf.Test/JsonParserTest.cs
  21. 34
      csharp/src/Google.Protobuf.Test/Reflection/DescriptorsTest.cs
  22. 254
      csharp/src/Google.Protobuf.Test/TestProtos/MapUnittestProto3.cs
  23. 17
      csharp/src/Google.Protobuf.Test/TestProtos/TestMessagesProto3.cs
  24. 20
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportProto3.cs
  25. 14
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestImportPublicProto3.cs
  26. 4
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestIssues.cs
  27. 274
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestProto3.cs
  28. 45
      csharp/src/Google.Protobuf.Test/TestProtos/UnittestWellKnownTypes.cs
  29. 6
      csharp/src/Google.Protobuf.Test/WellKnownTypes/AnyTest.cs
  30. 2
      csharp/src/Google.Protobuf/Google.Protobuf.csproj
  31. 2
      csharp/src/Google.Protobuf/JsonTokenizer.cs
  32. 1
      docs/third_party.md
  33. 2
      java/core/pom.xml
  34. 104
      java/core/src/main/java/com/google/protobuf/CodedInputStream.java
  35. 35
      java/core/src/main/java/com/google/protobuf/UnsafeUtil.java
  36. 484
      java/core/src/main/java/com/google/protobuf/Utf8.java
  37. 325
      java/core/src/test/java/com/google/protobuf/DecodeUtf8Test.java
  38. 9
      java/core/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java
  39. 2
      java/pom.xml
  40. 2
      java/util/pom.xml
  41. 2
      js/package.json
  42. 26
      objectivec/DevTools/full_mac_build.sh
  43. 2
      objectivec/GPBCodedOutputStream.m
  44. 2870
      objectivec/GPBDictionary.h
  45. 1953
      objectivec/GPBDictionary.m
  46. 13
      objectivec/GPBMessage.m
  47. 8
      objectivec/GPBRootObject.m
  48. 305
      objectivec/GPBUtilities.m
  49. 3
      objectivec/GPBUtilities_PackagePrivate.h
  50. 2
      objectivec/ProtocolBuffers_iOS.xcodeproj/project.pbxproj
  51. 2
      objectivec/Tests/GPBCodedInputStreamTests.m
  52. 80
      objectivec/Tests/GPBDictionaryTests+Bool.m
  53. 105
      objectivec/Tests/GPBDictionaryTests+Int32.m
  54. 105
      objectivec/Tests/GPBDictionaryTests+Int64.m
  55. 95
      objectivec/Tests/GPBDictionaryTests+String.m
  56. 105
      objectivec/Tests/GPBDictionaryTests+UInt32.m
  57. 105
      objectivec/Tests/GPBDictionaryTests+UInt64.m
  58. 35
      objectivec/Tests/GPBDictionaryTests.pddm
  59. 8
      objectivec/Tests/GPBMessageTests+Serialization.m
  60. 6
      objectivec/Tests/GPBMessageTests.m
  61. 80
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/Contents.json
  62. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_1024.png
  63. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_120.png
  64. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_152.png
  65. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_167.png
  66. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_180.png
  67. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_20.png
  68. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_29.png
  69. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_40.png
  70. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_58.png
  71. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_60.png
  72. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_76.png
  73. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_80.png
  74. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_87.png
  75. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6.png
  76. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6_2x.png
  77. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7.png
  78. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7_2x.png
  79. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6.png
  80. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6_2x.png
  81. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_2x.png
  82. BIN
      objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_3x.png
  83. 25
      objectivec/Tests/iOSTestHarness/Images.xcassets/LaunchImage.launchimage/Contents.json
  84. 2
      php/README.md
  85. 9
      php/ext/google/protobuf/encode_decode.c
  86. 1
      php/ext/google/protobuf/message.c
  87. 22
      php/ext/google/protobuf/package.xml
  88. 29
      php/ext/google/protobuf/protobuf.h
  89. 7
      php/src/Google/Protobuf/Any.php
  90. 20
      php/src/Google/Protobuf/Internal/Message.php
  91. 7
      php/tests/encode_decode_test.php
  92. 2
      post_process_dist.sh
  93. 16
      protoc-artifacts/README.md
  94. 13
      protoc-artifacts/build-protoc.sh
  95. 4
      protoc-artifacts/build-zip.sh
  96. 2
      protoc-artifacts/pom.xml
  97. 3
      python/MANIFEST.in
  98. 2
      python/google/protobuf/__init__.py
  99. 2
      python/google/protobuf/internal/well_known_types_test.py
  100. 16
      ruby/ext/google/protobuf_c/storage.c
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1,55 +1,65 @@
sudo: required
dist: trusty
# 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
# support, this should probably get updated to install steps and/or
# rvm/gemfile/jdk/etc. entries rather than manually doing the work.
# Everything is driven by the test.sh, so the language doesn't really
# matter, it just controls the default install/script/etc. steps on
# travis.
language: cpp
os:
- osx
# The Objective C build needs Xcode 7.0 or later.
osx_image: xcode8.3
script:
- ./tests.sh $CONFIG
env:
- CONFIG=cpp
- CONFIG=cpp_distcheck
- CONFIG=golang
- CONFIG=java_jdk7
- CONFIG=java_oracle7
- CONFIG=javanano_jdk7
- CONFIG=javanano_oracle7
- 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_cpp
- CONFIG=ruby21
- CONFIG=ruby22
- CONFIG=jruby
- CONFIG=php5.6_mac
- CONFIG=php7.0_mac
script: ./tests.sh $CONFIG
# The test matrix is manually built to cover a mix of linux and macOS
# hosted setups; this lets some extra settings be done specific to each
# host/language instead of forcing common values on all the tests.
matrix:
exclude:
# 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.
include:
# -----------------------------------------------------------------
# macOS hosted tests for Objective-C
- os: osx
env: CONFIG=objectivec_osx
osx_image: xcode9.1
language: objective-c
# iOS build log was starting to choke travis UI, so split to cover the
# Xcode Debug and Release Configurations independently.
- os: osx
env: CONFIG=java_jdk7
env: CONFIG=objectivec_ios_debug
osx_image: xcode9.1
language: objective-c
- os: osx
env: CONFIG=java_oracle7
env: CONFIG=objectivec_ios_release
osx_image: xcode9.1
language: objective-c
- os: osx
env: CONFIG=javanano_jdk7
env: CONFIG=objectivec_cocoapods_integration
osx_image: xcode9.1
language: objective-c
# -----------------------------------------------------------------
# macOS hosted tests for other languages.
- os: osx
env: CONFIG=javanano_oracle7
# Requires installing golang, currently travis.sh is doing that with apt-get
# which doesn't work on OS X.
env: CONFIG=cpp
- os: osx
env: CONFIG=golang
include:
env: CONFIG=cpp_distcheck
- os: osx
env: CONFIG=javascript
- os: osx
env: CONFIG=python
- os: osx
env: CONFIG=python_cpp
- os: osx
env: CONFIG=php5.6_mac
# Xcode versions force a host version of macOS:
# https://docs.travis-ci.com/user/reference/osx/#OS-X-Version
# Force macOS 10.12, the default travis image is going to be
# updated "soon", at which point this came come out:
# https://blog.travis-ci.com/2017-10-16-a-new-default-os-x-image-is-coming
osx_image: xcode8.3
- os: osx
env: CONFIG=php7.0_mac
# Same note about macOS version as on the php5.6_mac config.
osx_image: xcode8.3
# -----------------------------------------------------------------
# Linux hosted tests
# The dotnet environment requires Ubuntu 14.04 or 16.04. This
# configuration is effectively an "extra" one, outside the
# autogenerated matrix.
@ -57,7 +67,8 @@ matrix:
env: CONFIG=csharp
language: csharp
dist: trusty
dotnet: 1.0.1
sudo: required
dotnet: 1.0.4
mono: none
# This test is kept on travis because it doesn't play nicely with other
# tests on jenkins running in parallel.
@ -67,25 +78,14 @@ matrix:
# fetch pre-built Linux protoc binaries in the test.
- os: linux
env: CONFIG=java_compatibility
sudo: required
dist: trusty
# 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:
# These currently do not work on OS X but are being worked on by @haberman.
- os: osx
env: CONFIG=ruby22
- os: osx
env: CONFIG=jruby
# https://github.com/google/protobuf/issues/1253 - Started failing when
# we moved to an OS X image that is 10.11.
- os: osx
env: CONFIG=python_cpp
# Mark the iOS test as flakey as xcodebuild some times fails to start the
# iOS Simulator.
- os: osx
env: CONFIG=objectivec_ios_debug
- os: osx
env: CONFIG=objectivec_ios_release
sudo: required
dist: trusty
notifications:
email: false

@ -24,6 +24,8 @@ COPTS = select({
"-Woverloaded-virtual",
"-Wno-sign-compare",
"-Wno-unused-function",
# Prevents ISO C++ const string assignment warnings for pyext sources.
"-Wno-writable-strings",
],
})

@ -1,3 +1,79 @@
2017-11-13 version 3.5.0 (C++/Java/Python/PHP/Objective-C/C#/Ruby/JavaScript)
Planned Future Changes
* Make C++ implementation C++11 only: we plan to require C++11 to build
protobuf code starting from 3.6.0 release. Please join this github issue:
https://github.com/google/protobuf/issues/2780 to provide your feedback.
General
* Unknown fields are now preserved in proto3 for most of the language
implementations for proto3 by default. See the per-language section for
details.
* reserve keyword are now supported in enums
C++
* Proto3 messages are now preserving unknown fields by default. If you rely on
unknowns fields being dropped. Please use DiscardUnknownFields() explicitly.
* Deprecated the unsafe_arena_release_* and unsafe_arena_add_allocated_*
methods for string fields.
* Added move constructor and move assignment to RepeatedField,
RepeatedPtrField and google::protobuf::Any.
* Added perfect forwarding in Arena::CreateMessage
* In-progress experimental support for implicit weak fields with lite protos.
This feature allows the linker to strip out more unused messages and reduce
binary size.
* Various performance optimizations.
Java
* Proto3 messages are now preserving unknown fields by default. If you’d like
to drop unknown fields, please use the DiscardUnknownFieldsParser API. For
example:
Parser<Foo> parser = DiscardUnknownFieldsParser.wrap(Foo.parser());
Foo foo = parser.parseFrom(input);
* Added a new CodedInputStream decoder for Iterable<ByteBuffer> with direct
ByteBuffers.
* TextFormat now prints unknown length-delimited fields as messages if
possible.
* FieldMaskUtil.merge() no longer creates unnecessary empty messages when a
message field is unset in both source message and destination message.
* Various performance optimizations.
Python
* Proto3 messages are now preserving unknown fields by default. Use
message.DiscardUnknownFields() to drop unknown fields.
* Add FieldDescriptor.file in generated code.
* Add descriptor pool FindOneofByName in pure python.
* Change unknown enum values into unknown field set .
* Add more Python dict/list compatibility for Struct/ListValue.
* Add utf-8 support for text_format.Merge()/Parse().
* Support numeric unknown enum values for proto3 JSON format.
* Add warning for Unexpected end-group tag in cpp extension.
PHP
* Proto3 messages are now preserving unknown fields.
* Provide well known type messages in runtime.
* Add prefix ‘PB’ to generated class of reserved names.
* Fixed all conformance tests for encode/decode json in php runtime. C
extension needs more work.
Objective-C
* Fixed some issues around copying of messages with unknown fields and then
mutating the unknown fields in the copy.
C#
* Added unknown field support in JsonParser.
* Fixed oneof message field merge.
* Simplify parsing messages from array slices.
Ruby
* Unknown fields are now preserved by default.
* Fixed several bugs for segment fault.
Javascript
* Decoder can handle both paced and unpacked data no matter how the proto is
defined.
* Decoder now accept long varint for 32 bit integers.
2017-08-14 version 3.4.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
@ -92,7 +168,7 @@
* Note: AppEngine 2.5 is deprecated on June 2017 that AppEngine 2.5 will
never update protobuf runtime. Users who depend on AppEngine 2.5 should use
old protoc.
PHP
* Support PHP generic services. Specify file option php_generic_service=true
to enable generating service interface.

@ -61,8 +61,13 @@ csharp_EXTRA_DIST= \
csharp/keys/Google.Protobuf.public.snk \
csharp/keys/Google.Protobuf.snk \
csharp/keys/README.md \
csharp/protos/README.md \
csharp/protos/map_unittest_proto3.proto \
csharp/protos/unittest_custom_options_proto3.proto \
csharp/protos/unittest_import_public_proto3.proto \
csharp/protos/unittest_import_proto3.proto \
csharp/protos/unittest_issues.proto \
csharp/protos/unittest_proto3.proto \
csharp/src/AddressBook/AddPerson.cs \
csharp/src/AddressBook/Addressbook.cs \
csharp/src/AddressBook/AddressBook.csproj \
@ -281,6 +286,7 @@ java_EXTRA_DIST=
java/core/src/test/java/com/google/protobuf/CheckUtf8Test.java \
java/core/src/test/java/com/google/protobuf/CodedInputStreamTest.java \
java/core/src/test/java/com/google/protobuf/CodedOutputStreamTest.java \
java/core/src/test/java/com/google/protobuf/DecodeUtf8Test.java \
java/core/src/test/java/com/google/protobuf/DeprecatedFieldTest.java \
java/core/src/test/java/com/google/protobuf/DescriptorsTest.java \
java/core/src/test/java/com/google/protobuf/DiscardUnknownFieldsTest.java \
@ -553,15 +559,20 @@ objectivec_EXTRA_DIST= \
objectivec/Tests/GPBWireFormatTests.m \
objectivec/Tests/iOSTestHarness/AppDelegate.m \
objectivec/Tests/iOSTestHarness/en.lproj/InfoPlist.strings \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/Contents.json \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad6_2x.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPad7_2x.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone6_2x.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_2x.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/iPhone7_3x.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_20.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_29.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_40.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_58.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_60.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_76.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_80.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_87.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_120.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_152.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_167.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_180.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/appicon_1024.png \
objectivec/Tests/iOSTestHarness/Images.xcassets/AppIcon.appiconset/Contents.json \
objectivec/Tests/iOSTestHarness/Images.xcassets/LaunchImage.launchimage/Contents.json \
objectivec/Tests/iOSTestHarness/Info.plist \
objectivec/Tests/iOSTestHarness/LaunchScreen.xib \

@ -5,7 +5,7 @@
# dependent projects use the :git notation to refer to the library.
Pod::Spec.new do |s|
s.name = 'Protobuf'
s.version = '3.4.1'
s.version = '3.5.0'
s.summary = 'Protocol Buffers v.3 runtime library for Objective-C.'
s.homepage = 'https://github.com/google/protobuf'
s.license = '3-Clause BSD License'

@ -14,6 +14,7 @@ project(protobuf C CXX)
# Options
option(protobuf_BUILD_TESTS "Build tests" ON)
option(protobuf_BUILD_EXAMPLES "Build examples" OFF)
option(protobuf_BUILD_PROTOC_BINARIES "Build libprotoc and protoc compiler" ON)
if (BUILD_SHARED_LIBS)
set(protobuf_BUILD_SHARED_LIBS_DEFAULT ON)
else (BUILD_SHARED_LIBS)
@ -184,8 +185,10 @@ endif (protobuf_UNICODE)
include(libprotobuf-lite.cmake)
include(libprotobuf.cmake)
include(libprotoc.cmake)
include(protoc.cmake)
if (protobuf_BUILD_PROTOC_BINARIES)
include(libprotoc.cmake)
include(protoc.cmake)
endif (protobuf_BUILD_PROTOC_BINARIES)
if (protobuf_BUILD_TESTS)
include(tests.cmake)

@ -83,7 +83,6 @@ copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops.h" in
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_arm_gcc.h" include\google\protobuf\stubs\atomicops_internals_arm_gcc.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_atomicword_compat.h" include\google\protobuf\stubs\atomicops_internals_atomicword_compat.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_generic_gcc.h" include\google\protobuf\stubs\atomicops_internals_generic_gcc.h
copy "${PROTOBUF_SOURCE_WIN32_PATH}\..\src\google\protobuf\stubs\atomicops_internals_mips_gcc.h" include\google\protobuf\stubs\atomicops_internals_mips_gcc.h

@ -5,10 +5,12 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/protobuf.pc.cmake
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/protobuf-lite.pc.cmake
${CMAKE_CURRENT_BINARY_DIR}/protobuf-lite.pc @ONLY)
foreach(_library
libprotobuf-lite
libprotobuf
libprotoc)
set(_protobuf_libraries libprotobuf-lite libprotobuf)
if (protobuf_BUILD_PROTOC_BINARIES)
list(APPEND _protobuf_libraries libprotoc)
endif (protobuf_BUILD_PROTOC_BINARIES)
foreach(_library ${_protobuf_libraries})
set_property(TARGET ${_library}
PROPERTY INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${protobuf_source_dir}/src>
@ -19,8 +21,10 @@ foreach(_library
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT ${_library})
endforeach()
install(TARGETS protoc EXPORT protobuf-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc)
if (protobuf_BUILD_PROTOC_BINARIES)
install(TARGETS protoc EXPORT protobuf-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT protoc)
endif (protobuf_BUILD_PROTOC_BINARIES)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/protobuf.pc ${CMAKE_CURRENT_BINARY_DIR}/protobuf-lite.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
@ -101,10 +105,18 @@ configure_file(protobuf-options.cmake
${CMAKE_INSTALL_CMAKEDIR}/protobuf-options.cmake @ONLY)
# Allows the build directory to be used as a find directory.
export(TARGETS libprotobuf-lite libprotobuf libprotoc protoc
NAMESPACE protobuf::
FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
)
if (protobuf_BUILD_PROTOC_BINARIES)
export(TARGETS libprotobuf-lite libprotobuf libprotoc protoc
NAMESPACE protobuf::
FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
)
else (protobuf_BUILD_PROTOC_BINARIES)
export(TARGETS libprotobuf-lite libprotobuf
NAMESPACE protobuf::
FILE ${CMAKE_INSTALL_CMAKEDIR}/protobuf-targets.cmake
)
endif (protobuf_BUILD_PROTOC_BINARIES)
install(EXPORT protobuf-targets
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"

@ -17,7 +17,7 @@ AC_PREREQ(2.59)
# 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
# the size of one file name in the dist tarfile over the 99-char limit.)
AC_INIT([Protocol Buffers],[3.4.1],[protobuf@googlegroups.com],[protobuf])
AC_INIT([Protocol Buffers],[3.5.0],[protobuf@googlegroups.com],[protobuf])
AM_MAINTAINER_MODE([enable])
@ -52,6 +52,16 @@ AC_ARG_WITH([zlib],
[include classes for streaming compressed data in and out @<:@default=check@:>@])],
[],[with_zlib=check])
AC_ARG_WITH([zlib-include],
[AS_HELP_STRING([--with-zlib-include=PATH],
[zlib include directory])],
[CPPFLAGS="-I$withval $CPPFLAGS"])
AC_ARG_WITH([zlib-lib],
[AS_HELP_STRING([--with-zlib-lib=PATH],
[zlib lib directory])],
[LDFLAGS="-L$withval $LDFLAGS"])
AC_ARG_WITH([protoc],
[AS_HELP_STRING([--with-protoc=COMMAND],
[use the given protoc command instead of building a new one when building tests (useful for cross-compiling)])],

@ -1842,6 +1842,14 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
"optionalInt64": null,
"optionalUint32": null,
"optionalUint64": null,
"optionalSint32": null,
"optionalSint64": null,
"optionalFixed32": null,
"optionalFixed64": null,
"optionalSfixed32": null,
"optionalSfixed64": null,
"optionalFloat": null,
"optionalDouble": null,
"optionalBool": null,
"optionalString": null,
"optionalBytes": null,
@ -1851,6 +1859,14 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
"repeatedInt64": null,
"repeatedUint32": null,
"repeatedUint64": null,
"repeatedSint32": null,
"repeatedSint64": null,
"repeatedFixed32": null,
"repeatedFixed64": null,
"repeatedSfixed32": null,
"repeatedSfixed64": null,
"repeatedFloat": null,
"repeatedDouble": null,
"repeatedBool": null,
"repeatedString": null,
"repeatedBytes": null,

@ -5,7 +5,7 @@
<title>Google Protocol Buffers tools</title>
<summary>Tools for Protocol Buffers - Google's data interchange format.</summary>
<description>See project site for more info.</description>
<version>3.4.1</version>
<version>3.5.0</version>
<authors>Google Inc.</authors>
<owners>protobuf-packages</owners>
<licenseUrl>https://github.com/google/protobuf/blob/master/LICENSE</licenseUrl>

@ -3,7 +3,7 @@
# You first need to make sure protoc has been built (see instructions on
# building protoc in root of this repository)
set -ex
set -e
# cd to repository root
pushd $(dirname $0)/..
@ -40,28 +40,20 @@ $PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf \
src/google/protobuf/type.proto \
src/google/protobuf/wrappers.proto
# Test protos where the namespace matches the target location
$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test \
--csharp_opt=base_namespace=Google.Protobuf \
src/google/protobuf/map_unittest_proto3.proto \
src/google/protobuf/unittest_proto3.proto \
src/google/protobuf/unittest_import_proto3.proto \
src/google/protobuf/unittest_import_public_proto3.proto \
src/google/protobuf/unittest_well_known_types.proto
# Different base namespace to the protos above
$PROTOC -Isrc -Icsharp/protos --csharp_out=csharp/src/Google.Protobuf.Test \
--csharp_opt=base_namespace=UnitTest.Issues \
# Test protos
$PROTOC -Isrc -Icsharp/protos \
--csharp_out=csharp/src/Google.Protobuf.Test/TestProtos \
csharp/protos/map_unittest_proto3.proto \
csharp/protos/unittest_issues.proto \
csharp/protos/unittest_custom_options_proto3.proto
# Don't specify a base namespace at all; we just want to make sure the
# results end up in TestProtos.
$PROTOC -Isrc --csharp_out=csharp/src/Google.Protobuf.Test/TestProtos \
csharp/protos/unittest_custom_options_proto3.proto \
csharp/protos/unittest_proto3.proto \
csharp/protos/unittest_import_proto3.proto \
csharp/protos/unittest_import_public_proto3.proto \
src/google/protobuf/unittest_well_known_types.proto \
src/google/protobuf/test_messages_proto3.proto
# AddressBook sample protos
$PROTOC -Iexamples --csharp_out=csharp/src/AddressBook \
$PROTOC -Iexamples -Isrc --csharp_out=csharp/src/AddressBook \
examples/addressbook.proto
$PROTOC -Iconformance -Isrc --csharp_out=csharp/src/Google.Protobuf.Conformance \

@ -0,0 +1,3 @@
This directory contains unit test protos adapted from those in
src/google/protobuf, and C#-specific test protos for regression
tests against bugs found in the C# codegen or library.

@ -36,15 +36,11 @@
// required fields in proto3.
syntax = "proto3";
option cc_enable_arenas = true;
option csharp_namespace = "Google.Protobuf.TestProtos";
import "google/protobuf/unittest_proto3.proto";
import "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;
package protobuf_unittest3;
// Tests maps.
message TestMap {

@ -36,24 +36,12 @@
syntax = "proto3";
// 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_import = protobuf_unittest_import".
package protobuf_unittest_import;
option optimize_for = SPEED;
option cc_enable_arenas = true;
// Exercise the java_package option.
option java_package = "com.google.protobuf.test";
option csharp_namespace = "Google.Protobuf.TestProtos";
// 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";
import public "unittest_import_public_proto3.proto";
message ImportMessage {
int32 d = 1;

@ -34,7 +34,6 @@ syntax = "proto3";
package protobuf_unittest_import;
option java_package = "com.google.protobuf.test";
option csharp_namespace = "Google.Protobuf.TestProtos";
message PublicImportMessage {

@ -7,7 +7,6 @@ syntax = "proto3";
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.

@ -0,0 +1,379 @@
// 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";
option csharp_namespace = "Google.Protobuf.TestProtos";
// Only present so we can test that we can read it (as an example
// of a non-C# option)
option java_outer_classname = "UnittestProto";
import "unittest_import_proto3.proto";
package protobuf_unittest3;
// 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;
}
message TestEnumAllowAlias {
TestEnumWithDupValue value = 1;
}
// 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 {}

@ -514,7 +514,7 @@ namespace Google.Protobuf
var formatter = new JsonFormatter(JsonFormatter.Settings.Default.WithTypeRegistry(TypeRegistry.FromMessages(TestAllTypes.Descriptor)));
var message = new TestAllTypes { SingleInt32 = 10, SingleNestedMessage = new TestAllTypes.Types.NestedMessage { Bb = 20 } };
var any = Any.Pack(message);
AssertJson("{ '@type': 'type.googleapis.com/protobuf_unittest.TestAllTypes', 'singleInt32': 10, 'singleNestedMessage': { 'bb': 20 } }", formatter.Format(any));
AssertJson("{ '@type': 'type.googleapis.com/protobuf_unittest3.TestAllTypes', 'singleInt32': 10, 'singleNestedMessage': { 'bb': 20 } }", formatter.Format(any));
}
[Test]
@ -523,7 +523,7 @@ namespace Google.Protobuf
var formatter = new JsonFormatter(JsonFormatter.Settings.Default.WithTypeRegistry(TypeRegistry.FromMessages(TestAllTypes.Descriptor)));
var message = new TestAllTypes { SingleInt32 = 10 };
var any = Any.Pack(message, "foo.bar/baz");
AssertJson("{ '@type': 'foo.bar/baz/protobuf_unittest.TestAllTypes', 'singleInt32': 10 }", formatter.Format(any));
AssertJson("{ '@type': 'foo.bar/baz/protobuf_unittest3.TestAllTypes', 'singleInt32': 10 }", formatter.Format(any));
}
[Test]
@ -536,7 +536,7 @@ namespace Google.Protobuf
var doubleNestedMessage = new TestAllTypes { SingleInt32 = 20 };
var nestedMessage = Any.Pack(doubleNestedMessage);
var message = new TestWellKnownTypes { AnyField = Any.Pack(nestedMessage) };
AssertJson("{ 'anyField': { '@type': 'type.googleapis.com/google.protobuf.Any', 'value': { '@type': 'type.googleapis.com/protobuf_unittest.TestAllTypes', 'singleInt32': 20 } } }",
AssertJson("{ 'anyField': { '@type': 'type.googleapis.com/google.protobuf.Any', 'value': { '@type': 'type.googleapis.com/protobuf_unittest3.TestAllTypes', 'singleInt32': 20 } } }",
formatter.Format(message));
}

@ -809,7 +809,7 @@ namespace Google.Protobuf
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\" }";
string valueFirstJson = "{ \"singleInt32\": 10, \"singleNestedMessage\": { \"bb\": 20 }, \"@type\": \"type.googleapis.com/protobuf_unittest3.TestAllTypes\" }";
Assert.AreEqual(original, parser.Parse<Any>(valueFirstJson));
}
@ -820,7 +820,7 @@ namespace Google.Protobuf
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 }";
string json = "{ \"@type\": \"custom.prefix/middle-part/protobuf_unittest3.TestAllTypes\", \"singleInt32\": 10 }";
Assert.AreEqual(original, parser.Parse<Any>(json));
}

@ -48,13 +48,13 @@ namespace Google.Protobuf.Reflection
{
FileDescriptor file = UnittestProto3Reflection.Descriptor;
Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Name);
Assert.AreEqual("protobuf_unittest", file.Package);
Assert.AreEqual("unittest_proto3.proto", file.Name);
Assert.AreEqual("protobuf_unittest3", file.Package);
Assert.AreEqual("UnittestProto", file.Proto.Options.JavaOuterClassname);
Assert.AreEqual("google/protobuf/unittest_proto3.proto", file.Proto.Name);
Assert.AreEqual("unittest_proto3.proto", file.Proto.Name);
// unittest.proto doesn't have any public imports, but unittest_import.proto does.
// unittest_proto3.proto doesn't have any public imports, but unittest_import_proto3.proto does.
Assert.AreEqual(0, file.PublicDependencies.Count);
Assert.AreEqual(1, UnittestImportProto3Reflection.Descriptor.PublicDependencies.Count);
Assert.AreEqual(UnittestImportPublicProto3Reflection.Descriptor, UnittestImportProto3Reflection.Descriptor.PublicDependencies[0]);
@ -68,7 +68,7 @@ namespace Google.Protobuf.Reflection
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"));
Assert.Null(file.FindTypeByName<MessageDescriptor>("protobuf_unittest3.TestAllTypes"));
for (int i = 0; i < file.MessageTypes.Count; i++)
{
Assert.AreEqual(i, file.MessageTypes[i].Index);
@ -76,7 +76,7 @@ namespace Google.Protobuf.Reflection
Assert.AreEqual(file.EnumTypes[0], file.FindTypeByName<EnumDescriptor>("ForeignEnum"));
Assert.Null(file.FindTypeByName<EnumDescriptor>("NoSuchType"));
Assert.Null(file.FindTypeByName<EnumDescriptor>("protobuf_unittest.ForeignEnum"));
Assert.Null(file.FindTypeByName<EnumDescriptor>("protobuf_unittest3.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++)
@ -87,6 +87,16 @@ namespace Google.Protobuf.Reflection
Assert.AreEqual(10, file.SerializedData[0]);
}
[Test]
public void FileDescriptor_NonRootPath()
{
// unittest_proto3.proto used to be in google/protobuf. Now it's in the C#-specific location,
// let's test something that's still in a directory.
FileDescriptor file = UnittestWellKnownTypesReflection.Descriptor;
Assert.AreEqual("google/protobuf/unittest_well_known_types.proto", file.Name);
Assert.AreEqual("protobuf_unittest", file.Package);
}
[Test]
public void MessageDescriptor()
{
@ -94,7 +104,7 @@ namespace Google.Protobuf.Reflection
MessageDescriptor nestedType = TestAllTypes.Types.NestedMessage.Descriptor;
Assert.AreEqual("TestAllTypes", messageType.Name);
Assert.AreEqual("protobuf_unittest.TestAllTypes", messageType.FullName);
Assert.AreEqual("protobuf_unittest3.TestAllTypes", messageType.FullName);
Assert.AreEqual(UnittestProto3Reflection.Descriptor, messageType.File);
Assert.IsNull(messageType.ContainingType);
Assert.IsNull(messageType.Proto.Options);
@ -102,7 +112,7 @@ namespace Google.Protobuf.Reflection
Assert.AreEqual("TestAllTypes", messageType.Name);
Assert.AreEqual("NestedMessage", nestedType.Name);
Assert.AreEqual("protobuf_unittest.TestAllTypes.NestedMessage", nestedType.FullName);
Assert.AreEqual("protobuf_unittest3.TestAllTypes.NestedMessage", nestedType.FullName);
Assert.AreEqual(UnittestProto3Reflection.Descriptor, nestedType.File);
Assert.AreEqual(messageType, nestedType.ContainingType);
@ -143,7 +153,7 @@ namespace Google.Protobuf.Reflection
FieldDescriptor messageField = messageType.FindDescriptor<FieldDescriptor>("single_foreign_message");
Assert.AreEqual("single_int32", primitiveField.Name);
Assert.AreEqual("protobuf_unittest.TestAllTypes.single_int32",
Assert.AreEqual("protobuf_unittest3.TestAllTypes.single_int32",
primitiveField.FullName);
Assert.AreEqual(1, primitiveField.FieldNumber);
Assert.AreEqual(messageType, primitiveField.ContainingType);
@ -180,13 +190,13 @@ namespace Google.Protobuf.Reflection
EnumDescriptor nestedType = TestAllTypes.Descriptor.FindDescriptor<EnumDescriptor>("NestedEnum");
Assert.AreEqual("ForeignEnum", enumType.Name);
Assert.AreEqual("protobuf_unittest.ForeignEnum", enumType.FullName);
Assert.AreEqual("protobuf_unittest3.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",
Assert.AreEqual("protobuf_unittest3.TestAllTypes.NestedEnum",
nestedType.FullName);
Assert.AreEqual(UnittestProto3Reflection.Descriptor, nestedType.File);
Assert.AreEqual(TestAllTypes.Descriptor, nestedType.ContainingType);
@ -209,7 +219,7 @@ namespace Google.Protobuf.Reflection
{
OneofDescriptor descriptor = TestAllTypes.Descriptor.FindDescriptor<OneofDescriptor>("oneof_field");
Assert.AreEqual("oneof_field", descriptor.Name);
Assert.AreEqual("protobuf_unittest.TestAllTypes.oneof_field", descriptor.FullName);
Assert.AreEqual("protobuf_unittest3.TestAllTypes.oneof_field", descriptor.FullName);
var expectedFields = new[] {
TestAllTypes.OneofBytesFieldNumber,

@ -1,5 +1,5 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/map_unittest_proto3.proto
// source: map_unittest_proto3.proto
#pragma warning disable 1591, 0612, 3021
#region Designer generated code
@ -9,11 +9,11 @@ using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace Google.Protobuf.TestProtos {
/// <summary>Holder for reflection information generated from google/protobuf/map_unittest_proto3.proto</summary>
/// <summary>Holder for reflection information generated from map_unittest_proto3.proto</summary>
public static partial class MapUnittestProto3Reflection {
#region Descriptor
/// <summary>File descriptor for google/protobuf/map_unittest_proto3.proto</summary>
/// <summary>File descriptor for map_unittest_proto3.proto</summary>
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
@ -22,130 +22,130 @@ namespace Google.Protobuf.TestProtos {
static MapUnittestProto3Reflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"Cilnb29nbGUvcHJvdG9idWYvbWFwX3VuaXR0ZXN0X3Byb3RvMy5wcm90bxIR",
"cHJvdG9idWZfdW5pdHRlc3QaJWdvb2dsZS9wcm90b2J1Zi91bml0dGVzdF9w",
"cm90bzMucHJvdG8ilhIKB1Rlc3RNYXASRgoPbWFwX2ludDMyX2ludDMyGAEg",
"AygLMi0ucHJvdG9idWZfdW5pdHRlc3QuVGVzdE1hcC5NYXBJbnQzMkludDMy",
"RW50cnkSRgoPbWFwX2ludDY0X2ludDY0GAIgAygLMi0ucHJvdG9idWZfdW5p",
"dHRlc3QuVGVzdE1hcC5NYXBJbnQ2NEludDY0RW50cnkSSgoRbWFwX3VpbnQz",
"Ml91aW50MzIYAyADKAsyLy5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFwLk1h",
"cFVpbnQzMlVpbnQzMkVudHJ5EkoKEW1hcF91aW50NjRfdWludDY0GAQgAygL",
"Mi8ucHJvdG9idWZfdW5pdHRlc3QuVGVzdE1hcC5NYXBVaW50NjRVaW50NjRF",
"bnRyeRJKChFtYXBfc2ludDMyX3NpbnQzMhgFIAMoCzIvLnByb3RvYnVmX3Vu",
"aXR0ZXN0LlRlc3RNYXAuTWFwU2ludDMyU2ludDMyRW50cnkSSgoRbWFwX3Np",
"bnQ2NF9zaW50NjQYBiADKAsyLy5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFw",
"Lk1hcFNpbnQ2NFNpbnQ2NEVudHJ5Ek4KE21hcF9maXhlZDMyX2ZpeGVkMzIY",
"ByADKAsyMS5wcm90b2J1Zl91bml0dGVzdC5UZXN0TWFwLk1hcEZpeGVkMzJG",
"aXhlZDMyRW50cnk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VudW06AjgBGmEKG01hcEludDMyRm9y",
"ZWlnbk1lc3NhZ2VFbnRyeRILCgNrZXkYASABKAUSMQoFdmFsdWUYAiABKAsy",
"Ii5wcm90b2J1Zl91bml0dGVzdDMuRm9yZWlnbk1lc3NhZ2U6AjgBIuYBCh9N",
"ZXNzYWdlQ29udGFpbmluZ0VudW1DYWxsZWRUeXBlEksKBHR5cGUYASADKAsy",
"PS5wcm90b2J1Zl91bml0dGVzdDMuTWVzc2FnZUNvbnRhaW5pbmdFbnVtQ2Fs",
"bGVkVHlwZS5UeXBlRW50cnkaYAoJVHlwZUVudHJ5EgsKA2tleRgBIAEoBRJC",
"CgV2YWx1ZRgCIAEoCzIzLnByb3RvYnVmX3VuaXR0ZXN0My5NZXNzYWdlQ29u",
"dGFpbmluZ0VudW1DYWxsZWRUeXBlOgI4ASIUCgRUeXBlEgwKCFRZUEVfRk9P",
"EAAingEKH01lc3NhZ2VDb250YWluaW5nTWFwQ2FsbGVkRW50cnkSTQoFZW50",
"cnkYASADKAsyPi5wcm90b2J1Zl91bml0dGVzdDMuTWVzc2FnZUNvbnRhaW5p",
"bmdNYXBDYWxsZWRFbnRyeS5FbnRyeUVudHJ5GiwKCkVudHJ5RW50cnkSCwoD",
"a2V5GAEgASgFEg0KBXZhbHVlGAIgASgFOgI4ASo/CgdNYXBFbnVtEhAKDE1B",
"UF9FTlVNX0ZPTxAAEhAKDE1BUF9FTlVNX0JBUhABEhAKDE1BUF9FTlVNX0JB",
"WhACQh2qAhpHb29nbGUuUHJvdG9idWYuVGVzdFByb3Rvc2IGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.TestProtos.UnittestProto3Reflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.TestProtos.MapEnum), }, new pbr::GeneratedClrTypeInfo[] {

@ -27,7 +27,7 @@ namespace ProtobufTestMessages.Proto3 {
"dWYvYW55LnByb3RvGh5nb29nbGUvcHJvdG9idWYvZHVyYXRpb24ucHJvdG8a",
"IGdvb2dsZS9wcm90b2J1Zi9maWVsZF9tYXNrLnByb3RvGhxnb29nbGUvcHJv",
"dG9idWYvc3RydWN0LnByb3RvGh9nb29nbGUvcHJvdG9idWYvdGltZXN0YW1w",
"LnByb3RvGh5nb29nbGUvcHJvdG9idWYvd3JhcHBlcnMucHJvdG8irDsKElRl",
"LnByb3RvGh5nb29nbGUvcHJvdG9idWYvd3JhcHBlcnMucHJvdG8itDsKElRl",
"c3RBbGxUeXBlc1Byb3RvMxIWCg5vcHRpb25hbF9pbnQzMhgBIAEoBRIWCg5v",
"cHRpb25hbF9pbnQ2NBgCIAEoAxIXCg9vcHRpb25hbF91aW50MzIYAyABKA0S",
"FwoPb3B0aW9uYWxfdWludDY0GAQgASgEEhcKD29wdGlvbmFsX3NpbnQzMhgF",
@ -196,11 +196,11 @@ namespace ProtobufTestMessages.Proto3 {
"Z0ZvcmVpZ25FbnVtRW50cnkSCwoDa2V5GAEgASgJEjkKBXZhbHVlGAIgASgO",
"MioucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzMuRm9yZWlnbkVudW06",
"AjgBIjkKCk5lc3RlZEVudW0SBwoDRk9PEAASBwoDQkFSEAESBwoDQkFaEAIS",
"EAoDTkVHEP///////////wFCDQoLb25lb2ZfZmllbGQiGwoORm9yZWlnbk1l",
"c3NhZ2USCQoBYxgBIAEoBSpACgtGb3JlaWduRW51bRIPCgtGT1JFSUdOX0ZP",
"TxAAEg8KC0ZPUkVJR05fQkFSEAESDwoLRk9SRUlHTl9CQVoQAkI4Cihjb20u",
"Z29vZ2xlLnByb3RvYnVmX3Rlc3RfbWVzc2FnZXMucHJvdG8zSAH4AQGiAgZQ",
"cm90bzNiBnByb3RvMw=="));
"EAoDTkVHEP///////////wFCDQoLb25lb2ZfZmllbGRKBgj1AxD/AyIbCg5G",
"b3JlaWduTWVzc2FnZRIJCgFjGAEgASgFKkAKC0ZvcmVpZ25FbnVtEg8KC0ZP",
"UkVJR05fRk9PEAASDwoLRk9SRUlHTl9CQVIQARIPCgtGT1JFSUdOX0JBWhAC",
"QjgKKGNvbS5nb29nbGUucHJvdG9idWZfdGVzdF9tZXNzYWdlcy5wcm90bzNI",
"AfgBAaICBlByb3RvM2IGcHJvdG8z"));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.WellKnownTypes.AnyReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.DurationReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.FieldMaskReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.StructReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.TimestampReflection.Descriptor, global::Google.Protobuf.WellKnownTypes.WrappersReflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::ProtobufTestMessages.Proto3.ForeignEnum), }, new pbr::GeneratedClrTypeInfo[] {
@ -2808,7 +2808,10 @@ namespace ProtobufTestMessages.Proto3 {
OneofUint32 = other.OneofUint32;
break;
case OneofFieldOneofCase.OneofNestedMessage:
OneofNestedMessage = other.OneofNestedMessage;
if (OneofNestedMessage == null) {
OneofNestedMessage = new global::ProtobufTestMessages.Proto3.TestAllTypesProto3.Types.NestedMessage();
}
OneofNestedMessage.MergeFrom(other.OneofNestedMessage);
break;
case OneofFieldOneofCase.OneofString:
OneofString = other.OneofString;

@ -1,5 +1,5 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/unittest_import_proto3.proto
// source: unittest_import_proto3.proto
#pragma warning disable 1591, 0612, 3021
#region Designer generated code
@ -9,11 +9,11 @@ using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace Google.Protobuf.TestProtos {
/// <summary>Holder for reflection information generated from google/protobuf/unittest_import_proto3.proto</summary>
/// <summary>Holder for reflection information generated from unittest_import_proto3.proto</summary>
public static partial class UnittestImportProto3Reflection {
#region Descriptor
/// <summary>File descriptor for google/protobuf/unittest_import_proto3.proto</summary>
/// <summary>File descriptor for unittest_import_proto3.proto</summary>
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
@ -22,14 +22,12 @@ namespace Google.Protobuf.TestProtos {
static UnittestImportProto3Reflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"Cixnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0X3Byb3RvMy5wcm90",
"bxIYcHJvdG9idWZfdW5pdHRlc3RfaW1wb3J0GjNnb29nbGUvcHJvdG9idWYv",
"dW5pdHRlc3RfaW1wb3J0X3B1YmxpY19wcm90bzMucHJvdG8iGgoNSW1wb3J0",
"TWVzc2FnZRIJCgFkGAEgASgFKlkKCkltcG9ydEVudW0SGwoXSU1QT1JUX0VO",
"VU1fVU5TUEVDSUZJRUQQABIOCgpJTVBPUlRfRk9PEAcSDgoKSU1QT1JUX0JB",
"UhAIEg4KCklNUE9SVF9CQVoQCUI8Chhjb20uZ29vZ2xlLnByb3RvYnVmLnRl",
"c3RIAfgBAaoCGkdvb2dsZS5Qcm90b2J1Zi5UZXN0UHJvdG9zUABiBnByb3Rv",
"Mw=="));
"Chx1bml0dGVzdF9pbXBvcnRfcHJvdG8zLnByb3RvEhhwcm90b2J1Zl91bml0",
"dGVzdF9pbXBvcnQaI3VuaXR0ZXN0X2ltcG9ydF9wdWJsaWNfcHJvdG8zLnBy",
"b3RvIhoKDUltcG9ydE1lc3NhZ2USCQoBZBgBIAEoBSpZCgpJbXBvcnRFbnVt",
"EhsKF0lNUE9SVF9FTlVNX1VOU1BFQ0lGSUVEEAASDgoKSU1QT1JUX0ZPTxAH",
"Eg4KCklNUE9SVF9CQVIQCBIOCgpJTVBPUlRfQkFaEAlCHaoCGkdvb2dsZS5Q",
"cm90b2J1Zi5UZXN0UHJvdG9zUABiBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.TestProtos.UnittestImportPublicProto3Reflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.TestProtos.ImportEnum), }, new pbr::GeneratedClrTypeInfo[] {

@ -1,5 +1,5 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/unittest_import_public_proto3.proto
// source: unittest_import_public_proto3.proto
#pragma warning disable 1591, 0612, 3021
#region Designer generated code
@ -9,11 +9,11 @@ using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace Google.Protobuf.TestProtos {
/// <summary>Holder for reflection information generated from google/protobuf/unittest_import_public_proto3.proto</summary>
/// <summary>Holder for reflection information generated from unittest_import_public_proto3.proto</summary>
public static partial class UnittestImportPublicProto3Reflection {
#region Descriptor
/// <summary>File descriptor for google/protobuf/unittest_import_public_proto3.proto</summary>
/// <summary>File descriptor for unittest_import_public_proto3.proto</summary>
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
@ -22,10 +22,10 @@ namespace Google.Protobuf.TestProtos {
static UnittestImportPublicProto3Reflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"CjNnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfaW1wb3J0X3B1YmxpY19wcm90",
"bzMucHJvdG8SGHByb3RvYnVmX3VuaXR0ZXN0X2ltcG9ydCIgChNQdWJsaWNJ",
"bXBvcnRNZXNzYWdlEgkKAWUYASABKAVCNwoYY29tLmdvb2dsZS5wcm90b2J1",
"Zi50ZXN0qgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3NiBnByb3RvMw=="));
"CiN1bml0dGVzdF9pbXBvcnRfcHVibGljX3Byb3RvMy5wcm90bxIYcHJvdG9i",
"dWZfdW5pdHRlc3RfaW1wb3J0IiAKE1B1YmxpY0ltcG9ydE1lc3NhZ2USCQoB",
"ZRgBIAEoBUIdqgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQcm90b3NiBnByb3Rv",
"Mw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] {

@ -48,8 +48,8 @@ namespace UnitTest.Issues.TestProtos {
"GAEgASgFEgkKAXkYAiABKAVCBwoFdmFsdWUqVQoMTmVnYXRpdmVFbnVtEhYK",
"Ek5FR0FUSVZFX0VOVU1fWkVSTxAAEhYKCUZpdmVCZWxvdxD7//////////8B",
"EhUKCE1pbnVzT25lEP///////////wEqLgoORGVwcmVjYXRlZEVudW0SEwoP",
"REVQUkVDQVRFRF9aRVJPEAASBwoDb25lEAFCH0gBqgIaVW5pdFRlc3QuSXNz",
"dWVzLlRlc3RQcm90b3NiBnByb3RvMw=="));
"REVQUkVDQVRFRF9aRVJPEAASBwoDb25lEAFCHaoCGlVuaXRUZXN0Lklzc3Vl",
"cy5UZXN0UHJvdG9zYgZwcm90bzM="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::UnitTest.Issues.TestProtos.NegativeEnum), typeof(global::UnitTest.Issues.TestProtos.DeprecatedEnum), }, new pbr::GeneratedClrTypeInfo[] {

@ -1,5 +1,5 @@
// Generated by the protocol buffer compiler. DO NOT EDIT!
// source: google/protobuf/unittest_proto3.proto
// source: unittest_proto3.proto
#pragma warning disable 1591, 0612, 3021
#region Designer generated code
@ -9,11 +9,11 @@ using pbr = global::Google.Protobuf.Reflection;
using scg = global::System.Collections.Generic;
namespace Google.Protobuf.TestProtos {
/// <summary>Holder for reflection information generated from google/protobuf/unittest_proto3.proto</summary>
/// <summary>Holder for reflection information generated from unittest_proto3.proto</summary>
public static partial class UnittestProto3Reflection {
#region Descriptor
/// <summary>File descriptor for google/protobuf/unittest_proto3.proto</summary>
/// <summary>File descriptor for unittest_proto3.proto</summary>
public static pbr::FileDescriptor Descriptor {
get { return descriptor; }
}
@ -22,135 +22,135 @@ namespace Google.Protobuf.TestProtos {
static UnittestProto3Reflection() {
byte[] descriptorData = global::System.Convert.FromBase64String(
string.Concat(
"CiVnb29nbGUvcHJvdG9idWYvdW5pdHRlc3RfcHJvdG8zLnByb3RvEhFwcm90",
"b2J1Zl91bml0dGVzdBosZ29vZ2xlL3Byb3RvYnVmL3VuaXR0ZXN0X2ltcG9y",
"dF9wcm90bzMucHJvdG8i8A8KDFRlc3RBbGxUeXBlcxIUCgxzaW5nbGVfaW50",
"MzIYASABKAUSFAoMc2luZ2xlX2ludDY0GAIgASgDEhUKDXNpbmdsZV91aW50",
"MzIYAyABKA0SFQoNc2luZ2xlX3VpbnQ2NBgEIAEoBBIVCg1zaW5nbGVfc2lu",
"dDMyGAUgASgREhUKDXNpbmdsZV9zaW50NjQYBiABKBISFgoOc2luZ2xlX2Zp",
"eGVkMzIYByABKAcSFgoOc2luZ2xlX2ZpeGVkNjQYCCABKAYSFwoPc2luZ2xl",
"X3NmaXhlZDMyGAkgASgPEhcKD3NpbmdsZV9zZml4ZWQ2NBgKIAEoEBIUCgxz",
"aW5nbGVfZmxvYXQYCyABKAISFQoNc2luZ2xlX2RvdWJsZRgMIAEoARITCgtz",
"aW5nbGVfYm9vbBgNIAEoCBIVCg1zaW5nbGVfc3RyaW5nGA4gASgJEhQKDHNp",
"bmdsZV9ieXRlcxgPIAEoDBJMChVzaW5nbGVfbmVzdGVkX21lc3NhZ2UYEiAB",
"KAsyLS5wcm90b2J1Zl91bml0dGVzdC5UZXN0QWxsVHlwZXMuTmVzdGVkTWVz",
"c2FnZRJBChZzaW5nbGVfZm9yZWlnbl9tZXNzYWdlGBMgASgLMiEucHJvdG9i",
"dWZfdW5pdHRlc3QuRm9yZWlnbk1lc3NhZ2USRgoVc2luZ2xlX2ltcG9ydF9t",
"ZXNzYWdlGBQgASgLMicucHJvdG9idWZfdW5pdHRlc3RfaW1wb3J0LkltcG9y",
"dE1lc3NhZ2USRgoSc2luZ2xlX25lc3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BCgtUZXN0U2VydmljZRJGCgNG",
"b28SHi5wcm90b2J1Zl91bml0dGVzdDMuRm9vUmVxdWVzdBofLnByb3RvYnVm",
"X3VuaXR0ZXN0My5Gb29SZXNwb25zZRJGCgNCYXISHi5wcm90b2J1Zl91bml0",
"dGVzdDMuQmFyUmVxdWVzdBofLnByb3RvYnVmX3VuaXR0ZXN0My5CYXJSZXNw",
"b25zZUIsQg1Vbml0dGVzdFByb3RvqgIaR29vZ2xlLlByb3RvYnVmLlRlc3RQ",
"cm90b3NiBnByb3RvMw=="));
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
new pbr::FileDescriptor[] { global::Google.Protobuf.TestProtos.UnittestImportProto3Reflection.Descriptor, },
new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Google.Protobuf.TestProtos.ForeignEnum), typeof(global::Google.Protobuf.TestProtos.TestEnumWithDupValue), typeof(global::Google.Protobuf.TestProtos.TestSparseEnum), }, new pbr::GeneratedClrTypeInfo[] {
@ -1337,7 +1337,10 @@ namespace Google.Protobuf.TestProtos {
OneofUint32 = other.OneofUint32;
break;
case OneofFieldOneofCase.OneofNestedMessage:
OneofNestedMessage = other.OneofNestedMessage;
if (OneofNestedMessage == null) {
OneofNestedMessage = new global::Google.Protobuf.TestProtos.TestAllTypes.Types.NestedMessage();
}
OneofNestedMessage.MergeFrom(other.OneofNestedMessage);
break;
case OneofFieldOneofCase.OneofString:
OneofString = other.OneofString;
@ -5066,7 +5069,10 @@ namespace Google.Protobuf.TestProtos {
FooString = other.FooString;
break;
case FooOneofCase.FooMessage:
FooMessage = other.FooMessage;
if (FooMessage == null) {
FooMessage = new global::Google.Protobuf.TestProtos.TestAllTypes();
}
FooMessage.MergeFrom(other.FooMessage);
break;
}

@ -1890,31 +1890,58 @@ namespace Google.Protobuf.TestProtos {
}
switch (other.OneofFieldCase) {
case OneofFieldOneofCase.AnyField:
AnyField = other.AnyField;
if (AnyField == null) {
AnyField = new global::Google.Protobuf.WellKnownTypes.Any();
}
AnyField.MergeFrom(other.AnyField);
break;
case OneofFieldOneofCase.ApiField:
ApiField = other.ApiField;
if (ApiField == null) {
ApiField = new global::Google.Protobuf.WellKnownTypes.Api();
}
ApiField.MergeFrom(other.ApiField);
break;
case OneofFieldOneofCase.DurationField:
DurationField = other.DurationField;
if (DurationField == null) {
DurationField = new global::Google.Protobuf.WellKnownTypes.Duration();
}
DurationField.MergeFrom(other.DurationField);
break;
case OneofFieldOneofCase.EmptyField:
EmptyField = other.EmptyField;
if (EmptyField == null) {
EmptyField = new global::Google.Protobuf.WellKnownTypes.Empty();
}
EmptyField.MergeFrom(other.EmptyField);
break;
case OneofFieldOneofCase.FieldMaskField:
FieldMaskField = other.FieldMaskField;
if (FieldMaskField == null) {
FieldMaskField = new global::Google.Protobuf.WellKnownTypes.FieldMask();
}
FieldMaskField.MergeFrom(other.FieldMaskField);
break;
case OneofFieldOneofCase.SourceContextField:
SourceContextField = other.SourceContextField;
if (SourceContextField == null) {
SourceContextField = new global::Google.Protobuf.WellKnownTypes.SourceContext();
}
SourceContextField.MergeFrom(other.SourceContextField);
break;
case OneofFieldOneofCase.StructField:
StructField = other.StructField;
if (StructField == null) {
StructField = new global::Google.Protobuf.WellKnownTypes.Struct();
}
StructField.MergeFrom(other.StructField);
break;
case OneofFieldOneofCase.TimestampField:
TimestampField = other.TimestampField;
if (TimestampField == null) {
TimestampField = new global::Google.Protobuf.WellKnownTypes.Timestamp();
}
TimestampField.MergeFrom(other.TimestampField);
break;
case OneofFieldOneofCase.TypeField:
TypeField = other.TypeField;
if (TypeField == null) {
TypeField = new global::Google.Protobuf.WellKnownTypes.Type();
}
TypeField.MergeFrom(other.TypeField);
break;
case OneofFieldOneofCase.DoubleField:
DoubleField = other.DoubleField;

@ -42,7 +42,7 @@ namespace Google.Protobuf.WellKnownTypes
{
var message = SampleMessages.CreateFullTestAllTypes();
var any = Any.Pack(message);
Assert.AreEqual("type.googleapis.com/protobuf_unittest.TestAllTypes", any.TypeUrl);
Assert.AreEqual("type.googleapis.com/protobuf_unittest3.TestAllTypes", any.TypeUrl);
Assert.AreEqual(message.CalculateSize(), any.Value.Length);
}
@ -51,7 +51,7 @@ namespace Google.Protobuf.WellKnownTypes
{
var message = SampleMessages.CreateFullTestAllTypes();
var any = Any.Pack(message, "foo.bar/baz");
Assert.AreEqual("foo.bar/baz/protobuf_unittest.TestAllTypes", any.TypeUrl);
Assert.AreEqual("foo.bar/baz/protobuf_unittest3.TestAllTypes", any.TypeUrl);
Assert.AreEqual(message.CalculateSize(), any.Value.Length);
}
@ -60,7 +60,7 @@ namespace Google.Protobuf.WellKnownTypes
{
var message = SampleMessages.CreateFullTestAllTypes();
var any = Any.Pack(message, "foo.bar/baz/");
Assert.AreEqual("foo.bar/baz/protobuf_unittest.TestAllTypes", any.TypeUrl);
Assert.AreEqual("foo.bar/baz/protobuf_unittest3.TestAllTypes", any.TypeUrl);
Assert.AreEqual(message.CalculateSize(), any.Value.Length);
}

@ -4,7 +4,7 @@
<Description>C# runtime library for Protocol Buffers - Google's data interchange format.</Description>
<Copyright>Copyright 2015, Google Inc.</Copyright>
<AssemblyTitle>Google Protocol Buffers</AssemblyTitle>
<VersionPrefix>3.4.1</VersionPrefix>
<VersionPrefix>3.5.0</VersionPrefix>
<Authors>Google Inc.</Authors>
<TargetFrameworks>netstandard1.0;net45</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>

@ -245,7 +245,7 @@ namespace Google.Protobuf
state = State.ObjectAfterColon;
break;
case ',':
ValidateState(State.ObjectAfterProperty | State.ArrayAfterValue, "Invalid state to read a colon: ");
ValidateState(State.ObjectAfterProperty | State.ArrayAfterValue, "Invalid state to read a comma: ");
state = state == State.ObjectAfterProperty ? State.ObjectAfterComma : State.ArrayAfterComma;
break;
case '"':

@ -162,3 +162,4 @@ There are miscellaneous other things you may find useful as a Protocol Buffers d
* [Protocol Buffers Dynamic Schema - create protobuf schemas programmatically (Java)] (https://github.com/os72/protobuf-dynamic)
* [Make protoc plugins in NodeJS](https://github.com/konsumer/node-protoc-plugin)
* [ProfaneDB - A Protocol Buffers database](https://profanedb.gitlab.io)
* [Protocol Buffer property-based testing utility and example message generator (Python / Hypothesis)](https://github.com/CurataEng/hypothesis-protobuf)

@ -6,7 +6,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.4.1</version>
<version>3.5.0</version>
</parent>
<artifactId>protobuf-java</artifactId>

@ -64,6 +64,14 @@ public abstract class CodedInputStream {
// Integer.MAX_VALUE == 0x7FFFFFF == INT_MAX from limits.h
private static final int DEFAULT_SIZE_LIMIT = Integer.MAX_VALUE;
/**
* Whether to enable our custom UTF-8 decode codepath which does not use {@link StringCoding}.
* Enabled by default, disable by setting
* {@code -Dcom.google.protobuf.enableCustomutf8Decode=false} in JVM args.
*/
private static final boolean ENABLE_CUSTOM_UTF8_DECODE
= !"false".equals(System.getProperty("com.google.protobuf.enableCustomUtf8Decode"));
/** Visible for subclasses. See setRecursionLimit() */
int recursionDepth;
@ -825,13 +833,19 @@ public abstract class CodedInputStream {
public String readStringRequireUtf8() throws IOException {
final int size = readRawVarint32();
if (size > 0 && size <= (limit - pos)) {
// TODO(martinrb): We could save a pass by validating while decoding.
if (!Utf8.isValidUtf8(buffer, pos, pos + size)) {
throw InvalidProtocolBufferException.invalidUtf8();
if (ENABLE_CUSTOM_UTF8_DECODE) {
String result = Utf8.decodeUtf8(buffer, pos, size);
pos += size;
return result;
} else {
// TODO(martinrb): We could save a pass by validating while decoding.
if (!Utf8.isValidUtf8(buffer, pos, pos + size)) {
throw InvalidProtocolBufferException.invalidUtf8();
}
final int tempPos = pos;
pos += size;
return new String(buffer, tempPos, size, UTF_8);
}
final int tempPos = pos;
pos += size;
return new String(buffer, tempPos, size, UTF_8);
}
if (size == 0) {
@ -1524,6 +1538,8 @@ public abstract class CodedInputStream {
final int size = readRawVarint32();
if (size > 0 && size <= remaining()) {
// TODO(nathanmittler): Is there a way to avoid this copy?
// TODO(anuraaga): It might be possible to share the optimized loop with
// readStringRequireUtf8 by implementing Java replacement logic there.
// The same as readBytes' logic
byte[] bytes = new byte[size];
UnsafeUtil.copyMemory(pos, bytes, 0, size);
@ -1544,19 +1560,26 @@ public abstract class CodedInputStream {
@Override
public String readStringRequireUtf8() throws IOException {
final int size = readRawVarint32();
if (size >= 0 && size <= remaining()) {
// TODO(nathanmittler): Is there a way to avoid this copy?
// The same as readBytes' logic
byte[] bytes = new byte[size];
UnsafeUtil.copyMemory(pos, bytes, 0, size);
// TODO(martinrb): We could save a pass by validating while decoding.
if (!Utf8.isValidUtf8(bytes)) {
throw InvalidProtocolBufferException.invalidUtf8();
}
if (size > 0 && size <= remaining()) {
if (ENABLE_CUSTOM_UTF8_DECODE) {
final int bufferPos = bufferPos(pos);
String result = Utf8.decodeUtf8(buffer, bufferPos, size);
pos += size;
return result;
} else {
// TODO(nathanmittler): Is there a way to avoid this copy?
// The same as readBytes' logic
byte[] bytes = new byte[size];
UnsafeUtil.copyMemory(pos, bytes, 0, size);
// TODO(martinrb): We could save a pass by validating while decoding.
if (!Utf8.isValidUtf8(bytes)) {
throw InvalidProtocolBufferException.invalidUtf8();
}
String result = new String(bytes, UTF_8);
pos += size;
return result;
String result = new String(bytes, UTF_8);
pos += size;
return result;
}
}
if (size == 0) {
@ -2324,11 +2347,15 @@ public abstract class CodedInputStream {
bytes = readRawBytesSlowPath(size);
tempPos = 0;
}
// TODO(martinrb): We could save a pass by validating while decoding.
if (!Utf8.isValidUtf8(bytes, tempPos, tempPos + size)) {
throw InvalidProtocolBufferException.invalidUtf8();
if (ENABLE_CUSTOM_UTF8_DECODE) {
return Utf8.decodeUtf8(bytes, tempPos, size);
} else {
// TODO(martinrb): We could save a pass by validating while decoding.
if (!Utf8.isValidUtf8(bytes, tempPos, tempPos + size)) {
throw InvalidProtocolBufferException.invalidUtf8();
}
return new String(bytes, tempPos, size, UTF_8);
}
return new String(bytes, tempPos, size, UTF_8);
}
@Override
@ -3348,23 +3375,34 @@ public abstract class CodedInputStream {
public String readStringRequireUtf8() throws IOException {
final int size = readRawVarint32();
if (size > 0 && size <= currentByteBufferLimit - currentByteBufferPos) {
byte[] bytes = new byte[size];
UnsafeUtil.copyMemory(currentByteBufferPos, bytes, 0, size);
if (!Utf8.isValidUtf8(bytes)) {
throw InvalidProtocolBufferException.invalidUtf8();
if (ENABLE_CUSTOM_UTF8_DECODE) {
final int bufferPos = (int) (currentByteBufferPos - currentByteBufferStartPos);
String result = Utf8.decodeUtf8(currentByteBuffer, bufferPos, size);
currentByteBufferPos += size;
return result;
} else {
byte[] bytes = new byte[size];
UnsafeUtil.copyMemory(currentByteBufferPos, bytes, 0, size);
if (!Utf8.isValidUtf8(bytes)) {
throw InvalidProtocolBufferException.invalidUtf8();
}
String result = new String(bytes, UTF_8);
currentByteBufferPos += size;
return result;
}
String result = new String(bytes, UTF_8);
currentByteBufferPos += size;
return result;
}
if (size >= 0 && size <= remaining()) {
byte[] bytes = new byte[size];
readRawBytesTo(bytes, 0, size);
if (!Utf8.isValidUtf8(bytes)) {
throw InvalidProtocolBufferException.invalidUtf8();
if (ENABLE_CUSTOM_UTF8_DECODE) {
return Utf8.decodeUtf8(bytes, 0, size);
} else {
if (!Utf8.isValidUtf8(bytes)) {
throw InvalidProtocolBufferException.invalidUtf8();
}
String result = new String(bytes, UTF_8);
return result;
}
String result = new String(bytes, UTF_8);
return result;
}
if (size == 0) {

@ -33,7 +33,6 @@ package com.google.protobuf;
import java.lang.reflect.Field;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.security.AccessController;
import java.security.PrivilegedExceptionAction;
import java.util.logging.Level;
@ -72,6 +71,8 @@ final class UnsafeUtil {
private static final long BUFFER_ADDRESS_OFFSET = fieldOffset(bufferAddressField());
private static final long STRING_VALUE_OFFSET = fieldOffset(stringValueField());
private UnsafeUtil() {}
static boolean hasUnsafeArrayOperations() {
@ -259,6 +260,26 @@ final class UnsafeUtil {
return MEMORY_ACCESSOR.getLong(buffer, BUFFER_ADDRESS_OFFSET);
}
/**
* Returns a new {@link String} backed by the given {@code chars}. The char array should not
* be mutated any more after calling this function.
*/
static String moveToString(char[] chars) {
if (STRING_VALUE_OFFSET == -1) {
// In the off-chance that this JDK does not implement String as we'd expect, just do a copy.
return new String(chars);
}
final String str;
try {
str = (String) UNSAFE.allocateInstance(String.class);
} catch (InstantiationException e) {
// This should never happen, but return a copy as a fallback just in case.
return new String(chars);
}
putObject(str, STRING_VALUE_OFFSET, chars);
return str;
}
static Object getStaticObject(Field field) {
return MEMORY_ACCESSOR.getStaticObject(field);
}
@ -366,7 +387,12 @@ final class UnsafeUtil {
/** Finds the address field within a direct {@link Buffer}. */
private static Field bufferAddressField() {
return field(Buffer.class, "address");
return field(Buffer.class, "address", long.class);
}
/** Finds the value field within a {@link String}. */
private static Field stringValueField() {
return field(String.class, "value", char[].class);
}
/**
@ -381,11 +407,14 @@ final class UnsafeUtil {
* Gets the field with the given name within the class, or {@code null} if not found. If found,
* the field is made accessible.
*/
private static Field field(Class<?> clazz, String fieldName) {
private static Field field(Class<?> clazz, String fieldName, Class<?> expectedType) {
Field field;
try {
field = clazz.getDeclaredField(fieldName);
field.setAccessible(true);
if (!field.getType().equals(expectedType)) {
return null;
}
} catch (Throwable t) {
// Failed to access the fields.
field = null;

@ -34,11 +34,15 @@ import static com.google.protobuf.UnsafeUtil.addressOffset;
import static com.google.protobuf.UnsafeUtil.hasUnsafeArrayOperations;
import static com.google.protobuf.UnsafeUtil.hasUnsafeByteBufferOperations;
import static java.lang.Character.MAX_SURROGATE;
import static java.lang.Character.MIN_HIGH_SURROGATE;
import static java.lang.Character.MIN_LOW_SURROGATE;
import static java.lang.Character.MIN_SUPPLEMENTARY_CODE_POINT;
import static java.lang.Character.MIN_SURROGATE;
import static java.lang.Character.isSurrogatePair;
import static java.lang.Character.toCodePoint;
import java.nio.ByteBuffer;
import java.util.Arrays;
/**
* A set of low-level, high-performance static utility methods related
@ -289,7 +293,7 @@ final class Utf8 {
if (Character.MIN_SURROGATE <= c && c <= Character.MAX_SURROGATE) {
// Check that we have a well-formed surrogate pair.
int cp = Character.codePointAt(sequence, i);
if (cp < Character.MIN_SUPPLEMENTARY_CODE_POINT) {
if (cp < MIN_SUPPLEMENTARY_CODE_POINT) {
throw new UnpairedSurrogateException(i, utf16Length);
}
i++;
@ -330,6 +334,26 @@ final class Utf8 {
return processor.partialIsValidUtf8(state, buffer, index, limit);
}
/**
* Decodes the given UTF-8 portion of the {@link ByteBuffer} into a {@link String}.
*
* @throws InvalidProtocolBufferException if the input is not valid UTF-8.
*/
static String decodeUtf8(ByteBuffer buffer, int index, int size)
throws InvalidProtocolBufferException {
return processor.decodeUtf8(buffer, index, size);
}
/**
* Decodes the given UTF-8 encoded byte array slice into a {@link String}.
*
* @throws InvalidProtocolBufferException if the input is not valid UTF-8.
*/
static String decodeUtf8(byte[] bytes, int index, int size)
throws InvalidProtocolBufferException {
return processor.decodeUtf8(bytes, index, size);
}
/**
* Encodes the given characters to the target {@link ByteBuffer} using UTF-8 encoding.
*
@ -609,6 +633,116 @@ final class Utf8 {
}
}
/**
* Decodes the given byte array slice into a {@link String}.
*
* @throws InvalidProtocolBufferException if the byte array slice is not valid UTF-8.
*/
abstract String decodeUtf8(byte[] bytes, int index, int size)
throws InvalidProtocolBufferException;
/**
* Decodes the given portion of the {@link ByteBuffer} into a {@link String}.
*
* @throws InvalidProtocolBufferException if the portion of the buffer is not valid UTF-8.
*/
final String decodeUtf8(ByteBuffer buffer, int index, int size)
throws InvalidProtocolBufferException {
if (buffer.hasArray()) {
final int offset = buffer.arrayOffset();
return decodeUtf8(buffer.array(), offset + index, size);
} else if (buffer.isDirect()) {
return decodeUtf8Direct(buffer, index, size);
}
return decodeUtf8Default(buffer, index, size);
}
/**
* Decodes direct {@link ByteBuffer} instances into {@link String}.
*/
abstract String decodeUtf8Direct(ByteBuffer buffer, int index, int size)
throws InvalidProtocolBufferException;
/**
* Decodes {@link ByteBuffer} instances using the {@link ByteBuffer} API rather than
* potentially faster approaches.
*/
final String decodeUtf8Default(ByteBuffer buffer, int index, int size)
throws InvalidProtocolBufferException {
// Bitwise OR combines the sign bits so any negative value fails the check.
if ((index | size | buffer.limit() - index - size) < 0) {
throw new ArrayIndexOutOfBoundsException(
String.format("buffer limit=%d, index=%d, limit=%d", buffer.limit(), index, size));
}
int offset = index;
final int limit = offset + size;
// The longest possible resulting String is the same as the number of input bytes, when it is
// all ASCII. For other cases, this over-allocates and we will truncate in the end.
char[] resultArr = new char[size];
int resultPos = 0;
// Optimize for 100% ASCII (Hotspot loves small simple top-level loops like this).
// This simple loop stops when we encounter a byte >= 0x80 (i.e. non-ASCII).
while (offset < limit) {
byte b = buffer.get(offset);
if (!DecodeUtil.isOneByte(b)) {
break;
}
offset++;
DecodeUtil.handleOneByte(b, resultArr, resultPos++);
}
while (offset < limit) {
byte byte1 = buffer.get(offset++);
if (DecodeUtil.isOneByte(byte1)) {
DecodeUtil.handleOneByte(byte1, resultArr, resultPos++);
// It's common for there to be multiple ASCII characters in a run mixed in, so add an
// extra optimized loop to take care of these runs.
while (offset < limit) {
byte b = buffer.get(offset);
if (!DecodeUtil.isOneByte(b)) {
break;
}
offset++;
DecodeUtil.handleOneByte(b, resultArr, resultPos++);
}
} else if (DecodeUtil.isTwoBytes(byte1)) {
if (offset >= limit) {
throw InvalidProtocolBufferException.invalidUtf8();
}
DecodeUtil.handleTwoBytes(
byte1, /* byte2 */ buffer.get(offset++), resultArr, resultPos++);
} else if (DecodeUtil.isThreeBytes(byte1)) {
if (offset >= limit - 1) {
throw InvalidProtocolBufferException.invalidUtf8();
}
DecodeUtil.handleThreeBytes(
byte1,
/* byte2 */ buffer.get(offset++),
/* byte3 */ buffer.get(offset++),
resultArr,
resultPos++);
} else {
if (offset >= limit - 2) {
throw InvalidProtocolBufferException.invalidUtf8();
}
DecodeUtil.handleFourBytes(
byte1,
/* byte2 */ buffer.get(offset++),
/* byte3 */ buffer.get(offset++),
/* byte4 */ buffer.get(offset++),
resultArr,
resultPos++);
// 4-byte case requires two chars.
resultPos++;
}
}
return new String(resultArr, 0, resultPos);
}
/**
* Encodes an input character sequence ({@code in}) to UTF-8 in the target array ({@code out}).
* For a string, this method is similar to
@ -850,6 +984,88 @@ final class Utf8 {
return partialIsValidUtf8Default(state, buffer, index, limit);
}
@Override
String decodeUtf8(byte[] bytes, int index, int size) throws InvalidProtocolBufferException {
// Bitwise OR combines the sign bits so any negative value fails the check.
if ((index | size | bytes.length - index - size) < 0) {
throw new ArrayIndexOutOfBoundsException(
String.format("buffer length=%d, index=%d, size=%d", bytes.length, index, size));
}
int offset = index;
final int limit = offset + size;
// The longest possible resulting String is the same as the number of input bytes, when it is
// all ASCII. For other cases, this over-allocates and we will truncate in the end.
char[] resultArr = new char[size];
int resultPos = 0;
// Optimize for 100% ASCII (Hotspot loves small simple top-level loops like this).
// This simple loop stops when we encounter a byte >= 0x80 (i.e. non-ASCII).
while (offset < limit) {
byte b = bytes[offset];
if (!DecodeUtil.isOneByte(b)) {
break;
}
offset++;
DecodeUtil.handleOneByte(b, resultArr, resultPos++);
}
while (offset < limit) {
byte byte1 = bytes[offset++];
if (DecodeUtil.isOneByte(byte1)) {
DecodeUtil.handleOneByte(byte1, resultArr, resultPos++);
// It's common for there to be multiple ASCII characters in a run mixed in, so add an
// extra optimized loop to take care of these runs.
while (offset < limit) {
byte b = bytes[offset];
if (!DecodeUtil.isOneByte(b)) {
break;
}
offset++;
DecodeUtil.handleOneByte(b, resultArr, resultPos++);
}
} else if (DecodeUtil.isTwoBytes(byte1)) {
if (offset >= limit) {
throw InvalidProtocolBufferException.invalidUtf8();
}
DecodeUtil.handleTwoBytes(byte1, /* byte2 */ bytes[offset++], resultArr, resultPos++);
} else if (DecodeUtil.isThreeBytes(byte1)) {
if (offset >= limit - 1) {
throw InvalidProtocolBufferException.invalidUtf8();
}
DecodeUtil.handleThreeBytes(
byte1,
/* byte2 */ bytes[offset++],
/* byte3 */ bytes[offset++],
resultArr,
resultPos++);
} else {
if (offset >= limit - 2) {
throw InvalidProtocolBufferException.invalidUtf8();
}
DecodeUtil.handleFourBytes(
byte1,
/* byte2 */ bytes[offset++],
/* byte3 */ bytes[offset++],
/* byte4 */ bytes[offset++],
resultArr,
resultPos++);
// 4-byte case requires two chars.
resultPos++;
}
}
return new String(resultArr, 0, resultPos);
}
@Override
String decodeUtf8Direct(ByteBuffer buffer, int index, int size)
throws InvalidProtocolBufferException {
// For safe processing, we have to use the ByteBufferAPI.
return decodeUtf8Default(buffer, index, size);
}
@Override
int encodeUtf8(CharSequence in, byte[] out, int offset, int length) {
int utf16Length = in.length();
@ -996,6 +1212,7 @@ final class Utf8 {
@Override
int partialIsValidUtf8(int state, byte[] bytes, final int index, final int limit) {
// Bitwise OR combines the sign bits so any negative value fails the check.
if ((index | limit | bytes.length - limit) < 0) {
throw new ArrayIndexOutOfBoundsException(
String.format("Array length=%d, index=%d, limit=%d", bytes.length, index, limit));
@ -1091,6 +1308,7 @@ final class Utf8 {
@Override
int partialIsValidUtf8Direct(
final int state, ByteBuffer buffer, final int index, final int limit) {
// Bitwise OR combines the sign bits so any negative value fails the check.
if ((index | limit | buffer.limit() - limit) < 0) {
throw new ArrayIndexOutOfBoundsException(
String.format("buffer limit=%d, index=%d, limit=%d", buffer.limit(), index, limit));
@ -1184,6 +1402,163 @@ final class Utf8 {
return partialIsValidUtf8(address, (int) (addressLimit - address));
}
@Override
String decodeUtf8(byte[] bytes, int index, int size) throws InvalidProtocolBufferException {
if ((index | size | bytes.length - index - size) < 0) {
throw new ArrayIndexOutOfBoundsException(
String.format("buffer length=%d, index=%d, size=%d", bytes.length, index, size));
}
int offset = index;
final int limit = offset + size;
// The longest possible resulting String is the same as the number of input bytes, when it is
// all ASCII. For other cases, this over-allocates and we will truncate in the end.
char[] resultArr = new char[size];
int resultPos = 0;
// Optimize for 100% ASCII (Hotspot loves small simple top-level loops like this).
// This simple loop stops when we encounter a byte >= 0x80 (i.e. non-ASCII).
while (offset < limit) {
byte b = UnsafeUtil.getByte(bytes, offset);
if (!DecodeUtil.isOneByte(b)) {
break;
}
offset++;
DecodeUtil.handleOneByte(b, resultArr, resultPos++);
}
while (offset < limit) {
byte byte1 = UnsafeUtil.getByte(bytes, offset++);
if (DecodeUtil.isOneByte(byte1)) {
DecodeUtil.handleOneByte(byte1, resultArr, resultPos++);
// It's common for there to be multiple ASCII characters in a run mixed in, so add an
// extra optimized loop to take care of these runs.
while (offset < limit) {
byte b = UnsafeUtil.getByte(bytes, offset);
if (!DecodeUtil.isOneByte(b)) {
break;
}
offset++;
DecodeUtil.handleOneByte(b, resultArr, resultPos++);
}
} else if (DecodeUtil.isTwoBytes(byte1)) {
if (offset >= limit) {
throw InvalidProtocolBufferException.invalidUtf8();
}
DecodeUtil.handleTwoBytes(
byte1, /* byte2 */ UnsafeUtil.getByte(bytes, offset++), resultArr, resultPos++);
} else if (DecodeUtil.isThreeBytes(byte1)) {
if (offset >= limit - 1) {
throw InvalidProtocolBufferException.invalidUtf8();
}
DecodeUtil.handleThreeBytes(
byte1,
/* byte2 */ UnsafeUtil.getByte(bytes, offset++),
/* byte3 */ UnsafeUtil.getByte(bytes, offset++),
resultArr,
resultPos++);
} else {
if (offset >= limit - 2) {
throw InvalidProtocolBufferException.invalidUtf8();
}
DecodeUtil.handleFourBytes(
byte1,
/* byte2 */ UnsafeUtil.getByte(bytes, offset++),
/* byte3 */ UnsafeUtil.getByte(bytes, offset++),
/* byte4 */ UnsafeUtil.getByte(bytes, offset++),
resultArr,
resultPos++);
// 4-byte case requires two chars.
resultPos++;
}
}
if (resultPos < resultArr.length) {
resultArr = Arrays.copyOf(resultArr, resultPos);
}
return UnsafeUtil.moveToString(resultArr);
}
@Override
String decodeUtf8Direct(ByteBuffer buffer, int index, int size)
throws InvalidProtocolBufferException {
// Bitwise OR combines the sign bits so any negative value fails the check.
if ((index | size | buffer.limit() - index - size) < 0) {
throw new ArrayIndexOutOfBoundsException(
String.format("buffer limit=%d, index=%d, limit=%d", buffer.limit(), index, size));
}
long address = UnsafeUtil.addressOffset(buffer) + index;
final long addressLimit = address + size;
// The longest possible resulting String is the same as the number of input bytes, when it is
// all ASCII. For other cases, this over-allocates and we will truncate in the end.
char[] resultArr = new char[size];
int resultPos = 0;
// Optimize for 100% ASCII (Hotspot loves small simple top-level loops like this).
// This simple loop stops when we encounter a byte >= 0x80 (i.e. non-ASCII).
while (address < addressLimit) {
byte b = UnsafeUtil.getByte(address);
if (!DecodeUtil.isOneByte(b)) {
break;
}
address++;
DecodeUtil.handleOneByte(b, resultArr, resultPos++);
}
while (address < addressLimit) {
byte byte1 = UnsafeUtil.getByte(address++);
if (DecodeUtil.isOneByte(byte1)) {
DecodeUtil.handleOneByte(byte1, resultArr, resultPos++);
// It's common for there to be multiple ASCII characters in a run mixed in, so add an
// extra optimized loop to take care of these runs.
while (address < addressLimit) {
byte b = UnsafeUtil.getByte(address);
if (!DecodeUtil.isOneByte(b)) {
break;
}
address++;
DecodeUtil.handleOneByte(b, resultArr, resultPos++);
}
} else if (DecodeUtil.isTwoBytes(byte1)) {
if (address >= addressLimit) {
throw InvalidProtocolBufferException.invalidUtf8();
}
DecodeUtil.handleTwoBytes(
byte1, /* byte2 */ UnsafeUtil.getByte(address++), resultArr, resultPos++);
} else if (DecodeUtil.isThreeBytes(byte1)) {
if (address >= addressLimit - 1) {
throw InvalidProtocolBufferException.invalidUtf8();
}
DecodeUtil.handleThreeBytes(
byte1,
/* byte2 */ UnsafeUtil.getByte(address++),
/* byte3 */ UnsafeUtil.getByte(address++),
resultArr,
resultPos++);
} else {
if (address >= addressLimit - 2) {
throw InvalidProtocolBufferException.invalidUtf8();
}
DecodeUtil.handleFourBytes(
byte1,
/* byte2 */ UnsafeUtil.getByte(address++),
/* byte3 */ UnsafeUtil.getByte(address++),
/* byte4 */ UnsafeUtil.getByte(address++),
resultArr,
resultPos++);
// 4-byte case requires two chars.
resultPos++;
}
}
if (resultPos < resultArr.length) {
resultArr = Arrays.copyOf(resultArr, resultPos);
}
return UnsafeUtil.moveToString(resultArr);
}
@Override
int encodeUtf8(final CharSequence in, final byte[] out, final int offset, final int length) {
long outIx = offset;
@ -1554,5 +1929,112 @@ final class Utf8 {
}
}
/**
* Utility methods for decoding bytes into {@link String}. Callers are responsible for extracting
* bytes (possibly using Unsafe methods), and checking remaining bytes. All other UTF-8 validity
* checks and codepoint conversion happen in this class.
*/
private static class DecodeUtil {
/**
* Returns whether this is a single-byte codepoint (i.e., ASCII) with the form '0XXXXXXX'.
*/
private static boolean isOneByte(byte b) {
return b >= 0;
}
/**
* Returns whether this is a two-byte codepoint with the form '10XXXXXX'.
*/
private static boolean isTwoBytes(byte b) {
return b < (byte) 0xE0;
}
/**
* Returns whether this is a three-byte codepoint with the form '110XXXXX'.
*/
private static boolean isThreeBytes(byte b) {
return b < (byte) 0xF0;
}
private static void handleOneByte(byte byte1, char[] resultArr, int resultPos) {
resultArr[resultPos] = (char) byte1;
}
private static void handleTwoBytes(
byte byte1, byte byte2, char[] resultArr, int resultPos)
throws InvalidProtocolBufferException {
// Simultaneously checks for illegal trailing-byte in leading position (<= '11000000') and
// overlong 2-byte, '11000001'.
if (byte1 < (byte) 0xC2
|| isNotTrailingByte(byte2)) {
throw InvalidProtocolBufferException.invalidUtf8();
}
resultArr[resultPos] = (char) (((byte1 & 0x1F) << 6) | trailingByteValue(byte2));
}
private static void handleThreeBytes(
byte byte1, byte byte2, byte byte3, char[] resultArr, int resultPos)
throws InvalidProtocolBufferException {
if (isNotTrailingByte(byte2)
// overlong? 5 most significant bits must not all be zero
|| (byte1 == (byte) 0xE0 && byte2 < (byte) 0xA0)
// check for illegal surrogate codepoints
|| (byte1 == (byte) 0xED && byte2 >= (byte) 0xA0)
|| isNotTrailingByte(byte3)) {
throw InvalidProtocolBufferException.invalidUtf8();
}
resultArr[resultPos] = (char)
(((byte1 & 0x0F) << 12) | (trailingByteValue(byte2) << 6) | trailingByteValue(byte3));
}
private static void handleFourBytes(
byte byte1, byte byte2, byte byte3, byte byte4, char[] resultArr, int resultPos)
throws InvalidProtocolBufferException{
if (isNotTrailingByte(byte2)
// Check that 1 <= plane <= 16. Tricky optimized form of:
// valid 4-byte leading byte?
// if (byte1 > (byte) 0xF4 ||
// overlong? 4 most significant bits must not all be zero
// byte1 == (byte) 0xF0 && byte2 < (byte) 0x90 ||
// codepoint larger than the highest code point (U+10FFFF)?
// byte1 == (byte) 0xF4 && byte2 > (byte) 0x8F)
|| (((byte1 << 28) + (byte2 - (byte) 0x90)) >> 30) != 0
|| isNotTrailingByte(byte3)
|| isNotTrailingByte(byte4)) {
throw InvalidProtocolBufferException.invalidUtf8();
}
int codepoint = ((byte1 & 0x07) << 18)
| (trailingByteValue(byte2) << 12)
| (trailingByteValue(byte3) << 6)
| trailingByteValue(byte4);
resultArr[resultPos] = DecodeUtil.highSurrogate(codepoint);
resultArr[resultPos + 1] = DecodeUtil.lowSurrogate(codepoint);
}
/**
* Returns whether the byte is not a valid continuation of the form '10XXXXXX'.
*/
private static boolean isNotTrailingByte(byte b) {
return b > (byte) 0xBF;
}
/**
* Returns the actual value of the trailing byte (removes the prefix '10') for composition.
*/
private static int trailingByteValue(byte b) {
return b & 0x3F;
}
private static char highSurrogate(int codePoint) {
return (char) ((MIN_HIGH_SURROGATE - (MIN_SUPPLEMENTARY_CODE_POINT >>> 10))
+ (codePoint >>> 10));
}
private static char lowSurrogate(int codePoint) {
return (char) (MIN_LOW_SURROGATE + (codePoint & 0x3ff));
}
}
private Utf8() {}
}

@ -0,0 +1,325 @@
package com.google.protobuf;
import com.google.protobuf.Utf8.Processor;
import com.google.protobuf.Utf8.SafeProcessor;
import com.google.protobuf.Utf8.UnsafeProcessor;
import java.nio.ByteBuffer;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Logger;
import junit.framework.TestCase;
public class DecodeUtf8Test extends TestCase {
private static Logger logger = Logger.getLogger(DecodeUtf8Test.class.getName());
private static final Processor SAFE_PROCESSOR = new SafeProcessor();
private static final Processor UNSAFE_PROCESSOR = new UnsafeProcessor();
public void testRoundTripAllValidChars() throws Exception {
for (int i = Character.MIN_CODE_POINT; i < Character.MAX_CODE_POINT; i++) {
if (i < Character.MIN_SURROGATE || i > Character.MAX_SURROGATE) {
String str = new String(Character.toChars(i));
assertRoundTrips(str);
}
}
}
// Test all 1, 2, 3 invalid byte combinations. Valid ones would have been covered above.
public void testOneByte() throws Exception {
int valid = 0;
for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) {
ByteString bs = ByteString.copyFrom(new byte[] { (byte) i });
if (!bs.isValidUtf8()) {
assertInvalid(bs.toByteArray());
} else {
valid++;
}
}
assertEquals(IsValidUtf8TestUtil.EXPECTED_ONE_BYTE_ROUNDTRIPPABLE_COUNT, valid);
}
public void testTwoBytes() throws Exception {
int valid = 0;
for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) {
for (int j = Byte.MIN_VALUE; j <= Byte.MAX_VALUE; j++) {
ByteString bs = ByteString.copyFrom(new byte[]{(byte) i, (byte) j});
if (!bs.isValidUtf8()) {
assertInvalid(bs.toByteArray());
} else {
valid++;
}
}
}
assertEquals(IsValidUtf8TestUtil.EXPECTED_TWO_BYTE_ROUNDTRIPPABLE_COUNT, valid);
}
public void testThreeBytes() throws Exception {
// Travis' OOM killer doesn't like this test
if (System.getenv("TRAVIS") == null) {
int count = 0;
int valid = 0;
for (int i = Byte.MIN_VALUE; i <= Byte.MAX_VALUE; i++) {
for (int j = Byte.MIN_VALUE; j <= Byte.MAX_VALUE; j++) {
for (int k = Byte.MIN_VALUE; k <= Byte.MAX_VALUE; k++) {
byte[] bytes = new byte[]{(byte) i, (byte) j, (byte) k};
ByteString bs = ByteString.copyFrom(bytes);
if (!bs.isValidUtf8()) {
assertInvalid(bytes);
} else {
valid++;
}
count++;
if (count % 1000000L == 0) {
logger.info("Processed " + (count / 1000000L) + " million characters");
}
}
}
}
assertEquals(IsValidUtf8TestUtil.EXPECTED_THREE_BYTE_ROUNDTRIPPABLE_COUNT, valid);
}
}
/**
* Tests that round tripping of a sample of four byte permutations work.
*/
public void testInvalid_4BytesSamples() throws Exception {
// Bad trailing bytes
assertInvalid(0xF0, 0xA4, 0xAD, 0x7F);
assertInvalid(0xF0, 0xA4, 0xAD, 0xC0);
// Special cases for byte2
assertInvalid(0xF0, 0x8F, 0xAD, 0xA2);
assertInvalid(0xF4, 0x90, 0xAD, 0xA2);
}
public void testRealStrings() throws Exception {
// English
assertRoundTrips("The quick brown fox jumps over the lazy dog");
// German
assertRoundTrips("Quizdeltagerne spiste jordb\u00e6r med fl\u00f8de, mens cirkusklovnen");
// Japanese
assertRoundTrips(
"\u3044\u308d\u306f\u306b\u307b\u3078\u3068\u3061\u308a\u306c\u308b\u3092");
// Hebrew
assertRoundTrips(
"\u05d3\u05d2 \u05e1\u05e7\u05e8\u05df \u05e9\u05d8 \u05d1\u05d9\u05dd "
+ "\u05de\u05d0\u05d5\u05db\u05d6\u05d1 \u05d5\u05dc\u05e4\u05ea\u05e2"
+ " \u05de\u05e6\u05d0 \u05dc\u05d5 \u05d7\u05d1\u05e8\u05d4 "
+ "\u05d0\u05d9\u05da \u05d4\u05e7\u05dc\u05d9\u05d8\u05d4");
// Thai
assertRoundTrips(
" \u0e08\u0e07\u0e1d\u0e48\u0e32\u0e1f\u0e31\u0e19\u0e1e\u0e31\u0e12"
+ "\u0e19\u0e32\u0e27\u0e34\u0e0a\u0e32\u0e01\u0e32\u0e23");
// Chinese
assertRoundTrips(
"\u8fd4\u56de\u94fe\u4e2d\u7684\u4e0b\u4e00\u4e2a\u4ee3\u7406\u9879\u9009\u62e9\u5668");
// Chinese with 4-byte chars
assertRoundTrips("\uD841\uDF0E\uD841\uDF31\uD841\uDF79\uD843\uDC53\uD843\uDC78"
+ "\uD843\uDC96\uD843\uDCCF\uD843\uDCD5\uD843\uDD15\uD843\uDD7C\uD843\uDD7F"
+ "\uD843\uDE0E\uD843\uDE0F\uD843\uDE77\uD843\uDE9D\uD843\uDEA2");
// Mixed
assertRoundTrips(
"The quick brown \u3044\u308d\u306f\u306b\u307b\u3078\u8fd4\u56de\u94fe"
+ "\u4e2d\u7684\u4e0b\u4e00");
}
public void testOverlong() throws Exception {
assertInvalid(0xc0, 0xaf);
assertInvalid(0xe0, 0x80, 0xaf);
assertInvalid(0xf0, 0x80, 0x80, 0xaf);
// Max overlong
assertInvalid(0xc1, 0xbf);
assertInvalid(0xe0, 0x9f, 0xbf);
assertInvalid(0xf0 ,0x8f, 0xbf, 0xbf);
// null overlong
assertInvalid(0xc0, 0x80);
assertInvalid(0xe0, 0x80, 0x80);
assertInvalid(0xf0, 0x80, 0x80, 0x80);
}
public void testIllegalCodepoints() throws Exception {
// Single surrogate
assertInvalid(0xed, 0xa0, 0x80);
assertInvalid(0xed, 0xad, 0xbf);
assertInvalid(0xed, 0xae, 0x80);
assertInvalid(0xed, 0xaf, 0xbf);
assertInvalid(0xed, 0xb0, 0x80);
assertInvalid(0xed, 0xbe, 0x80);
assertInvalid(0xed, 0xbf, 0xbf);
// Paired surrogates
assertInvalid(0xed, 0xa0, 0x80, 0xed, 0xb0, 0x80);
assertInvalid(0xed, 0xa0, 0x80, 0xed, 0xbf, 0xbf);
assertInvalid(0xed, 0xad, 0xbf, 0xed, 0xb0, 0x80);
assertInvalid(0xed, 0xad, 0xbf, 0xed, 0xbf, 0xbf);
assertInvalid(0xed, 0xae, 0x80, 0xed, 0xb0, 0x80);
assertInvalid(0xed, 0xae, 0x80, 0xed, 0xbf, 0xbf);
assertInvalid(0xed, 0xaf, 0xbf, 0xed, 0xb0, 0x80);
assertInvalid(0xed, 0xaf, 0xbf, 0xed, 0xbf, 0xbf);
}
public void testBufferSlice() throws Exception {
String str = "The quick brown fox jumps over the lazy dog";
assertRoundTrips(str, 10, 4);
assertRoundTrips(str, str.length(), 0);
}
public void testInvalidBufferSlice() throws Exception {
byte[] bytes = "The quick brown fox jumps over the lazy dog".getBytes(Internal.UTF_8);
assertInvalidSlice(bytes, bytes.length - 3, 4);
assertInvalidSlice(bytes, bytes.length, 1);
assertInvalidSlice(bytes, bytes.length + 1, 0);
assertInvalidSlice(bytes, 0, bytes.length + 1);
}
private void assertInvalid(int... bytesAsInt) throws Exception {
byte[] bytes = new byte[bytesAsInt.length];
for (int i = 0; i < bytesAsInt.length; i++) {
bytes[i] = (byte) bytesAsInt[i];
}
assertInvalid(bytes);
}
private void assertInvalid(byte[] bytes) throws Exception {
try {
UNSAFE_PROCESSOR.decodeUtf8(bytes, 0, bytes.length);
fail();
} catch (InvalidProtocolBufferException e) {
// Expected.
}
try {
SAFE_PROCESSOR.decodeUtf8(bytes, 0, bytes.length);
fail();
} catch (InvalidProtocolBufferException e) {
// Expected.
}
ByteBuffer direct = ByteBuffer.allocateDirect(bytes.length);
direct.put(bytes);
direct.flip();
try {
UNSAFE_PROCESSOR.decodeUtf8(direct, 0, bytes.length);
fail();
} catch (InvalidProtocolBufferException e) {
// Expected.
}
try {
SAFE_PROCESSOR.decodeUtf8(direct, 0, bytes.length);
fail();
} catch (InvalidProtocolBufferException e) {
// Expected.
}
ByteBuffer heap = ByteBuffer.allocate(bytes.length);
heap.put(bytes);
heap.flip();
try {
UNSAFE_PROCESSOR.decodeUtf8(heap, 0, bytes.length);
fail();
} catch (InvalidProtocolBufferException e) {
// Expected.
}
try {
SAFE_PROCESSOR.decodeUtf8(heap, 0, bytes.length);
fail();
} catch (InvalidProtocolBufferException e) {
// Expected.
}
}
private void assertInvalidSlice(byte[] bytes, int index, int size) throws Exception {
try {
UNSAFE_PROCESSOR.decodeUtf8(bytes, index, size);
fail();
} catch (ArrayIndexOutOfBoundsException e) {
// Expected.
}
try {
SAFE_PROCESSOR.decodeUtf8(bytes, index, size);
fail();
} catch (ArrayIndexOutOfBoundsException e) {
// Expected.
}
ByteBuffer direct = ByteBuffer.allocateDirect(bytes.length);
direct.put(bytes);
direct.flip();
try {
UNSAFE_PROCESSOR.decodeUtf8(direct, index, size);
fail();
} catch (ArrayIndexOutOfBoundsException e) {
// Expected.
}
try {
SAFE_PROCESSOR.decodeUtf8(direct, index, size);
fail();
} catch (ArrayIndexOutOfBoundsException e) {
// Expected.
}
ByteBuffer heap = ByteBuffer.allocate(bytes.length);
heap.put(bytes);
heap.flip();
try {
UNSAFE_PROCESSOR.decodeUtf8(heap, index, size);
fail();
} catch (ArrayIndexOutOfBoundsException e) {
// Expected.
}
try {
SAFE_PROCESSOR.decodeUtf8(heap, index, size);
fail();
} catch (ArrayIndexOutOfBoundsException e) {
// Expected.
}
}
private void assertRoundTrips(String str) throws Exception {
assertRoundTrips(str, 0, -1);
}
private void assertRoundTrips(String str, int index, int size) throws Exception {
byte[] bytes = str.getBytes(Internal.UTF_8);
if (size == -1) {
size = bytes.length;
}
assertDecode(new String(bytes, index, size, Internal.UTF_8),
UNSAFE_PROCESSOR.decodeUtf8(bytes, index, size));
assertDecode(new String(bytes, index, size, Internal.UTF_8),
SAFE_PROCESSOR.decodeUtf8(bytes, index, size));
ByteBuffer direct = ByteBuffer.allocateDirect(bytes.length);
direct.put(bytes);
direct.flip();
assertDecode(new String(bytes, index, size, Internal.UTF_8),
UNSAFE_PROCESSOR.decodeUtf8(direct, index, size));
assertDecode(new String(bytes, index, size, Internal.UTF_8),
SAFE_PROCESSOR.decodeUtf8(direct, index, size));
ByteBuffer heap = ByteBuffer.allocate(bytes.length);
heap.put(bytes);
heap.flip();
assertDecode(new String(bytes, index, size, Internal.UTF_8),
UNSAFE_PROCESSOR.decodeUtf8(heap, index, size));
assertDecode(new String(bytes, index, size, Internal.UTF_8),
SAFE_PROCESSOR.decodeUtf8(heap, index, size));
}
private void assertDecode(String expected, String actual) {
if (!expected.equals(actual)) {
fail("Failure: Expected (" + codepoints(expected) + ") Actual (" + codepoints(actual) + ")");
}
}
private List<String> codepoints(String str) {
List<String> codepoints = new ArrayList<String>();
for (int i = 0; i < str.length(); i++) {
codepoints.add(Long.toHexString(str.charAt(i)));
}
return codepoints;
}
}

@ -273,6 +273,15 @@ final class IsValidUtf8TestUtil {
assertEquals(isRoundTrippable, Utf8.isValidUtf8(bytes));
assertEquals(isRoundTrippable, Utf8.isValidUtf8(bytes, 0, numBytes));
try {
assertEquals(s, Utf8.decodeUtf8(bytes, 0, numBytes));
} catch (InvalidProtocolBufferException e) {
if (isRoundTrippable) {
System.out.println("Could not decode utf-8");
outputFailure(byteChar, bytes, bytesReencoded);
}
}
// Test partial sequences.
// Partition numBytes into three segments (not necessarily non-empty).
int i = rnd.nextInt(numBytes);

@ -11,7 +11,7 @@
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.4.1</version>
<version>3.5.0</version>
<packaging>pom</packaging>
<name>Protocol Buffers [Parent]</name>

@ -6,7 +6,7 @@
<parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protobuf-parent</artifactId>
<version>3.4.1</version>
<version>3.5.0</version>
</parent>
<artifactId>protobuf-java-util</artifactId>

@ -1,6 +1,6 @@
{
"name": "google-protobuf",
"version": "3.4.1",
"version": "3.5.0",
"description": "Protocol Buffers for JavaScript",
"main": "google-protobuf.js",
"files": [

@ -253,36 +253,20 @@ if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
XCODEBUILD_TEST_BASE_IOS+=(
-destination "platform=iOS Simulator,name=iPhone 4s,OS=9.0" # 32bit
-destination "platform=iOS Simulator,name=iPhone 7,OS=10.0" # 64bit
-destination "platform=iOS Simulator,name=iPad 2,OS=9.0" # 32bit
-destination "platform=iOS Simulator,name=iPad Pro (9.7 inch),OS=10.0" # 64bit
)
;;
8.1* )
XCODEBUILD_TEST_BASE_IOS+=(
-destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
-destination "platform=iOS Simulator,name=iPhone 7,OS=10.1" # 64bit
-destination "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit
-destination "platform=iOS Simulator,name=iPad Pro (9.7 inch),OS=10.1" # 64bit
)
;;
8.2* )
XCODEBUILD_TEST_BASE_IOS+=(
-destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
-destination "platform=iOS Simulator,name=iPhone 7,OS=10.2" # 64bit
-destination "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit
-destination "platform=iOS Simulator,name=iPad Pro (9.7 inch),OS=10.2" # 64bit
)
;;
8.3* )
8.[1-3]* )
XCODEBUILD_TEST_BASE_IOS+=(
-destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
-destination "platform=iOS Simulator,name=iPhone 7,OS=latest" # 64bit
)
;;
9.0* )
9.[0-1]* )
XCODEBUILD_TEST_BASE_IOS+=(
-destination "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit
-destination "platform=iOS Simulator,name=iPhone 7,OS=latest" # 64bit
# 9.0/9.1 both seem to often fail running destinations in parallel
-disable-concurrent-testing
)
;;
* )
@ -299,7 +283,7 @@ if [[ "${DO_XCODE_IOS_TESTS}" == "yes" ]] ; then
"${XCODEBUILD_TEST_BASE_IOS[@]}" -configuration Release test
fi
# Don't leave the simulator in the developer's face.
killall Simulator
killall Simulator 2> /dev/null || true
fi
if [[ "${DO_XCODE_OSX_TESTS}" == "yes" ]] ; then
XCODEBUILD_TEST_BASE_OSX=(

@ -174,10 +174,10 @@ static void GPBWriteRawLittleEndian64(GPBOutputBufferState *state,
data:(NSMutableData *)data {
if ((self = [super init])) {
buffer_ = [data retain];
[output open];
state_.bytes = [data mutableBytes];
state_.size = [data length];
state_.output = [output retain];
[state_.output open];
}
return self;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -2998,7 +2998,10 @@ typedef struct ResolveIvarAccessorMethodResult {
SEL encodingSelector;
} ResolveIvarAccessorMethodResult;
static void ResolveIvarGet(GPBFieldDescriptor *field,
// |field| can be __unsafe_unretained because they are created at startup
// and are essentially global. No need to pay for retain/release when
// they are captured in blocks.
static void ResolveIvarGet(__unsafe_unretained GPBFieldDescriptor *field,
ResolveIvarAccessorMethodResult *result) {
GPBDataType fieldDataType = GPBGetFieldDataType(field);
switch (fieldDataType) {
@ -3040,7 +3043,8 @@ static void ResolveIvarGet(GPBFieldDescriptor *field,
}
}
static void ResolveIvarSet(GPBFieldDescriptor *field,
// See comment about __unsafe_unretained on ResolveIvarGet.
static void ResolveIvarSet(__unsafe_unretained GPBFieldDescriptor *field,
GPBFileSyntax syntax,
ResolveIvarAccessorMethodResult *result) {
GPBDataType fieldDataType = GPBGetFieldDataType(field);
@ -3084,9 +3088,10 @@ static void ResolveIvarSet(GPBFieldDescriptor *field,
// NOTE: hasOrCountSel_/setHasSel_ will be NULL if the field for the given
// message should not have has support (done in GPBDescriptor.m), so there is
// no need for checks here to see if has*/setHas* are allowed.
ResolveIvarAccessorMethodResult result = {NULL, NULL};
for (GPBFieldDescriptor *field in descriptor->fields_) {
// See comment about __unsafe_unretained on ResolveIvarGet.
for (__unsafe_unretained GPBFieldDescriptor *field in descriptor->fields_) {
BOOL isMapOrArray = GPBFieldIsMapOrArray(field);
if (!isMapOrArray) {
// Single fields.

@ -43,6 +43,14 @@
- (const char *)singletonNameC;
@end
// We need some object to conform to the MessageSignatureProtocol to make sure
// the selectors in it are recorded in our Objective C runtime information.
// GPBMessage is arguably the more "obvious" choice, but given that all messages
// inherit from GPBMessage, conflicts seem likely, so we are using GPBRootObject
// instead.
@interface GPBRootObject () <GPBMessageSignatureProtocol>
@end
@implementation GPBRootObject
// Taken from http://www.burtleburtle.net/bob/hash/doobs.html

@ -49,6 +49,19 @@ static void AppendTextFormatForMessage(GPBMessage *message,
NSMutableString *toStr,
NSString *lineIndent);
// Are two datatypes the same basic type representation (ex Int32 and SInt32).
// Marked unused because currently only called from asserts/debug.
static BOOL DataTypesEquivalent(GPBDataType type1,
GPBDataType type2) __attribute__ ((unused));
// Basic type representation for a type (ex: for SInt32 it is Int32).
// Marked unused because currently only called from asserts/debug.
static GPBDataType BaseDataType(GPBDataType type) __attribute__ ((unused));
// String name for a data type.
// Marked unused because currently only called from asserts/debug.
static NSString *TypeToString(GPBDataType dataType) __attribute__ ((unused));
NSData *GPBEmptyNSData(void) {
static dispatch_once_t onceToken;
static NSData *defaultNSData = nil;
@ -342,6 +355,14 @@ void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof,
//%PDDM-DEFINE IVAR_POD_ACCESSORS_DEFN(NAME, TYPE)
//%TYPE GPBGetMessage##NAME##Field(GPBMessage *self,
//% TYPE$S NAME$S GPBFieldDescriptor *field) {
//%#if defined(DEBUG) && DEBUG
//% NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
//% GPBDataType##NAME),
//% @"Attempting to get value of TYPE from field %@ "
//% @"of %@ which is of type %@.",
//% [self class], field.name,
//% TypeToString(GPBGetFieldDataType(field)));
//%#endif
//% if (GPBGetHasIvarField(self, field)) {
//% uint8_t *storage = (uint8_t *)self->messageStorage_;
//% TYPE *typePtr = (TYPE *)&storage[field->description_->offset];
@ -364,14 +385,24 @@ void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof,
//% NAME$S GPBFieldDescriptor *field,
//% NAME$S TYPE value,
//% NAME$S GPBFileSyntax syntax) {
//%#if defined(DEBUG) && DEBUG
//% NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
//% GPBDataType##NAME),
//% @"Attempting to set field %@ of %@ which is of type %@ with "
//% @"value of type TYPE.",
//% [self class], field.name,
//% TypeToString(GPBGetFieldDataType(field)));
//%#endif
//% GPBOneofDescriptor *oneof = field->containingOneof_;
//% if (oneof) {
//% GPBMessageFieldDescription *fieldDesc = field->description_;
//% GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number);
//% }
//%#if defined(DEBUG) && DEBUG
//% NSCAssert(self->messageStorage_ != NULL,
//% @"%@: All messages should have storage (from init)",
//% [self class]);
//%#endif
//%#if defined(__clang_analyzer__)
//% if (self->messageStorage_ == NULL) return;
//%#endif
@ -391,6 +422,14 @@ void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof,
//%// Only exists for public api, no core code should use this.
//%TYPE *GPBGetMessage##NAME##Field(GPBMessage *self,
//% TYPE$S NAME$S GPBFieldDescriptor *field) {
//%#if defined(DEBUG) && DEBUG
//% NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
//% GPBDataType##NAME),
//% @"Attempting to get value of TYPE from field %@ "
//% @"of %@ which is of type %@.",
//% [self class], field.name,
//% TypeToString(GPBGetFieldDataType(field)));
//%#endif
//% return (TYPE *)GPBGetObjectIvarWithField(self, field);
//%}
//%
@ -398,6 +437,14 @@ void GPBMaybeClearOneof(GPBMessage *self, GPBOneofDescriptor *oneof,
//%void GPBSetMessage##NAME##Field(GPBMessage *self,
//% NAME$S GPBFieldDescriptor *field,
//% NAME$S TYPE *value) {
//%#if defined(DEBUG) && DEBUG
//% NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
//% GPBDataType##NAME),
//% @"Attempting to set field %@ of %@ which is of type %@ with "
//% @"value of type TYPE.",
//% [self class], field.name,
//% TypeToString(GPBGetFieldDataType(field)));
//%#endif
//% GPBSetObjectIvarWithField(self, field, (id)value);
//%}
//%
@ -455,7 +502,7 @@ void GPBSetRetainedObjectIvarWithFieldInternal(GPBMessage *self,
GPBDataType fieldType = GPBGetFieldDataType(field);
BOOL isMapOrArray = GPBFieldIsMapOrArray(field);
BOOL fieldIsMessage = GPBDataTypeIsMessage(fieldType);
#ifdef DEBUG
#if defined(DEBUG) && DEBUG
if (value == nil && !isMapOrArray && !fieldIsMessage &&
field.hasDefaultValue) {
// Setting a message to nil is an obvious way to "clear" the value
@ -618,6 +665,13 @@ int32_t GPBGetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field) {
int32_t GPBGetEnumIvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
GPBFileSyntax syntax) {
#if defined(DEBUG) && DEBUG
NSCAssert(GPBGetFieldDataType(field) == GPBDataTypeEnum,
@"Attempting to get value of type Enum from field %@ "
@"of %@ which is of type %@.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
int32_t result = GPBGetMessageInt32Field(self, field);
// If this is presevering unknown enums, make sure the value is valid before
// returning it.
@ -638,6 +692,13 @@ void GPBSetMessageEnumField(GPBMessage *self, GPBFieldDescriptor *field,
void GPBSetEnumIvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field, int32_t value,
GPBFileSyntax syntax) {
#if defined(DEBUG) && DEBUG
NSCAssert(GPBGetFieldDataType(field) == GPBDataTypeEnum,
@"Attempting to set field %@ of %@ which is of type %@ with "
@"value of type Enum.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
// Don't allow in unknown values. Proto3 can use the Raw method.
if (![field isValidEnumValue:value]) {
[NSException raise:NSInvalidArgumentException
@ -663,6 +724,13 @@ void GPBSetMessageRawEnumField(GPBMessage *self, GPBFieldDescriptor *field,
BOOL GPBGetMessageBoolField(GPBMessage *self,
GPBFieldDescriptor *field) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), GPBDataTypeBool),
@"Attempting to get value of type bool from field %@ "
@"of %@ which is of type %@.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
if (GPBGetHasIvarField(self, field)) {
// Bools are stored in the has bits to avoid needing explicit space in the
// storage structure.
@ -688,6 +756,13 @@ void GPBSetBoolIvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
BOOL value,
GPBFileSyntax syntax) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field), GPBDataTypeBool),
@"Attempting to set field %@ of %@ which is of type %@ with "
@"value of type bool.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
GPBMessageFieldDescription *fieldDesc = field->description_;
GPBOneofDescriptor *oneof = field->containingOneof_;
if (oneof) {
@ -714,6 +789,14 @@ void GPBSetBoolIvarWithFieldInternal(GPBMessage *self,
int32_t GPBGetMessageInt32Field(GPBMessage *self,
GPBFieldDescriptor *field) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeInt32),
@"Attempting to get value of int32_t from field %@ "
@"of %@ which is of type %@.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
if (GPBGetHasIvarField(self, field)) {
uint8_t *storage = (uint8_t *)self->messageStorage_;
int32_t *typePtr = (int32_t *)&storage[field->description_->offset];
@ -736,14 +819,24 @@ void GPBSetInt32IvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
int32_t value,
GPBFileSyntax syntax) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeInt32),
@"Attempting to set field %@ of %@ which is of type %@ with "
@"value of type int32_t.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
GPBOneofDescriptor *oneof = field->containingOneof_;
if (oneof) {
GPBMessageFieldDescription *fieldDesc = field->description_;
GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number);
}
#if defined(DEBUG) && DEBUG
NSCAssert(self->messageStorage_ != NULL,
@"%@: All messages should have storage (from init)",
[self class]);
#endif
#if defined(__clang_analyzer__)
if (self->messageStorage_ == NULL) return;
#endif
@ -764,6 +857,14 @@ void GPBSetInt32IvarWithFieldInternal(GPBMessage *self,
uint32_t GPBGetMessageUInt32Field(GPBMessage *self,
GPBFieldDescriptor *field) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeUInt32),
@"Attempting to get value of uint32_t from field %@ "
@"of %@ which is of type %@.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
if (GPBGetHasIvarField(self, field)) {
uint8_t *storage = (uint8_t *)self->messageStorage_;
uint32_t *typePtr = (uint32_t *)&storage[field->description_->offset];
@ -786,14 +887,24 @@ void GPBSetUInt32IvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
uint32_t value,
GPBFileSyntax syntax) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeUInt32),
@"Attempting to set field %@ of %@ which is of type %@ with "
@"value of type uint32_t.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
GPBOneofDescriptor *oneof = field->containingOneof_;
if (oneof) {
GPBMessageFieldDescription *fieldDesc = field->description_;
GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number);
}
#if defined(DEBUG) && DEBUG
NSCAssert(self->messageStorage_ != NULL,
@"%@: All messages should have storage (from init)",
[self class]);
#endif
#if defined(__clang_analyzer__)
if (self->messageStorage_ == NULL) return;
#endif
@ -814,6 +925,14 @@ void GPBSetUInt32IvarWithFieldInternal(GPBMessage *self,
int64_t GPBGetMessageInt64Field(GPBMessage *self,
GPBFieldDescriptor *field) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeInt64),
@"Attempting to get value of int64_t from field %@ "
@"of %@ which is of type %@.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
if (GPBGetHasIvarField(self, field)) {
uint8_t *storage = (uint8_t *)self->messageStorage_;
int64_t *typePtr = (int64_t *)&storage[field->description_->offset];
@ -836,14 +955,24 @@ void GPBSetInt64IvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
int64_t value,
GPBFileSyntax syntax) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeInt64),
@"Attempting to set field %@ of %@ which is of type %@ with "
@"value of type int64_t.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
GPBOneofDescriptor *oneof = field->containingOneof_;
if (oneof) {
GPBMessageFieldDescription *fieldDesc = field->description_;
GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number);
}
#if defined(DEBUG) && DEBUG
NSCAssert(self->messageStorage_ != NULL,
@"%@: All messages should have storage (from init)",
[self class]);
#endif
#if defined(__clang_analyzer__)
if (self->messageStorage_ == NULL) return;
#endif
@ -864,6 +993,14 @@ void GPBSetInt64IvarWithFieldInternal(GPBMessage *self,
uint64_t GPBGetMessageUInt64Field(GPBMessage *self,
GPBFieldDescriptor *field) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeUInt64),
@"Attempting to get value of uint64_t from field %@ "
@"of %@ which is of type %@.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
if (GPBGetHasIvarField(self, field)) {
uint8_t *storage = (uint8_t *)self->messageStorage_;
uint64_t *typePtr = (uint64_t *)&storage[field->description_->offset];
@ -886,14 +1023,24 @@ void GPBSetUInt64IvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
uint64_t value,
GPBFileSyntax syntax) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeUInt64),
@"Attempting to set field %@ of %@ which is of type %@ with "
@"value of type uint64_t.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
GPBOneofDescriptor *oneof = field->containingOneof_;
if (oneof) {
GPBMessageFieldDescription *fieldDesc = field->description_;
GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number);
}
#if defined(DEBUG) && DEBUG
NSCAssert(self->messageStorage_ != NULL,
@"%@: All messages should have storage (from init)",
[self class]);
#endif
#if defined(__clang_analyzer__)
if (self->messageStorage_ == NULL) return;
#endif
@ -914,6 +1061,14 @@ void GPBSetUInt64IvarWithFieldInternal(GPBMessage *self,
float GPBGetMessageFloatField(GPBMessage *self,
GPBFieldDescriptor *field) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeFloat),
@"Attempting to get value of float from field %@ "
@"of %@ which is of type %@.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
if (GPBGetHasIvarField(self, field)) {
uint8_t *storage = (uint8_t *)self->messageStorage_;
float *typePtr = (float *)&storage[field->description_->offset];
@ -936,14 +1091,24 @@ void GPBSetFloatIvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
float value,
GPBFileSyntax syntax) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeFloat),
@"Attempting to set field %@ of %@ which is of type %@ with "
@"value of type float.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
GPBOneofDescriptor *oneof = field->containingOneof_;
if (oneof) {
GPBMessageFieldDescription *fieldDesc = field->description_;
GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number);
}
#if defined(DEBUG) && DEBUG
NSCAssert(self->messageStorage_ != NULL,
@"%@: All messages should have storage (from init)",
[self class]);
#endif
#if defined(__clang_analyzer__)
if (self->messageStorage_ == NULL) return;
#endif
@ -964,6 +1129,14 @@ void GPBSetFloatIvarWithFieldInternal(GPBMessage *self,
double GPBGetMessageDoubleField(GPBMessage *self,
GPBFieldDescriptor *field) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeDouble),
@"Attempting to get value of double from field %@ "
@"of %@ which is of type %@.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
if (GPBGetHasIvarField(self, field)) {
uint8_t *storage = (uint8_t *)self->messageStorage_;
double *typePtr = (double *)&storage[field->description_->offset];
@ -986,14 +1159,24 @@ void GPBSetDoubleIvarWithFieldInternal(GPBMessage *self,
GPBFieldDescriptor *field,
double value,
GPBFileSyntax syntax) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeDouble),
@"Attempting to set field %@ of %@ which is of type %@ with "
@"value of type double.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
GPBOneofDescriptor *oneof = field->containingOneof_;
if (oneof) {
GPBMessageFieldDescription *fieldDesc = field->description_;
GPBMaybeClearOneof(self, oneof, fieldDesc->hasIndex, fieldDesc->number);
}
#if defined(DEBUG) && DEBUG
NSCAssert(self->messageStorage_ != NULL,
@"%@: All messages should have storage (from init)",
[self class]);
#endif
#if defined(__clang_analyzer__)
if (self->messageStorage_ == NULL) return;
#endif
@ -1019,6 +1202,14 @@ void GPBSetDoubleIvarWithFieldInternal(GPBMessage *self,
// Only exists for public api, no core code should use this.
NSString *GPBGetMessageStringField(GPBMessage *self,
GPBFieldDescriptor *field) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeString),
@"Attempting to get value of NSString from field %@ "
@"of %@ which is of type %@.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
return (NSString *)GPBGetObjectIvarWithField(self, field);
}
@ -1026,6 +1217,14 @@ NSString *GPBGetMessageStringField(GPBMessage *self,
void GPBSetMessageStringField(GPBMessage *self,
GPBFieldDescriptor *field,
NSString *value) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeString),
@"Attempting to set field %@ of %@ which is of type %@ with "
@"value of type NSString.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
GPBSetObjectIvarWithField(self, field, (id)value);
}
@ -1035,6 +1234,14 @@ void GPBSetMessageStringField(GPBMessage *self,
// Only exists for public api, no core code should use this.
NSData *GPBGetMessageBytesField(GPBMessage *self,
GPBFieldDescriptor *field) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeBytes),
@"Attempting to get value of NSData from field %@ "
@"of %@ which is of type %@.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
return (NSData *)GPBGetObjectIvarWithField(self, field);
}
@ -1042,6 +1249,14 @@ NSData *GPBGetMessageBytesField(GPBMessage *self,
void GPBSetMessageBytesField(GPBMessage *self,
GPBFieldDescriptor *field,
NSData *value) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeBytes),
@"Attempting to set field %@ of %@ which is of type %@ with "
@"value of type NSData.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
GPBSetObjectIvarWithField(self, field, (id)value);
}
@ -1051,6 +1266,14 @@ void GPBSetMessageBytesField(GPBMessage *self,
// Only exists for public api, no core code should use this.
GPBMessage *GPBGetMessageMessageField(GPBMessage *self,
GPBFieldDescriptor *field) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeMessage),
@"Attempting to get value of GPBMessage from field %@ "
@"of %@ which is of type %@.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
return (GPBMessage *)GPBGetObjectIvarWithField(self, field);
}
@ -1058,6 +1281,14 @@ GPBMessage *GPBGetMessageMessageField(GPBMessage *self,
void GPBSetMessageMessageField(GPBMessage *self,
GPBFieldDescriptor *field,
GPBMessage *value) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeMessage),
@"Attempting to set field %@ of %@ which is of type %@ with "
@"value of type GPBMessage.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
GPBSetObjectIvarWithField(self, field, (id)value);
}
@ -1067,6 +1298,14 @@ void GPBSetMessageMessageField(GPBMessage *self,
// Only exists for public api, no core code should use this.
GPBMessage *GPBGetMessageGroupField(GPBMessage *self,
GPBFieldDescriptor *field) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeGroup),
@"Attempting to get value of GPBMessage from field %@ "
@"of %@ which is of type %@.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
return (GPBMessage *)GPBGetObjectIvarWithField(self, field);
}
@ -1074,6 +1313,14 @@ GPBMessage *GPBGetMessageGroupField(GPBMessage *self,
void GPBSetMessageGroupField(GPBMessage *self,
GPBFieldDescriptor *field,
GPBMessage *value) {
#if defined(DEBUG) && DEBUG
NSCAssert(DataTypesEquivalent(GPBGetFieldDataType(field),
GPBDataTypeGroup),
@"Attempting to set field %@ of %@ which is of type %@ with "
@"value of type GPBMessage.",
[self class], field.name,
TypeToString(GPBGetFieldDataType(field)));
#endif
GPBSetObjectIvarWithField(self, field, (id)value);
}
@ -1137,8 +1384,40 @@ void GPBSetMessageRepeatedField(GPBMessage *self, GPBFieldDescriptor *field, id
GPBSetObjectIvarWithField(self, field, array);
}
#if defined(DEBUG) && DEBUG
static NSString *TypeToStr(GPBDataType dataType) {
static GPBDataType BaseDataType(GPBDataType type) {
switch (type) {
case GPBDataTypeSFixed32:
case GPBDataTypeInt32:
case GPBDataTypeSInt32:
case GPBDataTypeEnum:
return GPBDataTypeInt32;
case GPBDataTypeFixed32:
case GPBDataTypeUInt32:
return GPBDataTypeUInt32;
case GPBDataTypeSFixed64:
case GPBDataTypeInt64:
case GPBDataTypeSInt64:
return GPBDataTypeInt64;
case GPBDataTypeFixed64:
case GPBDataTypeUInt64:
return GPBDataTypeUInt64;
case GPBDataTypeMessage:
case GPBDataTypeGroup:
return GPBDataTypeMessage;
case GPBDataTypeBool:
case GPBDataTypeFloat:
case GPBDataTypeDouble:
case GPBDataTypeBytes:
case GPBDataTypeString:
return type;
}
}
static BOOL DataTypesEquivalent(GPBDataType type1, GPBDataType type2) {
return BaseDataType(type1) == BaseDataType(type2);
}
static NSString *TypeToString(GPBDataType dataType) {
switch (dataType) {
case GPBDataTypeBool:
return @"Bool";
@ -1166,10 +1445,9 @@ static NSString *TypeToStr(GPBDataType dataType) {
case GPBDataTypeGroup:
return @"Object";
case GPBDataTypeEnum:
return @"Bool";
return @"Enum";
}
}
#endif
// GPBGetMessageMapField is defined in GPBMessage.m
@ -1185,8 +1463,8 @@ void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field,
if (dictionary) {
GPBDataType keyDataType = field.mapKeyDataType;
GPBDataType valueDataType = GPBGetFieldDataType(field);
NSString *keyStr = TypeToStr(keyDataType);
NSString *valueStr = TypeToStr(valueDataType);
NSString *keyStr = TypeToString(keyDataType);
NSString *valueStr = TypeToString(valueDataType);
if (keyDataType == GPBDataTypeString) {
keyStr = @"String";
}
@ -1216,8 +1494,11 @@ void GPBSetMessageMapField(GPBMessage *self, GPBFieldDescriptor *field,
const char *GPBMessageEncodingForSelector(SEL selector, BOOL instanceSel) {
Protocol *protocol =
objc_getProtocol(GPBStringifySymbol(GPBMessageSignatureProtocol));
NSCAssert(protocol, @"Missing GPBMessageSignatureProtocol");
struct objc_method_description description =
protocol_getMethodDescription(protocol, selector, NO, instanceSel);
NSCAssert(description.name != Nil && description.types != nil,
@"Missing method for selector %@", NSStringFromSelector(selector));
return description.types;
}
@ -1911,13 +2192,3 @@ BOOL GPBClassHasSel(Class aClass, SEL sel) {
free(methodList);
return result;
}
#pragma mark - GPBMessageSignatureProtocol
// A series of selectors that are used solely to get @encoding values
// for them by the dynamic protobuf runtime code. An object using the protocol
// needs to be declared for the protocol to be valid at runtime.
@interface GPBMessageSignatureProtocol : NSObject<GPBMessageSignatureProtocol>
@end
@implementation GPBMessageSignatureProtocol
@end

@ -309,7 +309,8 @@ NSString *GPBDecodeTextFormatName(const uint8_t *decodeData, int32_t key,
// A series of selectors that are used solely to get @encoding values
// for them by the dynamic protobuf runtime code. See
// GPBMessageEncodingForSelector for details.
// GPBMessageEncodingForSelector for details. GPBRootObject conforms to
// the protocol so that it is encoded in the Objective C runtime.
@protocol GPBMessageSignatureProtocol
@optional

@ -880,7 +880,6 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
FRAMEWORK_SEARCH_PATHS = (
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
"$(inherited)",
);
@ -916,7 +915,6 @@
buildSettings = {
CLANG_ENABLE_MODULES = YES;
FRAMEWORK_SEARCH_PATHS = (
"\"$(SDKROOT)/Developer/Library/Frameworks\"",
"\"$(DEVELOPER_LIBRARY_DIR)/Frameworks\"",
"$(inherited)",
);

@ -261,7 +261,7 @@
GPBCodedInputStream* input32 = [GPBCodedInputStream streamWithData:data];
XCTAssertEqual(value32, [input32 readInt32]);
int64_t value64 = INT64_MIN | (0x01L << 31);
int64_t value64 = INT64_MIN | (0x01LL << 31);
GPBCodedInputStream* input64 = [GPBCodedInputStream streamWithData:data];
XCTAssertEqual(value64, [input64 readInt64]);
}

@ -63,7 +63,8 @@
}
- (void)testOne {
GPBBoolUInt32Dictionary *dict = [GPBBoolUInt32Dictionary dictionaryWithUInt32:100U forKey:YES];
GPBBoolUInt32Dictionary *dict = [[GPBBoolUInt32Dictionary alloc] init];
[dict setUInt32:100U forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
@ -76,6 +77,7 @@
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -214,17 +216,18 @@
XCTAssertNotNil(dict);
GPBBoolUInt32Dictionary *dict2 =
[GPBBoolUInt32Dictionary dictionaryWithDictionary:dict];
[[GPBBoolUInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBBoolUInt32Dictionary *dict = [GPBBoolUInt32Dictionary dictionary];
GPBBoolUInt32Dictionary *dict = [[GPBBoolUInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -249,6 +252,7 @@
XCTAssertTrue([dict getUInt32:&value forKey:NO]);
XCTAssertEqual(value, 101U);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -364,7 +368,8 @@
}
- (void)testOne {
GPBBoolInt32Dictionary *dict = [GPBBoolInt32Dictionary dictionaryWithInt32:200 forKey:YES];
GPBBoolInt32Dictionary *dict = [[GPBBoolInt32Dictionary alloc] init];
[dict setInt32:200 forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
@ -377,6 +382,7 @@
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -515,17 +521,18 @@
XCTAssertNotNil(dict);
GPBBoolInt32Dictionary *dict2 =
[GPBBoolInt32Dictionary dictionaryWithDictionary:dict];
[[GPBBoolInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBBoolInt32Dictionary *dict = [GPBBoolInt32Dictionary dictionary];
GPBBoolInt32Dictionary *dict = [[GPBBoolInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -550,6 +557,7 @@
XCTAssertTrue([dict getInt32:&value forKey:NO]);
XCTAssertEqual(value, 201);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -665,7 +673,8 @@
}
- (void)testOne {
GPBBoolUInt64Dictionary *dict = [GPBBoolUInt64Dictionary dictionaryWithUInt64:300U forKey:YES];
GPBBoolUInt64Dictionary *dict = [[GPBBoolUInt64Dictionary alloc] init];
[dict setUInt64:300U forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
@ -678,6 +687,7 @@
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -816,17 +826,18 @@
XCTAssertNotNil(dict);
GPBBoolUInt64Dictionary *dict2 =
[GPBBoolUInt64Dictionary dictionaryWithDictionary:dict];
[[GPBBoolUInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBBoolUInt64Dictionary *dict = [GPBBoolUInt64Dictionary dictionary];
GPBBoolUInt64Dictionary *dict = [[GPBBoolUInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -851,6 +862,7 @@
XCTAssertTrue([dict getUInt64:&value forKey:NO]);
XCTAssertEqual(value, 301U);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -966,7 +978,8 @@
}
- (void)testOne {
GPBBoolInt64Dictionary *dict = [GPBBoolInt64Dictionary dictionaryWithInt64:400 forKey:YES];
GPBBoolInt64Dictionary *dict = [[GPBBoolInt64Dictionary alloc] init];
[dict setInt64:400 forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
@ -979,6 +992,7 @@
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -1117,17 +1131,18 @@
XCTAssertNotNil(dict);
GPBBoolInt64Dictionary *dict2 =
[GPBBoolInt64Dictionary dictionaryWithDictionary:dict];
[[GPBBoolInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBBoolInt64Dictionary *dict = [GPBBoolInt64Dictionary dictionary];
GPBBoolInt64Dictionary *dict = [[GPBBoolInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1152,6 +1167,7 @@
XCTAssertTrue([dict getInt64:&value forKey:NO]);
XCTAssertEqual(value, 401);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1267,7 +1283,8 @@
}
- (void)testOne {
GPBBoolBoolDictionary *dict = [GPBBoolBoolDictionary dictionaryWithBool:NO forKey:YES];
GPBBoolBoolDictionary *dict = [[GPBBoolBoolDictionary alloc] init];
[dict setBool:NO forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
@ -1280,6 +1297,7 @@
XCTAssertEqual(aValue, NO);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -1418,17 +1436,18 @@
XCTAssertNotNil(dict);
GPBBoolBoolDictionary *dict2 =
[GPBBoolBoolDictionary dictionaryWithDictionary:dict];
[[GPBBoolBoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBBoolBoolDictionary *dict = [GPBBoolBoolDictionary dictionary];
GPBBoolBoolDictionary *dict = [[GPBBoolBoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1453,6 +1472,7 @@
XCTAssertTrue([dict getBool:&value forKey:NO]);
XCTAssertEqual(value, YES);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1568,7 +1588,8 @@
}
- (void)testOne {
GPBBoolFloatDictionary *dict = [GPBBoolFloatDictionary dictionaryWithFloat:500.f forKey:YES];
GPBBoolFloatDictionary *dict = [[GPBBoolFloatDictionary alloc] init];
[dict setFloat:500.f forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
@ -1581,6 +1602,7 @@
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -1719,17 +1741,18 @@
XCTAssertNotNil(dict);
GPBBoolFloatDictionary *dict2 =
[GPBBoolFloatDictionary dictionaryWithDictionary:dict];
[[GPBBoolFloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBBoolFloatDictionary *dict = [GPBBoolFloatDictionary dictionary];
GPBBoolFloatDictionary *dict = [[GPBBoolFloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1754,6 +1777,7 @@
XCTAssertTrue([dict getFloat:&value forKey:NO]);
XCTAssertEqual(value, 501.f);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1869,7 +1893,8 @@
}
- (void)testOne {
GPBBoolDoubleDictionary *dict = [GPBBoolDoubleDictionary dictionaryWithDouble:600. forKey:YES];
GPBBoolDoubleDictionary *dict = [[GPBBoolDoubleDictionary alloc] init];
[dict setDouble:600. forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
@ -1882,6 +1907,7 @@
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -2020,17 +2046,18 @@
XCTAssertNotNil(dict);
GPBBoolDoubleDictionary *dict2 =
[GPBBoolDoubleDictionary dictionaryWithDictionary:dict];
[[GPBBoolDoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBBoolDoubleDictionary *dict = [GPBBoolDoubleDictionary dictionary];
GPBBoolDoubleDictionary *dict = [[GPBBoolDoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -2055,6 +2082,7 @@
XCTAssertTrue([dict getDouble:&value forKey:NO]);
XCTAssertEqual(value, 601.);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -2170,7 +2198,8 @@
}
- (void)testOne {
GPBBoolObjectDictionary<NSString*> *dict = [GPBBoolObjectDictionary dictionaryWithObject:@"abc" forKey:YES];
GPBBoolObjectDictionary<NSString*> *dict = [[GPBBoolObjectDictionary alloc] init];
[dict setObject:@"abc" forKey:YES];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
XCTAssertEqualObjects([dict objectForKey:YES], @"abc");
@ -2180,6 +2209,7 @@
XCTAssertEqualObjects(aObject, @"abc");
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -2313,17 +2343,18 @@
XCTAssertNotNil(dict);
GPBBoolObjectDictionary<NSString*> *dict2 =
[GPBBoolObjectDictionary dictionaryWithDictionary:dict];
[[GPBBoolObjectDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBBoolObjectDictionary<NSString*> *dict = [GPBBoolObjectDictionary dictionary];
GPBBoolObjectDictionary<NSString*> *dict = [[GPBBoolObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -2343,6 +2374,7 @@
XCTAssertEqualObjects([dict objectForKey:YES], @"abc");
XCTAssertEqualObjects([dict objectForKey:NO], @"def");
[dict2 release];
[dict release];
}
- (void)testRemove {

@ -45,7 +45,6 @@
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBInt32EnumDictionary (TestingTweak)
+ (instancetype)dictionaryWithEnum:(int32_t)value forKey:(int32_t)key;
- (instancetype)initWithEnums:(const int32_t [])values
forKeys:(const int32_t [])keys
count:(NSUInteger)count;
@ -64,14 +63,6 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
@implementation GPBInt32EnumDictionary (TestingTweak)
+ (instancetype)dictionaryWithEnum:(int32_t)value forKey:(int32_t)key {
// Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
// type correct.
return [[(GPBInt32EnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:&value
forKeys:&key
count:1] autorelease];
}
- (instancetype)initWithEnums:(const int32_t [])values
forKeys:(const int32_t [])keys
count:(NSUInteger)count {
@ -103,7 +94,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt32UInt32Dictionary *dict = [GPBInt32UInt32Dictionary dictionaryWithUInt32:100U forKey:11];
GPBInt32UInt32Dictionary *dict = [[GPBInt32UInt32Dictionary alloc] init];
[dict setUInt32:100U forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
@ -116,6 +108,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -258,17 +251,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt32UInt32Dictionary *dict2 =
[GPBInt32UInt32Dictionary dictionaryWithDictionary:dict];
[[GPBInt32UInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt32UInt32Dictionary *dict = [GPBInt32UInt32Dictionary dictionary];
GPBInt32UInt32Dictionary *dict = [[GPBInt32UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -299,6 +293,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getUInt32:&value forKey:14]);
XCTAssertEqual(value, 103U);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -460,7 +455,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt32Int32Dictionary *dict = [GPBInt32Int32Dictionary dictionaryWithInt32:200 forKey:11];
GPBInt32Int32Dictionary *dict = [[GPBInt32Int32Dictionary alloc] init];
[dict setInt32:200 forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
@ -473,6 +469,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -615,17 +612,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt32Int32Dictionary *dict2 =
[GPBInt32Int32Dictionary dictionaryWithDictionary:dict];
[[GPBInt32Int32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt32Int32Dictionary *dict = [GPBInt32Int32Dictionary dictionary];
GPBInt32Int32Dictionary *dict = [[GPBInt32Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -656,6 +654,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getInt32:&value forKey:14]);
XCTAssertEqual(value, 203);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -817,7 +816,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt32UInt64Dictionary *dict = [GPBInt32UInt64Dictionary dictionaryWithUInt64:300U forKey:11];
GPBInt32UInt64Dictionary *dict = [[GPBInt32UInt64Dictionary alloc] init];
[dict setUInt64:300U forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
@ -830,6 +830,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -972,17 +973,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt32UInt64Dictionary *dict2 =
[GPBInt32UInt64Dictionary dictionaryWithDictionary:dict];
[[GPBInt32UInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt32UInt64Dictionary *dict = [GPBInt32UInt64Dictionary dictionary];
GPBInt32UInt64Dictionary *dict = [[GPBInt32UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1013,6 +1015,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getUInt64:&value forKey:14]);
XCTAssertEqual(value, 303U);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1174,7 +1177,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt32Int64Dictionary *dict = [GPBInt32Int64Dictionary dictionaryWithInt64:400 forKey:11];
GPBInt32Int64Dictionary *dict = [[GPBInt32Int64Dictionary alloc] init];
[dict setInt64:400 forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
@ -1187,6 +1191,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -1329,17 +1334,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt32Int64Dictionary *dict2 =
[GPBInt32Int64Dictionary dictionaryWithDictionary:dict];
[[GPBInt32Int64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt32Int64Dictionary *dict = [GPBInt32Int64Dictionary dictionary];
GPBInt32Int64Dictionary *dict = [[GPBInt32Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1370,6 +1376,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getInt64:&value forKey:14]);
XCTAssertEqual(value, 403);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1531,7 +1538,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt32BoolDictionary *dict = [GPBInt32BoolDictionary dictionaryWithBool:YES forKey:11];
GPBInt32BoolDictionary *dict = [[GPBInt32BoolDictionary alloc] init];
[dict setBool:YES forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
@ -1544,6 +1552,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, YES);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -1686,17 +1695,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt32BoolDictionary *dict2 =
[GPBInt32BoolDictionary dictionaryWithDictionary:dict];
[[GPBInt32BoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt32BoolDictionary *dict = [GPBInt32BoolDictionary dictionary];
GPBInt32BoolDictionary *dict = [[GPBInt32BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1727,6 +1737,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getBool:&value forKey:14]);
XCTAssertEqual(value, NO);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1888,7 +1899,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt32FloatDictionary *dict = [GPBInt32FloatDictionary dictionaryWithFloat:500.f forKey:11];
GPBInt32FloatDictionary *dict = [[GPBInt32FloatDictionary alloc] init];
[dict setFloat:500.f forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
@ -1901,6 +1913,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -2043,17 +2056,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt32FloatDictionary *dict2 =
[GPBInt32FloatDictionary dictionaryWithDictionary:dict];
[[GPBInt32FloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt32FloatDictionary *dict = [GPBInt32FloatDictionary dictionary];
GPBInt32FloatDictionary *dict = [[GPBInt32FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -2084,6 +2098,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getFloat:&value forKey:14]);
XCTAssertEqual(value, 503.f);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -2245,7 +2260,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt32DoubleDictionary *dict = [GPBInt32DoubleDictionary dictionaryWithDouble:600. forKey:11];
GPBInt32DoubleDictionary *dict = [[GPBInt32DoubleDictionary alloc] init];
[dict setDouble:600. forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
@ -2258,6 +2274,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -2400,17 +2417,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt32DoubleDictionary *dict2 =
[GPBInt32DoubleDictionary dictionaryWithDictionary:dict];
[[GPBInt32DoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt32DoubleDictionary *dict = [GPBInt32DoubleDictionary dictionary];
GPBInt32DoubleDictionary *dict = [[GPBInt32DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -2441,6 +2459,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getDouble:&value forKey:14]);
XCTAssertEqual(value, 603.);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -2602,7 +2621,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt32EnumDictionary *dict = [GPBInt32EnumDictionary dictionaryWithEnum:700 forKey:11];
GPBInt32EnumDictionary *dict = [[GPBInt32EnumDictionary alloc] init];
[dict setEnum:700 forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
@ -2615,6 +2635,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 700);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -2757,17 +2778,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt32EnumDictionary *dict2 =
[GPBInt32EnumDictionary dictionaryWithDictionary:dict];
[[GPBInt32EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt32EnumDictionary *dict = [GPBInt32EnumDictionary dictionary];
GPBInt32EnumDictionary *dict = [[GPBInt32EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -2798,6 +2820,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getEnum:&value forKey:14]);
XCTAssertEqual(value, 703);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -3120,19 +3143,20 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt32EnumDictionary *dict2 =
[GPBInt32EnumDictionary dictionaryWithDictionary:dict];
[[GPBInt32EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
[dict2 release];
[dict release];
}
- (void)testUnknownAdds {
GPBInt32EnumDictionary *dict =
[GPBInt32EnumDictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
[[GPBInt32EnumDictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -3172,6 +3196,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getRawValue:&value forKey:14]);
XCTAssertEqual(value, 803);
[dict2 release];
[dict release];
}
- (void)testUnknownRemove {
@ -3375,7 +3400,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt32ObjectDictionary<NSString*> *dict = [GPBInt32ObjectDictionary dictionaryWithObject:@"abc" forKey:11];
GPBInt32ObjectDictionary<NSString*> *dict = [[GPBInt32ObjectDictionary alloc] init];
[dict setObject:@"abc" forKey:11];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
XCTAssertEqualObjects([dict objectForKey:11], @"abc");
@ -3385,6 +3411,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects(aObject, @"abc");
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -3520,17 +3547,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt32ObjectDictionary<NSString*> *dict2 =
[GPBInt32ObjectDictionary dictionaryWithDictionary:dict];
[[GPBInt32ObjectDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt32ObjectDictionary<NSString*> *dict = [GPBInt32ObjectDictionary dictionary];
GPBInt32ObjectDictionary<NSString*> *dict = [[GPBInt32ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -3552,6 +3580,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:13], @"ghi");
XCTAssertEqualObjects([dict objectForKey:14], @"jkl");
[dict2 release];
[dict release];
}
- (void)testRemove {

@ -45,7 +45,6 @@
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBInt64EnumDictionary (TestingTweak)
+ (instancetype)dictionaryWithEnum:(int32_t)value forKey:(int64_t)key;
- (instancetype)initWithEnums:(const int32_t [])values
forKeys:(const int64_t [])keys
count:(NSUInteger)count;
@ -64,14 +63,6 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
@implementation GPBInt64EnumDictionary (TestingTweak)
+ (instancetype)dictionaryWithEnum:(int32_t)value forKey:(int64_t)key {
// Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
// type correct.
return [[(GPBInt64EnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:&value
forKeys:&key
count:1] autorelease];
}
- (instancetype)initWithEnums:(const int32_t [])values
forKeys:(const int64_t [])keys
count:(NSUInteger)count {
@ -103,7 +94,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt64UInt32Dictionary *dict = [GPBInt64UInt32Dictionary dictionaryWithUInt32:100U forKey:21LL];
GPBInt64UInt32Dictionary *dict = [[GPBInt64UInt32Dictionary alloc] init];
[dict setUInt32:100U forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
@ -116,6 +108,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -258,17 +251,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt64UInt32Dictionary *dict2 =
[GPBInt64UInt32Dictionary dictionaryWithDictionary:dict];
[[GPBInt64UInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt64UInt32Dictionary *dict = [GPBInt64UInt32Dictionary dictionary];
GPBInt64UInt32Dictionary *dict = [[GPBInt64UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -299,6 +293,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getUInt32:&value forKey:24LL]);
XCTAssertEqual(value, 103U);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -460,7 +455,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt64Int32Dictionary *dict = [GPBInt64Int32Dictionary dictionaryWithInt32:200 forKey:21LL];
GPBInt64Int32Dictionary *dict = [[GPBInt64Int32Dictionary alloc] init];
[dict setInt32:200 forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
@ -473,6 +469,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -615,17 +612,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt64Int32Dictionary *dict2 =
[GPBInt64Int32Dictionary dictionaryWithDictionary:dict];
[[GPBInt64Int32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt64Int32Dictionary *dict = [GPBInt64Int32Dictionary dictionary];
GPBInt64Int32Dictionary *dict = [[GPBInt64Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -656,6 +654,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getInt32:&value forKey:24LL]);
XCTAssertEqual(value, 203);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -817,7 +816,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt64UInt64Dictionary *dict = [GPBInt64UInt64Dictionary dictionaryWithUInt64:300U forKey:21LL];
GPBInt64UInt64Dictionary *dict = [[GPBInt64UInt64Dictionary alloc] init];
[dict setUInt64:300U forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
@ -830,6 +830,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -972,17 +973,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt64UInt64Dictionary *dict2 =
[GPBInt64UInt64Dictionary dictionaryWithDictionary:dict];
[[GPBInt64UInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt64UInt64Dictionary *dict = [GPBInt64UInt64Dictionary dictionary];
GPBInt64UInt64Dictionary *dict = [[GPBInt64UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1013,6 +1015,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getUInt64:&value forKey:24LL]);
XCTAssertEqual(value, 303U);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1174,7 +1177,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt64Int64Dictionary *dict = [GPBInt64Int64Dictionary dictionaryWithInt64:400 forKey:21LL];
GPBInt64Int64Dictionary *dict = [[GPBInt64Int64Dictionary alloc] init];
[dict setInt64:400 forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
@ -1187,6 +1191,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -1329,17 +1334,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt64Int64Dictionary *dict2 =
[GPBInt64Int64Dictionary dictionaryWithDictionary:dict];
[[GPBInt64Int64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt64Int64Dictionary *dict = [GPBInt64Int64Dictionary dictionary];
GPBInt64Int64Dictionary *dict = [[GPBInt64Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1370,6 +1376,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getInt64:&value forKey:24LL]);
XCTAssertEqual(value, 403);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1531,7 +1538,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt64BoolDictionary *dict = [GPBInt64BoolDictionary dictionaryWithBool:YES forKey:21LL];
GPBInt64BoolDictionary *dict = [[GPBInt64BoolDictionary alloc] init];
[dict setBool:YES forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
@ -1544,6 +1552,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, YES);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -1686,17 +1695,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt64BoolDictionary *dict2 =
[GPBInt64BoolDictionary dictionaryWithDictionary:dict];
[[GPBInt64BoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt64BoolDictionary *dict = [GPBInt64BoolDictionary dictionary];
GPBInt64BoolDictionary *dict = [[GPBInt64BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1727,6 +1737,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getBool:&value forKey:24LL]);
XCTAssertEqual(value, NO);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1888,7 +1899,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt64FloatDictionary *dict = [GPBInt64FloatDictionary dictionaryWithFloat:500.f forKey:21LL];
GPBInt64FloatDictionary *dict = [[GPBInt64FloatDictionary alloc] init];
[dict setFloat:500.f forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
@ -1901,6 +1913,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -2043,17 +2056,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt64FloatDictionary *dict2 =
[GPBInt64FloatDictionary dictionaryWithDictionary:dict];
[[GPBInt64FloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt64FloatDictionary *dict = [GPBInt64FloatDictionary dictionary];
GPBInt64FloatDictionary *dict = [[GPBInt64FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -2084,6 +2098,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getFloat:&value forKey:24LL]);
XCTAssertEqual(value, 503.f);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -2245,7 +2260,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt64DoubleDictionary *dict = [GPBInt64DoubleDictionary dictionaryWithDouble:600. forKey:21LL];
GPBInt64DoubleDictionary *dict = [[GPBInt64DoubleDictionary alloc] init];
[dict setDouble:600. forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
@ -2258,6 +2274,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -2400,17 +2417,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt64DoubleDictionary *dict2 =
[GPBInt64DoubleDictionary dictionaryWithDictionary:dict];
[[GPBInt64DoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt64DoubleDictionary *dict = [GPBInt64DoubleDictionary dictionary];
GPBInt64DoubleDictionary *dict = [[GPBInt64DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -2441,6 +2459,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getDouble:&value forKey:24LL]);
XCTAssertEqual(value, 603.);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -2602,7 +2621,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt64EnumDictionary *dict = [GPBInt64EnumDictionary dictionaryWithEnum:700 forKey:21LL];
GPBInt64EnumDictionary *dict = [[GPBInt64EnumDictionary alloc] init];
[dict setEnum:700 forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
@ -2615,6 +2635,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 700);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -2757,17 +2778,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt64EnumDictionary *dict2 =
[GPBInt64EnumDictionary dictionaryWithDictionary:dict];
[[GPBInt64EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt64EnumDictionary *dict = [GPBInt64EnumDictionary dictionary];
GPBInt64EnumDictionary *dict = [[GPBInt64EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -2798,6 +2820,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getEnum:&value forKey:24LL]);
XCTAssertEqual(value, 703);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -3120,19 +3143,20 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt64EnumDictionary *dict2 =
[GPBInt64EnumDictionary dictionaryWithDictionary:dict];
[[GPBInt64EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
[dict2 release];
[dict release];
}
- (void)testUnknownAdds {
GPBInt64EnumDictionary *dict =
[GPBInt64EnumDictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
[[GPBInt64EnumDictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -3172,6 +3196,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getRawValue:&value forKey:24LL]);
XCTAssertEqual(value, 803);
[dict2 release];
[dict release];
}
- (void)testUnknownRemove {
@ -3375,7 +3400,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBInt64ObjectDictionary<NSString*> *dict = [GPBInt64ObjectDictionary dictionaryWithObject:@"abc" forKey:21LL];
GPBInt64ObjectDictionary<NSString*> *dict = [[GPBInt64ObjectDictionary alloc] init];
[dict setObject:@"abc" forKey:21LL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
XCTAssertEqualObjects([dict objectForKey:21LL], @"abc");
@ -3385,6 +3411,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects(aObject, @"abc");
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -3520,17 +3547,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBInt64ObjectDictionary<NSString*> *dict2 =
[GPBInt64ObjectDictionary dictionaryWithDictionary:dict];
[[GPBInt64ObjectDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBInt64ObjectDictionary<NSString*> *dict = [GPBInt64ObjectDictionary dictionary];
GPBInt64ObjectDictionary<NSString*> *dict = [[GPBInt64ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -3552,6 +3580,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:23LL], @"ghi");
XCTAssertEqualObjects([dict objectForKey:24LL], @"jkl");
[dict2 release];
[dict release];
}
- (void)testRemove {

@ -45,7 +45,6 @@
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBStringEnumDictionary (TestingTweak)
+ (instancetype)dictionaryWithEnum:(int32_t)value forKey:(NSString *)key;
- (instancetype)initWithEnums:(const int32_t [])values
forKeys:(const NSString * [])keys
count:(NSUInteger)count;
@ -64,14 +63,6 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
@implementation GPBStringEnumDictionary (TestingTweak)
+ (instancetype)dictionaryWithEnum:(int32_t)value forKey:(NSString *)key {
// Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
// type correct.
return [[(GPBStringEnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:&value
forKeys:&key
count:1] autorelease];
}
- (instancetype)initWithEnums:(const int32_t [])values
forKeys:(const NSString * [])keys
count:(NSUInteger)count {
@ -103,7 +94,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBStringUInt32Dictionary *dict = [GPBStringUInt32Dictionary dictionaryWithUInt32:100U forKey:@"foo"];
GPBStringUInt32Dictionary *dict = [[GPBStringUInt32Dictionary alloc] init];
[dict setUInt32:100U forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
@ -116,6 +108,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -258,17 +251,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBStringUInt32Dictionary *dict2 =
[GPBStringUInt32Dictionary dictionaryWithDictionary:dict];
[[GPBStringUInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBStringUInt32Dictionary *dict = [GPBStringUInt32Dictionary dictionary];
GPBStringUInt32Dictionary *dict = [[GPBStringUInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -299,6 +293,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getUInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 103U);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -460,7 +455,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBStringInt32Dictionary *dict = [GPBStringInt32Dictionary dictionaryWithInt32:200 forKey:@"foo"];
GPBStringInt32Dictionary *dict = [[GPBStringInt32Dictionary alloc] init];
[dict setInt32:200 forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
@ -473,6 +469,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -615,17 +612,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBStringInt32Dictionary *dict2 =
[GPBStringInt32Dictionary dictionaryWithDictionary:dict];
[[GPBStringInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBStringInt32Dictionary *dict = [GPBStringInt32Dictionary dictionary];
GPBStringInt32Dictionary *dict = [[GPBStringInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -656,6 +654,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getInt32:&value forKey:@"mumble"]);
XCTAssertEqual(value, 203);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -817,7 +816,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBStringUInt64Dictionary *dict = [GPBStringUInt64Dictionary dictionaryWithUInt64:300U forKey:@"foo"];
GPBStringUInt64Dictionary *dict = [[GPBStringUInt64Dictionary alloc] init];
[dict setUInt64:300U forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
@ -830,6 +830,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -972,17 +973,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBStringUInt64Dictionary *dict2 =
[GPBStringUInt64Dictionary dictionaryWithDictionary:dict];
[[GPBStringUInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBStringUInt64Dictionary *dict = [GPBStringUInt64Dictionary dictionary];
GPBStringUInt64Dictionary *dict = [[GPBStringUInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1013,6 +1015,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getUInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 303U);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1174,7 +1177,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBStringInt64Dictionary *dict = [GPBStringInt64Dictionary dictionaryWithInt64:400 forKey:@"foo"];
GPBStringInt64Dictionary *dict = [[GPBStringInt64Dictionary alloc] init];
[dict setInt64:400 forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
@ -1187,6 +1191,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -1329,17 +1334,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBStringInt64Dictionary *dict2 =
[GPBStringInt64Dictionary dictionaryWithDictionary:dict];
[[GPBStringInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBStringInt64Dictionary *dict = [GPBStringInt64Dictionary dictionary];
GPBStringInt64Dictionary *dict = [[GPBStringInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1370,6 +1376,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getInt64:&value forKey:@"mumble"]);
XCTAssertEqual(value, 403);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1531,7 +1538,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBStringBoolDictionary *dict = [GPBStringBoolDictionary dictionaryWithBool:YES forKey:@"foo"];
GPBStringBoolDictionary *dict = [[GPBStringBoolDictionary alloc] init];
[dict setBool:YES forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
@ -1544,6 +1552,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, YES);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -1686,17 +1695,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBStringBoolDictionary *dict2 =
[GPBStringBoolDictionary dictionaryWithDictionary:dict];
[[GPBStringBoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBStringBoolDictionary *dict = [GPBStringBoolDictionary dictionary];
GPBStringBoolDictionary *dict = [[GPBStringBoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1727,6 +1737,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getBool:&value forKey:@"mumble"]);
XCTAssertEqual(value, NO);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1888,7 +1899,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBStringFloatDictionary *dict = [GPBStringFloatDictionary dictionaryWithFloat:500.f forKey:@"foo"];
GPBStringFloatDictionary *dict = [[GPBStringFloatDictionary alloc] init];
[dict setFloat:500.f forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
@ -1901,6 +1913,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -2043,17 +2056,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBStringFloatDictionary *dict2 =
[GPBStringFloatDictionary dictionaryWithDictionary:dict];
[[GPBStringFloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBStringFloatDictionary *dict = [GPBStringFloatDictionary dictionary];
GPBStringFloatDictionary *dict = [[GPBStringFloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -2084,6 +2098,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getFloat:&value forKey:@"mumble"]);
XCTAssertEqual(value, 503.f);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -2245,7 +2260,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBStringDoubleDictionary *dict = [GPBStringDoubleDictionary dictionaryWithDouble:600. forKey:@"foo"];
GPBStringDoubleDictionary *dict = [[GPBStringDoubleDictionary alloc] init];
[dict setDouble:600. forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
@ -2258,6 +2274,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -2400,17 +2417,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBStringDoubleDictionary *dict2 =
[GPBStringDoubleDictionary dictionaryWithDictionary:dict];
[[GPBStringDoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBStringDoubleDictionary *dict = [GPBStringDoubleDictionary dictionary];
GPBStringDoubleDictionary *dict = [[GPBStringDoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -2441,6 +2459,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getDouble:&value forKey:@"mumble"]);
XCTAssertEqual(value, 603.);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -2602,7 +2621,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBStringEnumDictionary *dict = [GPBStringEnumDictionary dictionaryWithEnum:700 forKey:@"foo"];
GPBStringEnumDictionary *dict = [[GPBStringEnumDictionary alloc] init];
[dict setEnum:700 forKey:@"foo"];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
@ -2615,6 +2635,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 700);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -2757,17 +2778,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBStringEnumDictionary *dict2 =
[GPBStringEnumDictionary dictionaryWithDictionary:dict];
[[GPBStringEnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBStringEnumDictionary *dict = [GPBStringEnumDictionary dictionary];
GPBStringEnumDictionary *dict = [[GPBStringEnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -2798,6 +2820,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getEnum:&value forKey:@"mumble"]);
XCTAssertEqual(value, 703);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -3120,19 +3143,20 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBStringEnumDictionary *dict2 =
[GPBStringEnumDictionary dictionaryWithDictionary:dict];
[[GPBStringEnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
[dict2 release];
[dict release];
}
- (void)testUnknownAdds {
GPBStringEnumDictionary *dict =
[GPBStringEnumDictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
[[GPBStringEnumDictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -3172,6 +3196,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getRawValue:&value forKey:@"mumble"]);
XCTAssertEqual(value, 803);
[dict2 release];
[dict release];
}
- (void)testUnknownRemove {

@ -45,7 +45,6 @@
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBUInt32EnumDictionary (TestingTweak)
+ (instancetype)dictionaryWithEnum:(int32_t)value forKey:(uint32_t)key;
- (instancetype)initWithEnums:(const int32_t [])values
forKeys:(const uint32_t [])keys
count:(NSUInteger)count;
@ -64,14 +63,6 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
@implementation GPBUInt32EnumDictionary (TestingTweak)
+ (instancetype)dictionaryWithEnum:(int32_t)value forKey:(uint32_t)key {
// Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
// type correct.
return [[(GPBUInt32EnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:&value
forKeys:&key
count:1] autorelease];
}
- (instancetype)initWithEnums:(const int32_t [])values
forKeys:(const uint32_t [])keys
count:(NSUInteger)count {
@ -103,7 +94,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt32UInt32Dictionary *dict = [GPBUInt32UInt32Dictionary dictionaryWithUInt32:100U forKey:1U];
GPBUInt32UInt32Dictionary *dict = [[GPBUInt32UInt32Dictionary alloc] init];
[dict setUInt32:100U forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
@ -116,6 +108,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -258,17 +251,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt32UInt32Dictionary *dict2 =
[GPBUInt32UInt32Dictionary dictionaryWithDictionary:dict];
[[GPBUInt32UInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt32UInt32Dictionary *dict = [GPBUInt32UInt32Dictionary dictionary];
GPBUInt32UInt32Dictionary *dict = [[GPBUInt32UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -299,6 +293,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getUInt32:&value forKey:4U]);
XCTAssertEqual(value, 103U);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -460,7 +455,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt32Int32Dictionary *dict = [GPBUInt32Int32Dictionary dictionaryWithInt32:200 forKey:1U];
GPBUInt32Int32Dictionary *dict = [[GPBUInt32Int32Dictionary alloc] init];
[dict setInt32:200 forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
@ -473,6 +469,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -615,17 +612,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt32Int32Dictionary *dict2 =
[GPBUInt32Int32Dictionary dictionaryWithDictionary:dict];
[[GPBUInt32Int32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt32Int32Dictionary *dict = [GPBUInt32Int32Dictionary dictionary];
GPBUInt32Int32Dictionary *dict = [[GPBUInt32Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -656,6 +654,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getInt32:&value forKey:4U]);
XCTAssertEqual(value, 203);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -817,7 +816,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt32UInt64Dictionary *dict = [GPBUInt32UInt64Dictionary dictionaryWithUInt64:300U forKey:1U];
GPBUInt32UInt64Dictionary *dict = [[GPBUInt32UInt64Dictionary alloc] init];
[dict setUInt64:300U forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
@ -830,6 +830,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -972,17 +973,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt32UInt64Dictionary *dict2 =
[GPBUInt32UInt64Dictionary dictionaryWithDictionary:dict];
[[GPBUInt32UInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt32UInt64Dictionary *dict = [GPBUInt32UInt64Dictionary dictionary];
GPBUInt32UInt64Dictionary *dict = [[GPBUInt32UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1013,6 +1015,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getUInt64:&value forKey:4U]);
XCTAssertEqual(value, 303U);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1174,7 +1177,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt32Int64Dictionary *dict = [GPBUInt32Int64Dictionary dictionaryWithInt64:400 forKey:1U];
GPBUInt32Int64Dictionary *dict = [[GPBUInt32Int64Dictionary alloc] init];
[dict setInt64:400 forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
@ -1187,6 +1191,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -1329,17 +1334,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt32Int64Dictionary *dict2 =
[GPBUInt32Int64Dictionary dictionaryWithDictionary:dict];
[[GPBUInt32Int64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt32Int64Dictionary *dict = [GPBUInt32Int64Dictionary dictionary];
GPBUInt32Int64Dictionary *dict = [[GPBUInt32Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1370,6 +1376,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getInt64:&value forKey:4U]);
XCTAssertEqual(value, 403);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1531,7 +1538,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt32BoolDictionary *dict = [GPBUInt32BoolDictionary dictionaryWithBool:YES forKey:1U];
GPBUInt32BoolDictionary *dict = [[GPBUInt32BoolDictionary alloc] init];
[dict setBool:YES forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
@ -1544,6 +1552,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, YES);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -1686,17 +1695,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt32BoolDictionary *dict2 =
[GPBUInt32BoolDictionary dictionaryWithDictionary:dict];
[[GPBUInt32BoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt32BoolDictionary *dict = [GPBUInt32BoolDictionary dictionary];
GPBUInt32BoolDictionary *dict = [[GPBUInt32BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1727,6 +1737,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getBool:&value forKey:4U]);
XCTAssertEqual(value, NO);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1888,7 +1899,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt32FloatDictionary *dict = [GPBUInt32FloatDictionary dictionaryWithFloat:500.f forKey:1U];
GPBUInt32FloatDictionary *dict = [[GPBUInt32FloatDictionary alloc] init];
[dict setFloat:500.f forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
@ -1901,6 +1913,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -2043,17 +2056,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt32FloatDictionary *dict2 =
[GPBUInt32FloatDictionary dictionaryWithDictionary:dict];
[[GPBUInt32FloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt32FloatDictionary *dict = [GPBUInt32FloatDictionary dictionary];
GPBUInt32FloatDictionary *dict = [[GPBUInt32FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -2084,6 +2098,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getFloat:&value forKey:4U]);
XCTAssertEqual(value, 503.f);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -2245,7 +2260,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt32DoubleDictionary *dict = [GPBUInt32DoubleDictionary dictionaryWithDouble:600. forKey:1U];
GPBUInt32DoubleDictionary *dict = [[GPBUInt32DoubleDictionary alloc] init];
[dict setDouble:600. forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
@ -2258,6 +2274,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -2400,17 +2417,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt32DoubleDictionary *dict2 =
[GPBUInt32DoubleDictionary dictionaryWithDictionary:dict];
[[GPBUInt32DoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt32DoubleDictionary *dict = [GPBUInt32DoubleDictionary dictionary];
GPBUInt32DoubleDictionary *dict = [[GPBUInt32DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -2441,6 +2459,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getDouble:&value forKey:4U]);
XCTAssertEqual(value, 603.);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -2602,7 +2621,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt32EnumDictionary *dict = [GPBUInt32EnumDictionary dictionaryWithEnum:700 forKey:1U];
GPBUInt32EnumDictionary *dict = [[GPBUInt32EnumDictionary alloc] init];
[dict setEnum:700 forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
@ -2615,6 +2635,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 700);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -2757,17 +2778,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt32EnumDictionary *dict2 =
[GPBUInt32EnumDictionary dictionaryWithDictionary:dict];
[[GPBUInt32EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt32EnumDictionary *dict = [GPBUInt32EnumDictionary dictionary];
GPBUInt32EnumDictionary *dict = [[GPBUInt32EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -2798,6 +2820,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getEnum:&value forKey:4U]);
XCTAssertEqual(value, 703);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -3120,19 +3143,20 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt32EnumDictionary *dict2 =
[GPBUInt32EnumDictionary dictionaryWithDictionary:dict];
[[GPBUInt32EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
[dict2 release];
[dict release];
}
- (void)testUnknownAdds {
GPBUInt32EnumDictionary *dict =
[GPBUInt32EnumDictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
[[GPBUInt32EnumDictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -3172,6 +3196,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getRawValue:&value forKey:4U]);
XCTAssertEqual(value, 803);
[dict2 release];
[dict release];
}
- (void)testUnknownRemove {
@ -3375,7 +3400,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt32ObjectDictionary<NSString*> *dict = [GPBUInt32ObjectDictionary dictionaryWithObject:@"abc" forKey:1U];
GPBUInt32ObjectDictionary<NSString*> *dict = [[GPBUInt32ObjectDictionary alloc] init];
[dict setObject:@"abc" forKey:1U];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
XCTAssertEqualObjects([dict objectForKey:1U], @"abc");
@ -3385,6 +3411,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects(aObject, @"abc");
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -3520,17 +3547,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt32ObjectDictionary<NSString*> *dict2 =
[GPBUInt32ObjectDictionary dictionaryWithDictionary:dict];
[[GPBUInt32ObjectDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt32ObjectDictionary<NSString*> *dict = [GPBUInt32ObjectDictionary dictionary];
GPBUInt32ObjectDictionary<NSString*> *dict = [[GPBUInt32ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -3552,6 +3580,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:3U], @"ghi");
XCTAssertEqualObjects([dict objectForKey:4U], @"jkl");
[dict2 release];
[dict release];
}
- (void)testRemove {

@ -45,7 +45,6 @@
// To let the testing macros work, add some extra methods to simplify things.
@interface GPBUInt64EnumDictionary (TestingTweak)
+ (instancetype)dictionaryWithEnum:(int32_t)value forKey:(uint64_t)key;
- (instancetype)initWithEnums:(const int32_t [])values
forKeys:(const uint64_t [])keys
count:(NSUInteger)count;
@ -64,14 +63,6 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
@implementation GPBUInt64EnumDictionary (TestingTweak)
+ (instancetype)dictionaryWithEnum:(int32_t)value forKey:(uint64_t)key {
// Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
// type correct.
return [[(GPBUInt64EnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
rawValues:&value
forKeys:&key
count:1] autorelease];
}
- (instancetype)initWithEnums:(const int32_t [])values
forKeys:(const uint64_t [])keys
count:(NSUInteger)count {
@ -103,7 +94,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt64UInt32Dictionary *dict = [GPBUInt64UInt32Dictionary dictionaryWithUInt32:100U forKey:31ULL];
GPBUInt64UInt32Dictionary *dict = [[GPBUInt64UInt32Dictionary alloc] init];
[dict setUInt32:100U forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint32_t value;
@ -116,6 +108,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 100U);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -258,17 +251,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt64UInt32Dictionary *dict2 =
[GPBUInt64UInt32Dictionary dictionaryWithDictionary:dict];
[[GPBUInt64UInt32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt64UInt32Dictionary *dict = [GPBUInt64UInt32Dictionary dictionary];
GPBUInt64UInt32Dictionary *dict = [[GPBUInt64UInt32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -299,6 +293,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getUInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 103U);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -460,7 +455,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt64Int32Dictionary *dict = [GPBUInt64Int32Dictionary dictionaryWithInt32:200 forKey:31ULL];
GPBUInt64Int32Dictionary *dict = [[GPBUInt64Int32Dictionary alloc] init];
[dict setInt32:200 forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
@ -473,6 +469,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 200);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -615,17 +612,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt64Int32Dictionary *dict2 =
[GPBUInt64Int32Dictionary dictionaryWithDictionary:dict];
[[GPBUInt64Int32Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt64Int32Dictionary *dict = [GPBUInt64Int32Dictionary dictionary];
GPBUInt64Int32Dictionary *dict = [[GPBUInt64Int32Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -656,6 +654,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getInt32:&value forKey:34ULL]);
XCTAssertEqual(value, 203);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -817,7 +816,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt64UInt64Dictionary *dict = [GPBUInt64UInt64Dictionary dictionaryWithUInt64:300U forKey:31ULL];
GPBUInt64UInt64Dictionary *dict = [[GPBUInt64UInt64Dictionary alloc] init];
[dict setUInt64:300U forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
uint64_t value;
@ -830,6 +830,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 300U);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -972,17 +973,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt64UInt64Dictionary *dict2 =
[GPBUInt64UInt64Dictionary dictionaryWithDictionary:dict];
[[GPBUInt64UInt64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt64UInt64Dictionary *dict = [GPBUInt64UInt64Dictionary dictionary];
GPBUInt64UInt64Dictionary *dict = [[GPBUInt64UInt64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1013,6 +1015,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getUInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 303U);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1174,7 +1177,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt64Int64Dictionary *dict = [GPBUInt64Int64Dictionary dictionaryWithInt64:400 forKey:31ULL];
GPBUInt64Int64Dictionary *dict = [[GPBUInt64Int64Dictionary alloc] init];
[dict setInt64:400 forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int64_t value;
@ -1187,6 +1191,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 400);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -1329,17 +1334,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt64Int64Dictionary *dict2 =
[GPBUInt64Int64Dictionary dictionaryWithDictionary:dict];
[[GPBUInt64Int64Dictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt64Int64Dictionary *dict = [GPBUInt64Int64Dictionary dictionary];
GPBUInt64Int64Dictionary *dict = [[GPBUInt64Int64Dictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1370,6 +1376,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getInt64:&value forKey:34ULL]);
XCTAssertEqual(value, 403);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1531,7 +1538,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt64BoolDictionary *dict = [GPBUInt64BoolDictionary dictionaryWithBool:YES forKey:31ULL];
GPBUInt64BoolDictionary *dict = [[GPBUInt64BoolDictionary alloc] init];
[dict setBool:YES forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
BOOL value;
@ -1544,6 +1552,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, YES);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -1686,17 +1695,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt64BoolDictionary *dict2 =
[GPBUInt64BoolDictionary dictionaryWithDictionary:dict];
[[GPBUInt64BoolDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt64BoolDictionary *dict = [GPBUInt64BoolDictionary dictionary];
GPBUInt64BoolDictionary *dict = [[GPBUInt64BoolDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -1727,6 +1737,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getBool:&value forKey:34ULL]);
XCTAssertEqual(value, NO);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -1888,7 +1899,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt64FloatDictionary *dict = [GPBUInt64FloatDictionary dictionaryWithFloat:500.f forKey:31ULL];
GPBUInt64FloatDictionary *dict = [[GPBUInt64FloatDictionary alloc] init];
[dict setFloat:500.f forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
float value;
@ -1901,6 +1913,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 500.f);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -2043,17 +2056,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt64FloatDictionary *dict2 =
[GPBUInt64FloatDictionary dictionaryWithDictionary:dict];
[[GPBUInt64FloatDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt64FloatDictionary *dict = [GPBUInt64FloatDictionary dictionary];
GPBUInt64FloatDictionary *dict = [[GPBUInt64FloatDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -2084,6 +2098,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getFloat:&value forKey:34ULL]);
XCTAssertEqual(value, 503.f);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -2245,7 +2260,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt64DoubleDictionary *dict = [GPBUInt64DoubleDictionary dictionaryWithDouble:600. forKey:31ULL];
GPBUInt64DoubleDictionary *dict = [[GPBUInt64DoubleDictionary alloc] init];
[dict setDouble:600. forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
double value;
@ -2258,6 +2274,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 600.);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -2400,17 +2417,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt64DoubleDictionary *dict2 =
[GPBUInt64DoubleDictionary dictionaryWithDictionary:dict];
[[GPBUInt64DoubleDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt64DoubleDictionary *dict = [GPBUInt64DoubleDictionary dictionary];
GPBUInt64DoubleDictionary *dict = [[GPBUInt64DoubleDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -2441,6 +2459,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getDouble:&value forKey:34ULL]);
XCTAssertEqual(value, 603.);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -2602,7 +2621,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt64EnumDictionary *dict = [GPBUInt64EnumDictionary dictionaryWithEnum:700 forKey:31ULL];
GPBUInt64EnumDictionary *dict = [[GPBUInt64EnumDictionary alloc] init];
[dict setEnum:700 forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
int32_t value;
@ -2615,6 +2635,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqual(aValue, 700);
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -2757,17 +2778,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt64EnumDictionary *dict2 =
[GPBUInt64EnumDictionary dictionaryWithDictionary:dict];
[[GPBUInt64EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt64EnumDictionary *dict = [GPBUInt64EnumDictionary dictionary];
GPBUInt64EnumDictionary *dict = [[GPBUInt64EnumDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -2798,6 +2820,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getEnum:&value forKey:34ULL]);
XCTAssertEqual(value, 703);
[dict2 release];
[dict release];
}
- (void)testRemove {
@ -3120,19 +3143,20 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt64EnumDictionary *dict2 =
[GPBUInt64EnumDictionary dictionaryWithDictionary:dict];
[[GPBUInt64EnumDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
[dict2 release];
[dict release];
}
- (void)testUnknownAdds {
GPBUInt64EnumDictionary *dict =
[GPBUInt64EnumDictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
[[GPBUInt64EnumDictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -3172,6 +3196,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertTrue([dict getRawValue:&value forKey:34ULL]);
XCTAssertEqual(value, 803);
[dict2 release];
[dict release];
}
- (void)testUnknownRemove {
@ -3375,7 +3400,8 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
}
- (void)testOne {
GPBUInt64ObjectDictionary<NSString*> *dict = [GPBUInt64ObjectDictionary dictionaryWithObject:@"abc" forKey:31ULL];
GPBUInt64ObjectDictionary<NSString*> *dict = [[GPBUInt64ObjectDictionary alloc] init];
[dict setObject:@"abc" forKey:31ULL];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 1U);
XCTAssertEqualObjects([dict objectForKey:31ULL], @"abc");
@ -3385,6 +3411,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects(aObject, @"abc");
XCTAssertNotEqual(stop, NULL);
}];
[dict release];
}
- (void)testBasics {
@ -3520,17 +3547,18 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertNotNil(dict);
GPBUInt64ObjectDictionary<NSString*> *dict2 =
[GPBUInt64ObjectDictionary dictionaryWithDictionary:dict];
[[GPBUInt64ObjectDictionary alloc] initWithDictionary:dict];
XCTAssertNotNil(dict2);
// Should be new pointer, but equal objects.
XCTAssertNotEqual(dict, dict2);
XCTAssertEqualObjects(dict, dict2);
[dict2 release];
[dict release];
}
- (void)testAdds {
GPBUInt64ObjectDictionary<NSString*> *dict = [GPBUInt64ObjectDictionary dictionary];
GPBUInt64ObjectDictionary<NSString*> *dict = [[GPBUInt64ObjectDictionary alloc] init];
XCTAssertNotNil(dict);
XCTAssertEqual(dict.count, 0U);
@ -3552,6 +3580,7 @@ static BOOL TestingEnum_IsValidValue(int32_t value) {
XCTAssertEqualObjects([dict objectForKey:33ULL], @"ghi");
XCTAssertEqualObjects([dict objectForKey:34ULL], @"jkl");
[dict2 release];
[dict release];
}
- (void)testRemove {

@ -78,7 +78,8 @@
//%}
//%
//%- (void)testOne {
//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWith##VALUE_NAME$u##:VAL1 forKey:KEY1];
//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
//% [dict set##VALUE_NAME$u##:VAL1 forKey:KEY1];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 1U);
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
@ -88,6 +89,7 @@
//% XCTAssertEqual##VSUFFIX(a##VNAME$u, VAL1);
//% XCTAssertNotEqual(stop, NULL);
//% }];
//% [dict release];
//%}
//%
//%- (void)testBasics {
@ -223,17 +225,18 @@
//% XCTAssertNotNil(dict);
//%
//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
//% [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWithDictionary:dict];
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithDictionary:dict];
//% XCTAssertNotNil(dict2);
//%
//% // Should be new pointer, but equal objects.
//% XCTAssertNotEqual(dict, dict2);
//% XCTAssertEqualObjects(dict, dict2);
//% [dict2 release];
//% [dict release];
//%}
//%
//%- (void)testAdds {
//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionary];
//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
//% XCTAssertNotNil(dict);
//%
//% XCTAssertEqual(dict.count, 0U);
@ -255,6 +258,7 @@
//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY3, VAL3)
//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY4, VAL4)
//% [dict2 release];
//% [dict release];
//%}
//%
//%- (void)testRemove {
@ -522,19 +526,20 @@
//% XCTAssertNotNil(dict);
//%
//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
//% [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWithDictionary:dict];
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithDictionary:dict];
//% XCTAssertNotNil(dict2);
//%
//% // Should be new pointer, but equal objects.
//% XCTAssertNotEqual(dict, dict2);
//% XCTAssertEqualObjects(dict, dict2);
//% XCTAssertEqual(dict.validationFunc, dict2.validationFunc); // Pointer comparison
//% [dict2 release];
//% [dict release];
//%}
//%
//%- (void)testUnknownAdds {
//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict =
//% [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWithValidationFunction:TestingEnum_IsValidValue];
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithValidationFunction:TestingEnum_IsValidValue];
//% XCTAssertNotNil(dict);
//%
//% XCTAssertEqual(dict.count, 0U);
@ -561,6 +566,7 @@
//%TEST_VALUE##VHELPER(VALUE_NAME, dict, value, KEY4, kGPBUnrecognizedEnumeratorValue)
//%TEST_RAW_VALUE##VHELPER(dict, value, KEY4, VAL4)
//% [dict2 release];
//% [dict release];
//%}
//%
//%- (void)testUnknownRemove {
@ -729,7 +735,6 @@
//%PDDM-DEFINE TEST_HELPERS(KEY_NAME, KEY_TYPE, KisP)
//%// To let the testing macros work, add some extra methods to simplify things.
//%@interface GPB##KEY_NAME##EnumDictionary (TestingTweak)
//%+ (instancetype)dictionaryWithEnum:(int32_t)value forKey:(KEY_TYPE##KisP$S##KisP)key;
//%- (instancetype)initWithEnums:(const int32_t [])values
//% forKeys:(const KEY_TYPE##KisP$S##KisP [])keys
//% count:(NSUInteger)count;
@ -748,14 +753,6 @@
//%}
//%
//%@implementation GPB##KEY_NAME##EnumDictionary (TestingTweak)
//%+ (instancetype)dictionaryWithEnum:(int32_t)value forKey:(KEY_TYPE##KisP$S##KisP)key {
//% // Cast is needed to compiler knows what class we are invoking initWithValues: on to get the
//% // type correct.
//% return [[(GPB##KEY_NAME##EnumDictionary*)[self alloc] initWithValidationFunction:TestingEnum_IsValidValue
//% KEY_NAME$S rawValues:&value
//% KEY_NAME$S forKeys:&key
//% KEY_NAME$S count:1] autorelease];
//%}
//%- (instancetype)initWithEnums:(const int32_t [])values
//% forKeys:(const KEY_TYPE##KisP$S##KisP [])keys
//% count:(NSUInteger)count {
@ -801,7 +798,8 @@
//%}
//%
//%- (void)testOne {
//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWith##VALUE_NAME$u##:VAL1 forKey:KEY1];
//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
//% [dict set##VALUE_NAME$u##:VAL1 forKey:KEY1];
//% XCTAssertNotNil(dict);
//% XCTAssertEqual(dict.count, 1U);
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
@ -811,6 +809,7 @@
//% XCTAssertEqual##VSUFFIX(a##VNAME$u, VAL1);
//% XCTAssertNotEqual(stop, NULL);
//% }];
//% [dict release];
//%}
//%
//%- (void)testBasics {
@ -944,17 +943,18 @@
//% XCTAssertNotNil(dict);
//%
//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict2 =
//% [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionaryWithDictionary:dict];
//% [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] initWithDictionary:dict];
//% XCTAssertNotNil(dict2);
//%
//% // Should be new pointer, but equal objects.
//% XCTAssertNotEqual(dict, dict2);
//% XCTAssertEqualObjects(dict, dict2);
//% [dict2 release];
//% [dict release];
//%}
//%
//%- (void)testAdds {
//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [GPB##KEY_NAME##VALUE_NAME##Dictionary dictionary];
//% DICTIONARY_CLASS_DECL##VHELPER(KEY_NAME, VALUE_NAME, VALUE_TYPE) *dict = [[GPB##KEY_NAME##VALUE_NAME##Dictionary alloc] init];
//% XCTAssertNotNil(dict);
//%
//% XCTAssertEqual(dict.count, 0U);
@ -974,6 +974,7 @@
//%DECLARE_VALUE_STORAGE##VHELPER(VALUE_TYPE, VNAME)TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY1, VAL1)
//%TEST_VALUE##VHELPER(VALUE_NAME, dict, VNAME, KEY2, VAL2)
//% [dict2 release];
//% [dict release];
//%}
//%
//%- (void)testRemove {

@ -1114,10 +1114,10 @@
- (void)testMap_Proto2UnknownEnum {
TestEnumMapPlusExtra *orig = [[TestEnumMapPlusExtra alloc] init];
orig.knownMapField = [GPBInt32EnumDictionary
dictionaryWithValidationFunction:Proto2MapEnumPlusExtra_IsValidValue];
orig.unknownMapField = [GPBInt32EnumDictionary
dictionaryWithValidationFunction:Proto2MapEnumPlusExtra_IsValidValue];
orig.knownMapField = [[[GPBInt32EnumDictionary alloc]
initWithValidationFunction:Proto2MapEnumPlusExtra_IsValidValue] autorelease];
orig.unknownMapField = [[[GPBInt32EnumDictionary alloc]
initWithValidationFunction:Proto2MapEnumPlusExtra_IsValidValue] autorelease];
[orig.knownMapField setEnum:Proto2MapEnumPlusExtra_EProto2MapEnumFoo
forKey:0];
[orig.unknownMapField setEnum:Proto2MapEnumPlusExtra_EProto2MapEnumExtra

@ -1238,7 +1238,8 @@
// with different objects that are equal).
TestRecursiveMessageWithRepeatedField *message3 =
[TestRecursiveMessageWithRepeatedField message];
message3.iToI = [GPBInt32Int32Dictionary dictionaryWithInt32:10 forKey:20];
message3.iToI = [[[GPBInt32Int32Dictionary alloc] init] autorelease];
[message3.iToI setInt32:10 forKey:20];
message3.strToStr =
[NSMutableDictionary dictionaryWithObject:@"abc" forKey:@"123"];
XCTAssertNotNil(message.iToI);
@ -1323,7 +1324,8 @@
XCTAssertFalse([message hasA]);
GPBInt32Int32Dictionary *iToI = [message.a.iToI retain];
XCTAssertEqual(iToI->_autocreator, message.a); // Pointer comparision
message.a.iToI = [GPBInt32Int32Dictionary dictionaryWithInt32:6 forKey:7];
message.a.iToI = [[[GPBInt32Int32Dictionary alloc] init] autorelease];
[message.a.iToI setInt32:6 forKey:7];
XCTAssertTrue([message hasA]);
XCTAssertNotEqual(message.a.iToI, iToI); // Pointer comparision
XCTAssertNil(iToI->_autocreator);

@ -1,72 +1,103 @@
{
"images" : [
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "appicon_40.png",
"scale" : "2x"
},
{
"size" : "20x20",
"idiom" : "iphone",
"filename" : "appicon_60.png",
"scale" : "3x"
},
{
"size" : "29x29",
"idiom" : "iphone",
"filename" : "appicon_29.png",
"scale" : "1x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"idiom" : "iphone",
"filename" : "appicon_58.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "29x29",
"idiom" : "iphone",
"filename" : "appicon_87.png",
"scale" : "3x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"idiom" : "iphone",
"filename" : "appicon_80.png",
"scale" : "2x"
},
{
"idiom" : "iphone",
"size" : "40x40",
"idiom" : "iphone",
"filename" : "appicon_120.png",
"scale" : "3x"
},
{
"size" : "57x57",
"idiom" : "iphone",
"filename" : "iPhone6.png",
"size" : "57x57",
"scale" : "1x"
},
{
"size" : "57x57",
"idiom" : "iphone",
"filename" : "iPhone6_2x.png",
"size" : "57x57",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "iPhone7_2x.png",
"filename" : "appicon_120.png",
"scale" : "2x"
},
{
"size" : "60x60",
"idiom" : "iphone",
"filename" : "iPhone7_3x.png",
"filename" : "appicon_180.png",
"scale" : "3x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"size" : "29x29",
"filename" : "appicon_20.png",
"scale" : "1x"
},
{
"size" : "20x20",
"idiom" : "ipad",
"size" : "29x29",
"filename" : "appicon_40.png",
"scale" : "2x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"size" : "40x40",
"filename" : "appicon_29.png",
"scale" : "1x"
},
{
"size" : "29x29",
"idiom" : "ipad",
"filename" : "appicon_58.png",
"scale" : "2x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "appicon_40.png",
"scale" : "1x"
},
{
"size" : "40x40",
"idiom" : "ipad",
"filename" : "appicon_80.png",
"scale" : "2x"
},
{
@ -80,32 +111,37 @@
"scale" : "2x"
},
{
"size" : "72x72",
"idiom" : "ipad",
"filename" : "iPad6.png",
"size" : "72x72",
"scale" : "1x"
},
{
"size" : "72x72",
"idiom" : "ipad",
"filename" : "iPad6_2x.png",
"size" : "72x72",
"scale" : "2x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "iPad7.png",
"filename" : "appicon_76.png",
"scale" : "1x"
},
{
"size" : "76x76",
"idiom" : "ipad",
"filename" : "iPad7_2x.png",
"filename" : "appicon_152.png",
"scale" : "2x"
},
{
"size" : "83.5x83.5",
"idiom" : "ipad",
"filename" : "appicon_167.png",
"scale" : "2x"
},
{
"idiom" : "car",
"size" : "120x120",
"size" : "1024x1024",
"idiom" : "ios-marketing",
"filename" : "appicon_1024.png",
"scale" : "1x"
}
],
@ -113,4 +149,4 @@
"version" : 1,
"author" : "xcode"
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 201 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

@ -3,43 +3,30 @@
{
"orientation" : "portrait",
"idiom" : "ipad",
"minimum-system-version" : "7.0",
"extent" : "full-screen",
"scale" : "2x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"minimum-system-version" : "7.0",
"extent" : "full-screen",
"scale" : "1x"
},
{
"orientation" : "landscape",
"idiom" : "ipad",
"minimum-system-version" : "7.0",
"extent" : "full-screen",
"scale" : "2x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"minimum-system-version" : "7.0",
"scale" : "2x"
"scale" : "1x"
},
{
"orientation" : "portrait",
"idiom" : "iphone",
"idiom" : "ipad",
"extent" : "full-screen",
"minimum-system-version" : "7.0",
"subtype" : "retina4",
"scale" : "2x"
},
{
"orientation" : "portrait",
"orientation" : "landscape",
"idiom" : "ipad",
"minimum-system-version" : "7.0",
"extent" : "full-screen",
"scale" : "1x"
"minimum-system-version" : "7.0",
"scale" : "2x"
}
],
"info" : {

@ -16,7 +16,7 @@ generation functionality.
To use PHP runtime library requires:
- C extension: PHP 5.5.x or 5.6.x.
- C extension: PHP 5.5, 5.6, or 7.
- PHP package: PHP 5.5, 5.6 or 7.
## Installation

@ -1614,3 +1614,12 @@ PHP_METHOD(Message, mergeFromJsonString) {
stackenv_uninit(&se);
}
}
PHP_METHOD(Message, discardUnknownFields) {
MessageHeader* msg = UNBOX(MessageHeader, getThis());
stringsink* unknown = DEREF(message_data(msg), 0, stringsink*);
if (unknown != NULL) {
stringsink_uninit(unknown);
DEREF(message_data(msg), 0, stringsink*) = NULL;
}
}

@ -42,6 +42,7 @@ static void hex_to_binary(const char* hex, char** binary, int* binary_len);
static zend_function_entry message_methods[] = {
PHP_ME(Message, clear, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Message, discardUnknownFields, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Message, serializeToString, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Message, mergeFromString, NULL, ZEND_ACC_PUBLIC)
PHP_ME(Message, serializeToJsonString, NULL, ZEND_ACC_PUBLIC)

@ -10,11 +10,11 @@
<email>protobuf-opensource@google.com</email>
<active>yes</active>
</lead>
<date>2017-09-14</date>
<date>2017-11-15</date>
<time>11:02:07</time>
<version>
<release>3.4.1</release>
<api>3.4.1</api>
<release>3.5.0</release>
<api>3.5.0</api>
</version>
<stability>
<release>stable</release>
@ -165,6 +165,22 @@ GA release.
<time>11:02:07</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>
GA release.
</notes>
</release>
<release>
<version>
<release>3.5.0</release>
<api>3.5.0</api>
</version>
<stability>
<release>stable</release>
<api>stable</api>
</stability>
<date>2017-11-15</date>
<time>11:02:07</time>
<license uri="https://opensource.org/licenses/BSD-3-Clause">3-Clause BSD License</license>
<notes>
GA release.
</notes>
</release>

@ -37,7 +37,7 @@
#include "upb.h"
#define PHP_PROTOBUF_EXTNAME "protobuf"
#define PHP_PROTOBUF_VERSION "3.4.1"
#define PHP_PROTOBUF_VERSION "3.5.0"
#define MAX_LENGTH_OF_INT64 20
#define SIZEOF_INT64 8
@ -608,48 +608,36 @@ typedef struct Api Api;
typedef struct BoolValue BoolValue;
typedef struct BytesValue BytesValue;
typedef struct Descriptor Descriptor;
typedef struct Descriptor Descriptor;
typedef struct DescriptorPool DescriptorPool;
typedef struct DoubleValue DoubleValue;
typedef struct Duration Duration;
typedef struct Enum Enum;
typedef struct EnumDescriptor EnumDescriptor;
typedef struct EnumDescriptor EnumDescriptor;
typedef struct EnumValue EnumValue;
typedef struct EnumValueDescriptor EnumValueDescriptor;
typedef struct Enum Enum;
typedef struct EnumValueDescriptor EnumValueDescriptor;
typedef struct Field Field;
typedef struct FieldDescriptor FieldDescriptor;
typedef struct FieldDescriptor FieldDescriptor;
typedef struct FieldMask FieldMask;
typedef struct EnumValue EnumValue;
typedef struct Field_Cardinality Field_Cardinality;
typedef struct FieldDescriptor FieldDescriptor;
typedef struct Field Field;
typedef struct Field_Kind Field_Kind;
typedef struct FieldMask FieldMask;
typedef struct FloatValue FloatValue;
typedef struct GPBEmpty GPBEmpty;
typedef struct Int32Value Int32Value;
typedef struct Int64Value Int64Value;
typedef struct InternalDescriptorPool InternalDescriptorPool;
typedef struct ListValue ListValue;
typedef struct Map Map;
typedef struct Map Map;
typedef struct MapIter MapIter;
typedef struct MapIter MapIter;
typedef struct Map Map;
typedef struct MessageField MessageField;
typedef struct MessageField MessageField;
typedef struct MessageHeader MessageHeader;
typedef struct MessageHeader MessageHeader;
typedef struct MessageLayout MessageLayout;
typedef struct MessageLayout MessageLayout;
typedef struct Method Method;
typedef struct Mixin Mixin;
typedef struct NullValue NullValue;
typedef struct Oneof Oneof;
typedef struct Oneof Oneof;
typedef struct Option Option;
typedef struct RepeatedField RepeatedField;
typedef struct RepeatedField RepeatedField;
typedef struct RepeatedFieldIter RepeatedFieldIter;
typedef struct RepeatedFieldIter RepeatedFieldIter;
typedef struct RepeatedField RepeatedField;
typedef struct SourceContext SourceContext;
typedef struct StringValue StringValue;
typedef struct Struct Struct;
@ -969,6 +957,7 @@ PHP_METHOD(Message, serializeToString);
PHP_METHOD(Message, mergeFromString);
PHP_METHOD(Message, serializeToJsonString);
PHP_METHOD(Message, mergeFromJsonString);
PHP_METHOD(Message, discardUnknownFields);
// -----------------------------------------------------------------------------
// Type check / conversion.

@ -4,7 +4,6 @@
namespace Google\Protobuf;
use Google\Protobuf\Internal\DescriptorPool;
use Google\Protobuf\Internal\GPBType;
use Google\Protobuf\Internal\GPBUtil;
use Google\Protobuf\Internal\Message;
@ -217,7 +216,7 @@ class Any extends \Google\Protobuf\Internal\Message
substr($this->type_url, $url_prifix_len);
// Create message according to fully qualified name.
$pool = DescriptorPool::getGeneratedPool();
$pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
$desc = $pool->getDescriptorByProtoName( ".".$fully_qualifed_name);
if (is_null($desc)) {
throw new \Exception("Class ".$fully_qualifed_name
@ -248,7 +247,7 @@ class Any extends \Google\Protobuf\Internal\Message
$this->value = $msg->serializeToString();
// Set type url.
$pool = DescriptorPool::getGeneratedPool();
$pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
$desc = $pool->getDescriptorByClassName(get_class($msg));
$fully_qualifed_name = $desc->getFullName();
$this->type_url = GPBUtil::TYPE_URL_PREFIX.substr(
@ -262,7 +261,7 @@ class Any extends \Google\Protobuf\Internal\Message
*/
public function is($klass)
{
$pool = DescriptorPool::getGeneratedPool();
$pool = \Google\Protobuf\Internal\DescriptorPool::getGeneratedPool();
$desc = $pool->getDescriptorByClassName($klass);
$fully_qualifed_name = $desc->getFullName();
$type_url = GPBUtil::TYPE_URL_PREFIX.substr(

@ -576,6 +576,15 @@ class Message
}
}
/**
* Clear all unknown fields previously parsed.
* @return null.
*/
public function discardUnknownFields()
{
$this->unknown = "";
}
/**
* Merges the contents of the specified message into current message.
*
@ -833,6 +842,8 @@ class Message
}
return $value;
case GPBType::INT32:
case GPBType::SINT32:
case GPBType::SFIXED32:
if (is_null($value)) {
return $this->defaultValue($field);
}
@ -850,6 +861,7 @@ class Message
}
return $value;
case GPBType::UINT32:
case GPBType::FIXED32:
if (is_null($value)) {
return $this->defaultValue($field);
}
@ -863,6 +875,8 @@ class Message
}
return $value;
case GPBType::INT64:
case GPBType::SINT64:
case GPBType::SFIXED64:
if (is_null($value)) {
return $this->defaultValue($field);
}
@ -880,6 +894,7 @@ class Message
}
return $value;
case GPBType::UINT64:
case GPBType::FIXED64:
if (is_null($value)) {
return $this->defaultValue($field);
}
@ -895,11 +910,6 @@ class Message
$value = bcsub($value, "18446744073709551616");
}
return $value;
case GPBType::FIXED64:
if (is_null($value)) {
return $this->defaultValue($field);
}
return $value;
default:
return $value;
}

@ -466,6 +466,13 @@ class EncodeDecodeTest extends TestBase
$m->mergeFromString($from);
$to = $m->serializeToString();
$this->assertSame(bin2hex($from), bin2hex($to));
$m = new TestMessage();
$from = hex2bin('F80601');
$m->mergeFromString($from);
$m->discardUnknownFields();
$to = $m->serializeToString();
$this->assertSame("", bin2hex($to));
}
public function testJsonEncode()

@ -27,7 +27,7 @@ fi
set -ex
LANGUAGES="cpp csharp java javanano js objectivec python ruby php"
LANGUAGES="cpp csharp java javanano js objectivec python ruby php all"
BASENAME=`basename $1 .tar.gz`
VERSION=${BASENAME:9}

@ -68,11 +68,11 @@ configure GPG and Sonatype account.
You need to perform the deployment for every platform that you want to
support. DO NOT close the staging repository until you have done the
deployment for all platforms. Currently the following platforms are supported:
- Linux (x86_32 and x86_64)
- Linux (x86_32, x86_64 and cross compiled aarch_64)
- Windows (x86_32 and x86_64) with
- Cygwin64 with MinGW compilers (x86_64)
- MSYS with MinGW32 (x86_32)
- Cross compile in Linux with MinGW-w64 (x86_32, x86_64)
- Cygwin64 with MinGW compilers (x86_64)
- MSYS with MinGW32 (x86_32)
- Cross compile in Linux with MinGW-w64 (x86_32, x86_64)
- MacOSX (x86_32 and x86_64)
As for MSYS2/MinGW64 for Windows: protoc will build, but it insists on
@ -99,6 +99,9 @@ $ mvn clean deploy -P release -Dstaging.repository=comgoogle-123
A 32-bit artifact can be deployed from a 64-bit host with
``-Dos.detected.arch=x86_32``
An arm64 artifact can be deployed from x86 host with
``-Dos.detected.arch=aarch_64``
A windows artifact can be deployed from a linux machine with
``-Dos.detected.name=windows``
@ -174,8 +177,9 @@ stored:
### Tested build environments
We have successfully built artifacts on the following environments:
- Linux x86_32 and x86_64:
- Centos 6.6 (within Docker 1.6.1)
- Ubuntu 14.04.2 64-bit
- Centos 6.6 (within Docker 1.6.1)
- Ubuntu 14.04.2 64-bit
- Linux aarch_64: Cross compiled with `g++-aarch64-linux-gnu` on Ubuntu 14.04.2 64-bit
- Windows x86_32: MSYS with ``mingw32-gcc-g++ 4.8.1-4`` on Windows 7 64-bit
- Windows x86_32: Cross compile with ``i686-w64-mingw32-g++ 4.8.2`` on Ubuntu 14.04.2 64-bit
- Windows x86_64: Cygwin64 with ``mingw64-x86_64-gcc-g++ 4.8.3-1`` on Windows 7 64-bit

@ -6,6 +6,12 @@
# Usage: build-protoc.sh <OS> <ARCH> <TARGET>
# <OS> and <ARCH> are ${os.detected.name} and ${os.detected.arch} from os-maven-plugin
# <TARGET> can be "protoc" or "protoc-gen-javalite"
#
# The script now supports cross-compiling windows and linux-arm64 in linux-x86
# environment. Required packages:
# - Windows: i686-w64-mingw32-gcc (32bit) and x86_64-w64-mingw32-gcc (64bit)
# - Arm64: g++-aarch64-linux-gnu
OS=$1
ARCH=$2
MAKE_TARGET=$3
@ -73,6 +79,8 @@ checkArch ()
assertEq $format "elf32-i386" $LINENO
elif [[ "$ARCH" == x86_64 ]]; then
assertEq $format "elf64-x86-64" $LINENO
elif [[ "$ARCH" == aarch_64 ]]; then
assertEq $format "elf64-little" $LINENO
else
fail "Unsupported arch: $ARCH"
fi
@ -116,6 +124,9 @@ checkDependencies ()
white_list="linux-gate\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|ld-linux\.so\.2"
elif [[ "$ARCH" == x86_64 ]]; then
white_list="linux-vdso\.so\.1\|libpthread\.so\.0\|libm\.so\.6\|libc\.so\.6\|ld-linux-x86-64\.so\.2"
elif [[ "$ARCH" == aarch_64 ]]; then
dump_cmd='objdump -p '"$1"' | grep NEEDED'
white_list="libpthread\.so\.0\|libc\.so\.6\|ld-linux-aarch64\.so\.1"
fi
elif [[ "$OS" == osx ]]; then
dump_cmd='otool -L '"$1"' | fgrep dylib'
@ -180,6 +191,8 @@ elif [[ "$(uname)" == Linux* ]]; then
CXXFLAGS="$CXXFLAGS -m64"
elif [[ "$ARCH" == x86_32 ]]; then
CXXFLAGS="$CXXFLAGS -m32"
elif [[ "$ARCH" == aarch_64 ]]; then
CONFIGURE_ARGS="$CONFIGURE_ARGS --host=aarch64-linux-gnu"
else
fail "Unsupported arch: $ARCH"
fi

@ -13,12 +13,13 @@ Example:
This script will download pre-built protoc or protoc plugin binaries from maven
repository and create .zip packages suitable to be included in the github
release page. If the target is protoc, well-known type .proto files will also be
included. Each invocation will create 5 zip packages:
included. Each invocation will create 6 zip packages:
dist/<TARGET>-<VERSION_NUMBER>-win32.zip
dist/<TARGET>-<VERSION_NUMBER>-osx-x86_32.zip
dist/<TARGET>-<VERSION_NUMBER>-osx-x86_64.zip
dist/<TARGET>-<VERSION_NUMBER>-linux-x86_32.zip
dist/<TARGET>-<VERSION_NUMBER>-linux-x86_64.zip
dist/<TARGET>-<VERSION_NUMBER>-linux-aarch_64.zip
EOF
exit 1
fi
@ -33,6 +34,7 @@ declare -a FILE_NAMES=( \
osx-x86_64.zip osx-x86_64.exe \
linux-x86_32.zip linux-x86_32.exe \
linux-x86_64.zip linux-x86_64.exe \
linux-aarch_64.zip linux-aarch_64.exe \
)
# List of all well-known types to be included.

@ -10,7 +10,7 @@
</parent>
<groupId>com.google.protobuf</groupId>
<artifactId>protoc</artifactId>
<version>3.4.1</version>
<version>3.5.0</version>
<packaging>pom</packaging>
<name>Protobuf Compiler</name>
<description>

@ -4,6 +4,9 @@ exclude google/protobuf/internal/*_test.py
exclude google/protobuf/internal/*.proto
exclude google/protobuf/internal/test_util.py
recursive-include google *.cc
recursive-include google *.h
recursive-exclude google *_test.py
recursive-exclude google *_test.proto
recursive-exclude google unittest*_pb2.py

@ -30,7 +30,7 @@
# Copyright 2007 Google Inc. All Rights Reserved.
__version__ = '3.4.1'
__version__ = '3.5.0.post1'
if __name__ != '__main__':
try:

@ -101,7 +101,7 @@ class TimeUtilTest(TimeUtilTestBase):
message.FromJsonString('1970-01-01T00:00:00.1Z')
self.assertEqual(0, message.seconds)
self.assertEqual(100000000, message.nanos)
# Parsing accpets offsets.
# Parsing accepts offsets.
message.FromJsonString('1970-01-01T00:00:00-08:00')
self.assertEqual(8 * 3600, message.seconds)
self.assertEqual(0, message.nanos)

@ -606,12 +606,20 @@ static void check_repeated_field_type(VALUE val, const upb_fielddef* field) {
rb_raise(rb_eTypeError, "Repeated field array has wrong element type");
}
if (self->field_type == UPB_TYPE_MESSAGE ||
self->field_type == UPB_TYPE_ENUM) {
if (self->field_type == UPB_TYPE_MESSAGE) {
if (self->field_type_class !=
get_def_obj(upb_fielddef_subdef(field))) {
Descriptor_msgclass(get_def_obj(upb_fielddef_subdef(field)))) {
rb_raise(rb_eTypeError,
"Repeated field array has wrong message/enum class");
"Repeated field array has wrong message class");
}
}
if (self->field_type == UPB_TYPE_ENUM) {
if (self->field_type_class !=
EnumDescriptor_enummodule(get_def_obj(upb_fielddef_subdef(field)))) {
rb_raise(rb_eTypeError,
"Repeated field array has wrong enum class");
}
}
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save