protoc 2.6.1.1 → 2.6.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (479) hide show
  1. checksums.yaml +4 -4
  2. data/ext/protoc/Makefile.in +10 -13
  3. data/ext/protoc/extconf.rb +0 -1
  4. data/ext/protoc/protobuf/CHANGES.txt +593 -0
  5. data/ext/protoc/protobuf/CONTRIBUTORS.txt +93 -0
  6. data/ext/protoc/protobuf/INSTALL.txt +237 -0
  7. data/ext/protoc/protobuf/LICENSE +33 -0
  8. data/ext/protoc/protobuf/Makefile.am +267 -0
  9. data/ext/protoc/protobuf/README.md +167 -0
  10. data/ext/protoc/protobuf/autogen.sh +41 -0
  11. data/ext/protoc/protobuf/benchmarks/ProtoBench.java +203 -0
  12. data/ext/protoc/protobuf/benchmarks/google_message1.dat +0 -0
  13. data/ext/protoc/protobuf/benchmarks/google_message2.dat +0 -0
  14. data/ext/protoc/protobuf/benchmarks/google_size.proto +136 -0
  15. data/ext/protoc/protobuf/benchmarks/google_speed.proto +136 -0
  16. data/ext/protoc/protobuf/benchmarks/readme.txt +50 -0
  17. data/ext/protoc/protobuf/configure.ac +159 -0
  18. data/ext/protoc/protobuf/editors/README.txt +5 -0
  19. data/ext/protoc/protobuf/editors/proto.vim +105 -0
  20. data/ext/protoc/protobuf/editors/protobuf-mode.el +220 -0
  21. data/ext/protoc/protobuf/examples/AddPerson.java +95 -0
  22. data/ext/protoc/protobuf/examples/ListPeople.java +50 -0
  23. data/ext/protoc/protobuf/examples/Makefile +58 -0
  24. data/ext/protoc/protobuf/examples/README.txt +29 -0
  25. data/ext/protoc/protobuf/examples/add_person.cc +95 -0
  26. data/ext/protoc/protobuf/examples/add_person.py +58 -0
  27. data/ext/protoc/protobuf/examples/addressbook.proto +30 -0
  28. data/ext/protoc/protobuf/examples/list_people.cc +68 -0
  29. data/ext/protoc/protobuf/examples/list_people.py +38 -0
  30. data/ext/protoc/protobuf/generate_descriptor_proto.sh +33 -0
  31. data/ext/protoc/protobuf/java/README.txt +96 -0
  32. data/ext/protoc/protobuf/java/pom.xml +217 -0
  33. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/AbstractMessage.java +466 -0
  34. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/AbstractMessageLite.java +355 -0
  35. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/AbstractParser.java +253 -0
  36. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/BlockingRpcChannel.java +51 -0
  37. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/BlockingService.java +64 -0
  38. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/BoundedByteString.java +163 -0
  39. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ByteString.java +1022 -0
  40. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/CodedInputStream.java +1311 -0
  41. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/CodedOutputStream.java +1297 -0
  42. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Descriptors.java +2238 -0
  43. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/DynamicMessage.java +622 -0
  44. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Extension.java +96 -0
  45. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ExtensionRegistry.java +392 -0
  46. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ExtensionRegistryLite.java +185 -0
  47. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/FieldSet.java +907 -0
  48. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/GeneratedMessage.java +2213 -0
  49. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/GeneratedMessageLite.java +949 -0
  50. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Internal.java +391 -0
  51. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java +122 -0
  52. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LazyField.java +154 -0
  53. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LazyFieldLite.java +176 -0
  54. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LazyStringArrayList.java +367 -0
  55. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LazyStringList.java +163 -0
  56. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LiteralByteString.java +362 -0
  57. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Message.java +244 -0
  58. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/MessageLite.java +320 -0
  59. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java +60 -0
  60. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/MessageOrBuilder.java +143 -0
  61. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/MessageReflection.java +931 -0
  62. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Parser.java +261 -0
  63. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ProtocolMessageEnum.java +58 -0
  64. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ProtocolStringList.java +48 -0
  65. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java +696 -0
  66. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RopeByteString.java +957 -0
  67. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RpcCallback.java +47 -0
  68. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RpcChannel.java +71 -0
  69. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RpcController.java +118 -0
  70. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RpcUtil.java +134 -0
  71. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Service.java +117 -0
  72. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ServiceException.java +52 -0
  73. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/SingleFieldBuilder.java +241 -0
  74. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/SmallSortedMap.java +618 -0
  75. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/TextFormat.java +1984 -0
  76. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/UninitializedMessageException.java +99 -0
  77. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/UnknownFieldSet.java +995 -0
  78. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java +205 -0
  79. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Utf8.java +349 -0
  80. data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/WireFormat.java +163 -0
  81. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/AbstractMessageTest.java +527 -0
  82. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/BoundedByteStringTest.java +68 -0
  83. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/ByteStringTest.java +759 -0
  84. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/CheckUtf8Test.java +141 -0
  85. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/CodedInputStreamTest.java +769 -0
  86. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/CodedOutputStreamTest.java +401 -0
  87. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java +80 -0
  88. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/DescriptorsTest.java +735 -0
  89. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/DynamicMessageTest.java +326 -0
  90. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java +48 -0
  91. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/GeneratedMessageTest.java +1515 -0
  92. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/IsValidUtf8Test.java +180 -0
  93. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java +421 -0
  94. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyFieldLiteTest.java +134 -0
  95. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyFieldTest.java +121 -0
  96. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyMessageLiteTest.java +319 -0
  97. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyStringArrayListTest.java +174 -0
  98. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java +143 -0
  99. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LiteEqualsAndHashTest.java +85 -0
  100. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LiteTest.java +148 -0
  101. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LiteralByteStringTest.java +396 -0
  102. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/MessageTest.java +353 -0
  103. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/NestedBuildersTest.java +185 -0
  104. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/ParserTest.java +381 -0
  105. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/RepeatedFieldBuilderTest.java +190 -0
  106. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java +97 -0
  107. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/RopeByteStringTest.java +115 -0
  108. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/ServiceTest.java +320 -0
  109. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/SingleFieldBuilderTest.java +155 -0
  110. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/SmallSortedMapTest.java +420 -0
  111. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/TestBadIdentifiers.java +96 -0
  112. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/TestUtil.java +4124 -0
  113. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/TextFormatTest.java +994 -0
  114. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/UnknownFieldSetTest.java +653 -0
  115. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java +227 -0
  116. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/WireFormatTest.java +606 -0
  117. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/lazy_fields_lite.proto +61 -0
  118. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/lite_equals_and_hash.proto +55 -0
  119. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/multiple_files_test.proto +77 -0
  120. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/nested_builders_test.proto +53 -0
  121. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/nested_extension.proto +46 -0
  122. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/nested_extension_lite.proto +48 -0
  123. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/non_nested_extension.proto +49 -0
  124. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/non_nested_extension_lite.proto +50 -0
  125. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/outer_class_name_test.proto +38 -0
  126. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/outer_class_name_test2.proto +42 -0
  127. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/outer_class_name_test3.proto +43 -0
  128. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_bad_identifiers.proto +157 -0
  129. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_check_utf8.proto +50 -0
  130. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_check_utf8_size.proto +51 -0
  131. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_custom_options.proto +43 -0
  132. data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_extra_interfaces.proto +60 -0
  133. data/ext/protoc/protobuf/m4/ac_system_extensions.m4 +37 -0
  134. data/ext/protoc/protobuf/m4/acx_check_suncc.m4 +75 -0
  135. data/ext/protoc/protobuf/m4/acx_pthread.m4 +397 -0
  136. data/ext/protoc/protobuf/m4/stl_hash.m4 +72 -0
  137. data/ext/protoc/protobuf/more_tests/Makefile +41 -0
  138. data/ext/protoc/protobuf/post_process_dist.sh +60 -0
  139. data/ext/protoc/protobuf/protobuf-lite.pc.in +13 -0
  140. data/ext/protoc/protobuf/protobuf.pc.in +14 -0
  141. data/ext/protoc/protobuf/python/README.txt +105 -0
  142. data/ext/protoc/protobuf/python/ez_setup.py +284 -0
  143. data/ext/protoc/protobuf/python/google/__init__.py +1 -0
  144. data/ext/protoc/protobuf/python/google/protobuf/__init__.py +0 -0
  145. data/ext/protoc/protobuf/python/google/protobuf/descriptor.py +849 -0
  146. data/ext/protoc/protobuf/python/google/protobuf/descriptor_database.py +137 -0
  147. data/ext/protoc/protobuf/python/google/protobuf/descriptor_pool.py +643 -0
  148. data/ext/protoc/protobuf/python/google/protobuf/internal/__init__.py +0 -0
  149. data/ext/protoc/protobuf/python/google/protobuf/internal/api_implementation.cc +139 -0
  150. data/ext/protoc/protobuf/python/google/protobuf/internal/api_implementation.py +89 -0
  151. data/ext/protoc/protobuf/python/google/protobuf/internal/api_implementation_default_test.py +63 -0
  152. data/ext/protoc/protobuf/python/google/protobuf/internal/containers.py +269 -0
  153. data/ext/protoc/protobuf/python/google/protobuf/internal/cpp_message.py +663 -0
  154. data/ext/protoc/protobuf/python/google/protobuf/internal/decoder.py +831 -0
  155. data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_database_test.py +63 -0
  156. data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_pool_test.py +564 -0
  157. data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_pool_test1.proto +94 -0
  158. data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_pool_test2.proto +70 -0
  159. data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_python_test.py +54 -0
  160. data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_test.py +669 -0
  161. data/ext/protoc/protobuf/python/google/protobuf/internal/encoder.py +788 -0
  162. data/ext/protoc/protobuf/python/google/protobuf/internal/enum_type_wrapper.py +89 -0
  163. data/ext/protoc/protobuf/python/google/protobuf/internal/factory_test1.proto +57 -0
  164. data/ext/protoc/protobuf/python/google/protobuf/internal/factory_test2.proto +92 -0
  165. data/ext/protoc/protobuf/python/google/protobuf/internal/generator_test.py +343 -0
  166. data/ext/protoc/protobuf/python/google/protobuf/internal/message_factory_python_test.py +54 -0
  167. data/ext/protoc/protobuf/python/google/protobuf/internal/message_factory_test.py +131 -0
  168. data/ext/protoc/protobuf/python/google/protobuf/internal/message_listener.py +78 -0
  169. data/ext/protoc/protobuf/python/google/protobuf/internal/message_python_test.py +54 -0
  170. data/ext/protoc/protobuf/python/google/protobuf/internal/message_test.py +681 -0
  171. data/ext/protoc/protobuf/python/google/protobuf/internal/missing_enum_values.proto +50 -0
  172. data/ext/protoc/protobuf/python/google/protobuf/internal/more_extensions.proto +58 -0
  173. data/ext/protoc/protobuf/python/google/protobuf/internal/more_extensions_dynamic.proto +49 -0
  174. data/ext/protoc/protobuf/python/google/protobuf/internal/more_messages.proto +51 -0
  175. data/ext/protoc/protobuf/python/google/protobuf/internal/python_message.py +1251 -0
  176. data/ext/protoc/protobuf/python/google/protobuf/internal/reflection_test.py +2934 -0
  177. data/ext/protoc/protobuf/python/google/protobuf/internal/service_reflection_test.py +136 -0
  178. data/ext/protoc/protobuf/python/google/protobuf/internal/symbol_database_test.py +120 -0
  179. data/ext/protoc/protobuf/python/google/protobuf/internal/test_bad_identifiers.proto +52 -0
  180. data/ext/protoc/protobuf/python/google/protobuf/internal/test_util.py +662 -0
  181. data/ext/protoc/protobuf/python/google/protobuf/internal/text_encoding_test.py +68 -0
  182. data/ext/protoc/protobuf/python/google/protobuf/internal/text_format_test.py +743 -0
  183. data/ext/protoc/protobuf/python/google/protobuf/internal/type_checkers.py +328 -0
  184. data/ext/protoc/protobuf/python/google/protobuf/internal/unknown_fields_test.py +231 -0
  185. data/ext/protoc/protobuf/python/google/protobuf/internal/wire_format.py +268 -0
  186. data/ext/protoc/protobuf/python/google/protobuf/internal/wire_format_test.py +253 -0
  187. data/ext/protoc/protobuf/python/google/protobuf/message.py +284 -0
  188. data/ext/protoc/protobuf/python/google/protobuf/message_factory.py +155 -0
  189. data/ext/protoc/protobuf/python/google/protobuf/pyext/README +6 -0
  190. data/ext/protoc/protobuf/python/google/protobuf/pyext/__init__.py +0 -0
  191. data/ext/protoc/protobuf/python/google/protobuf/pyext/cpp_message.py +61 -0
  192. data/ext/protoc/protobuf/python/google/protobuf/pyext/descriptor.cc +357 -0
  193. data/ext/protoc/protobuf/python/google/protobuf/pyext/descriptor.h +96 -0
  194. data/ext/protoc/protobuf/python/google/protobuf/pyext/descriptor_cpp2_test.py +58 -0
  195. data/ext/protoc/protobuf/python/google/protobuf/pyext/extension_dict.cc +338 -0
  196. data/ext/protoc/protobuf/python/google/protobuf/pyext/extension_dict.h +123 -0
  197. data/ext/protoc/protobuf/python/google/protobuf/pyext/message.cc +2561 -0
  198. data/ext/protoc/protobuf/python/google/protobuf/pyext/message.h +305 -0
  199. data/ext/protoc/protobuf/python/google/protobuf/pyext/message_factory_cpp2_test.py +56 -0
  200. data/ext/protoc/protobuf/python/google/protobuf/pyext/proto2_api_test.proto +38 -0
  201. data/ext/protoc/protobuf/python/google/protobuf/pyext/python.proto +66 -0
  202. data/ext/protoc/protobuf/python/google/protobuf/pyext/python_protobuf.h +57 -0
  203. data/ext/protoc/protobuf/python/google/protobuf/pyext/reflection_cpp2_generated_test.py +94 -0
  204. data/ext/protoc/protobuf/python/google/protobuf/pyext/repeated_composite_container.cc +763 -0
  205. data/ext/protoc/protobuf/python/google/protobuf/pyext/repeated_composite_container.h +172 -0
  206. data/ext/protoc/protobuf/python/google/protobuf/pyext/repeated_scalar_container.cc +825 -0
  207. data/ext/protoc/protobuf/python/google/protobuf/pyext/repeated_scalar_container.h +112 -0
  208. data/ext/protoc/protobuf/python/google/protobuf/pyext/scoped_pyobject_ptr.h +95 -0
  209. data/ext/protoc/protobuf/python/google/protobuf/reflection.py +205 -0
  210. data/ext/protoc/protobuf/python/google/protobuf/service.py +226 -0
  211. data/ext/protoc/protobuf/python/google/protobuf/service_reflection.py +284 -0
  212. data/ext/protoc/protobuf/python/google/protobuf/symbol_database.py +185 -0
  213. data/ext/protoc/protobuf/python/google/protobuf/text_encoding.py +110 -0
  214. data/ext/protoc/protobuf/python/google/protobuf/text_format.py +873 -0
  215. data/ext/protoc/protobuf/python/mox.py +1401 -0
  216. data/ext/protoc/protobuf/python/setup.py +201 -0
  217. data/ext/protoc/protobuf/python/stubout.py +140 -0
  218. data/ext/protoc/protobuf/src/Makefile.am +418 -0
  219. data/ext/protoc/protobuf/src/google/protobuf/SEBS +240 -0
  220. data/ext/protoc/protobuf/src/google/protobuf/compiler/code_generator.cc +84 -0
  221. data/ext/protoc/protobuf/src/google/protobuf/compiler/code_generator.h +145 -0
  222. data/ext/protoc/protobuf/src/google/protobuf/compiler/command_line_interface.cc +1603 -0
  223. data/ext/protoc/protobuf/src/google/protobuf/compiler/command_line_interface.h +378 -0
  224. data/ext/protoc/protobuf/src/google/protobuf/compiler/command_line_interface_unittest.cc +1654 -0
  225. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc +158 -0
  226. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc +288 -0
  227. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.h +103 -0
  228. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc +431 -0
  229. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.h +122 -0
  230. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc +210 -0
  231. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.h +86 -0
  232. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc +166 -0
  233. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_field.h +185 -0
  234. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc +665 -0
  235. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_file.h +99 -0
  236. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc +125 -0
  237. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.h +72 -0
  238. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc +494 -0
  239. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.h +206 -0
  240. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc +2645 -0
  241. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h +175 -0
  242. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc +375 -0
  243. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.h +121 -0
  244. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h +58 -0
  245. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc +123 -0
  246. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc +451 -0
  247. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.h +123 -0
  248. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc +334 -0
  249. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_service.h +118 -0
  250. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc +642 -0
  251. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.h +127 -0
  252. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto +132 -0
  253. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_unittest.cc +2074 -0
  254. data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_unittest.h +51 -0
  255. data/ext/protoc/protobuf/src/google/protobuf/compiler/importer.cc +480 -0
  256. data/ext/protoc/protobuf/src/google/protobuf/compiler/importer.h +317 -0
  257. data/ext/protoc/protobuf/src/google/protobuf/compiler/importer_unittest.cc +617 -0
  258. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_context.cc +195 -0
  259. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_context.h +95 -0
  260. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_doc_comment.cc +233 -0
  261. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_doc_comment.h +69 -0
  262. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_doc_comment_unittest.cc +67 -0
  263. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_enum.cc +333 -0
  264. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_enum.h +99 -0
  265. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_enum_field.cc +778 -0
  266. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_enum_field.h +158 -0
  267. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_extension.cc +207 -0
  268. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_extension.h +109 -0
  269. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_field.cc +213 -0
  270. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_field.h +162 -0
  271. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_file.cc +534 -0
  272. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_file.h +115 -0
  273. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_generator.cc +158 -0
  274. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_generator.h +72 -0
  275. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_generator_factory.cc +77 -0
  276. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_generator_factory.h +101 -0
  277. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_helpers.cc +737 -0
  278. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_helpers.h +322 -0
  279. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_lazy_message_field.cc +826 -0
  280. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_lazy_message_field.h +121 -0
  281. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_message.cc +1666 -0
  282. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_message.h +140 -0
  283. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_message_field.cc +1343 -0
  284. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_message_field.h +173 -0
  285. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_name_resolver.cc +266 -0
  286. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_name_resolver.h +124 -0
  287. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_plugin_unittest.cc +124 -0
  288. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_primitive_field.cc +877 -0
  289. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_primitive_field.h +160 -0
  290. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_service.cc +473 -0
  291. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_service.h +135 -0
  292. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.cc +201 -0
  293. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.h +90 -0
  294. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_string_field.cc +1056 -0
  295. data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_string_field.h +160 -0
  296. data/ext/protoc/protobuf/src/google/protobuf/compiler/main.cc +61 -0
  297. data/ext/protoc/protobuf/src/google/protobuf/compiler/mock_code_generator.cc +240 -0
  298. data/ext/protoc/protobuf/src/google/protobuf/compiler/mock_code_generator.h +117 -0
  299. data/ext/protoc/protobuf/src/google/protobuf/compiler/package_info.h +64 -0
  300. data/ext/protoc/protobuf/src/google/protobuf/compiler/parser.cc +1750 -0
  301. data/ext/protoc/protobuf/src/google/protobuf/compiler/parser.h +522 -0
  302. data/ext/protoc/protobuf/src/google/protobuf/compiler/parser_unittest.cc +2612 -0
  303. data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.cc +163 -0
  304. data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.h +72 -0
  305. data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.pb.cc +1148 -0
  306. data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.pb.h +897 -0
  307. data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.proto +147 -0
  308. data/ext/protoc/protobuf/src/google/protobuf/compiler/python/python_generator.cc +1262 -0
  309. data/ext/protoc/protobuf/src/google/protobuf/compiler/python/python_generator.h +166 -0
  310. data/ext/protoc/protobuf/src/google/protobuf/compiler/python/python_plugin_unittest.cc +118 -0
  311. data/ext/protoc/protobuf/src/google/protobuf/compiler/subprocess.cc +463 -0
  312. data/ext/protoc/protobuf/src/google/protobuf/compiler/subprocess.h +108 -0
  313. data/ext/protoc/protobuf/src/google/protobuf/compiler/test_plugin.cc +51 -0
  314. data/ext/protoc/protobuf/src/google/protobuf/compiler/zip_output_unittest.sh +91 -0
  315. data/ext/protoc/protobuf/src/google/protobuf/compiler/zip_writer.cc +218 -0
  316. data/ext/protoc/protobuf/src/google/protobuf/compiler/zip_writer.h +93 -0
  317. data/ext/protoc/protobuf/src/google/protobuf/descriptor.cc +5420 -0
  318. data/ext/protoc/protobuf/src/google/protobuf/descriptor.h +1691 -0
  319. data/ext/protoc/protobuf/src/google/protobuf/descriptor.pb.cc +9135 -0
  320. data/ext/protoc/protobuf/src/google/protobuf/descriptor.pb.h +6761 -0
  321. data/ext/protoc/protobuf/src/google/protobuf/descriptor.proto +687 -0
  322. data/ext/protoc/protobuf/src/google/protobuf/descriptor_database.cc +543 -0
  323. data/ext/protoc/protobuf/src/google/protobuf/descriptor_database.h +369 -0
  324. data/ext/protoc/protobuf/src/google/protobuf/descriptor_database_unittest.cc +748 -0
  325. data/ext/protoc/protobuf/src/google/protobuf/descriptor_pb2_test.py +54 -0
  326. data/ext/protoc/protobuf/src/google/protobuf/descriptor_unittest.cc +5501 -0
  327. data/ext/protoc/protobuf/src/google/protobuf/dynamic_message.cc +764 -0
  328. data/ext/protoc/protobuf/src/google/protobuf/dynamic_message.h +148 -0
  329. data/ext/protoc/protobuf/src/google/protobuf/dynamic_message_unittest.cc +230 -0
  330. data/ext/protoc/protobuf/src/google/protobuf/extension_set.cc +1663 -0
  331. data/ext/protoc/protobuf/src/google/protobuf/extension_set.h +1234 -0
  332. data/ext/protoc/protobuf/src/google/protobuf/extension_set_heavy.cc +734 -0
  333. data/ext/protoc/protobuf/src/google/protobuf/extension_set_unittest.cc +1095 -0
  334. data/ext/protoc/protobuf/src/google/protobuf/generated_enum_reflection.h +91 -0
  335. data/ext/protoc/protobuf/src/google/protobuf/generated_message_reflection.cc +1683 -0
  336. data/ext/protoc/protobuf/src/google/protobuf/generated_message_reflection.h +504 -0
  337. data/ext/protoc/protobuf/src/google/protobuf/generated_message_reflection_unittest.cc +795 -0
  338. data/ext/protoc/protobuf/src/google/protobuf/generated_message_util.cc +65 -0
  339. data/ext/protoc/protobuf/src/google/protobuf/generated_message_util.h +113 -0
  340. data/ext/protoc/protobuf/src/google/protobuf/io/coded_stream.cc +914 -0
  341. data/ext/protoc/protobuf/src/google/protobuf/io/coded_stream.h +1220 -0
  342. data/ext/protoc/protobuf/src/google/protobuf/io/coded_stream_inl.h +69 -0
  343. data/ext/protoc/protobuf/src/google/protobuf/io/coded_stream_unittest.cc +1378 -0
  344. data/ext/protoc/protobuf/src/google/protobuf/io/gzip_stream.cc +326 -0
  345. data/ext/protoc/protobuf/src/google/protobuf/io/gzip_stream.h +209 -0
  346. data/ext/protoc/protobuf/src/google/protobuf/io/gzip_stream_unittest.sh +44 -0
  347. data/ext/protoc/protobuf/src/google/protobuf/io/package_info.h +54 -0
  348. data/ext/protoc/protobuf/src/google/protobuf/io/printer.cc +198 -0
  349. data/ext/protoc/protobuf/src/google/protobuf/io/printer.h +136 -0
  350. data/ext/protoc/protobuf/src/google/protobuf/io/printer_unittest.cc +285 -0
  351. data/ext/protoc/protobuf/src/google/protobuf/io/strtod.cc +113 -0
  352. data/ext/protoc/protobuf/src/google/protobuf/io/strtod.h +50 -0
  353. data/ext/protoc/protobuf/src/google/protobuf/io/tokenizer.cc +1127 -0
  354. data/ext/protoc/protobuf/src/google/protobuf/io/tokenizer.h +402 -0
  355. data/ext/protoc/protobuf/src/google/protobuf/io/tokenizer_unittest.cc +999 -0
  356. data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream.cc +57 -0
  357. data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream.h +248 -0
  358. data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc +473 -0
  359. data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h +358 -0
  360. data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc +405 -0
  361. data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h +354 -0
  362. data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_unittest.cc +965 -0
  363. data/ext/protoc/protobuf/src/google/protobuf/lite_unittest.cc +350 -0
  364. data/ext/protoc/protobuf/src/google/protobuf/message.cc +358 -0
  365. data/ext/protoc/protobuf/src/google/protobuf/message.h +866 -0
  366. data/ext/protoc/protobuf/src/google/protobuf/message_lite.cc +335 -0
  367. data/ext/protoc/protobuf/src/google/protobuf/message_lite.h +247 -0
  368. data/ext/protoc/protobuf/src/google/protobuf/message_unittest.cc +427 -0
  369. data/ext/protoc/protobuf/src/google/protobuf/package_info.h +64 -0
  370. data/ext/protoc/protobuf/src/google/protobuf/reflection_ops.cc +269 -0
  371. data/ext/protoc/protobuf/src/google/protobuf/reflection_ops.h +81 -0
  372. data/ext/protoc/protobuf/src/google/protobuf/reflection_ops_unittest.cc +475 -0
  373. data/ext/protoc/protobuf/src/google/protobuf/repeated_field.cc +87 -0
  374. data/ext/protoc/protobuf/src/google/protobuf/repeated_field.h +1603 -0
  375. data/ext/protoc/protobuf/src/google/protobuf/repeated_field_reflection_unittest.cc +195 -0
  376. data/ext/protoc/protobuf/src/google/protobuf/repeated_field_unittest.cc +1442 -0
  377. data/ext/protoc/protobuf/src/google/protobuf/service.cc +46 -0
  378. data/ext/protoc/protobuf/src/google/protobuf/service.h +291 -0
  379. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops.h +227 -0
  380. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h +325 -0
  381. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h +151 -0
  382. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h +146 -0
  383. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h +122 -0
  384. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h +137 -0
  385. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_macosx.h +225 -0
  386. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h +313 -0
  387. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_pnacl.h +73 -0
  388. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_solaris.h +188 -0
  389. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_tsan.h +219 -0
  390. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc +137 -0
  391. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h +293 -0
  392. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc +112 -0
  393. data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h +150 -0
  394. data/ext/protoc/protobuf/src/google/protobuf/stubs/common.cc +395 -0
  395. data/ext/protoc/protobuf/src/google/protobuf/stubs/common.h +1226 -0
  396. data/ext/protoc/protobuf/src/google/protobuf/stubs/common_unittest.cc +357 -0
  397. data/ext/protoc/protobuf/src/google/protobuf/stubs/hash.h +232 -0
  398. data/ext/protoc/protobuf/src/google/protobuf/stubs/map_util.h +771 -0
  399. data/ext/protoc/protobuf/src/google/protobuf/stubs/once.cc +99 -0
  400. data/ext/protoc/protobuf/src/google/protobuf/stubs/once.h +166 -0
  401. data/ext/protoc/protobuf/src/google/protobuf/stubs/once_unittest.cc +253 -0
  402. data/ext/protoc/protobuf/src/google/protobuf/stubs/platform_macros.h +103 -0
  403. data/ext/protoc/protobuf/src/google/protobuf/stubs/shared_ptr.h +470 -0
  404. data/ext/protoc/protobuf/src/google/protobuf/stubs/stl_util.h +121 -0
  405. data/ext/protoc/protobuf/src/google/protobuf/stubs/stringprintf.cc +175 -0
  406. data/ext/protoc/protobuf/src/google/protobuf/stubs/stringprintf.h +76 -0
  407. data/ext/protoc/protobuf/src/google/protobuf/stubs/stringprintf_unittest.cc +152 -0
  408. data/ext/protoc/protobuf/src/google/protobuf/stubs/structurally_valid.cc +536 -0
  409. data/ext/protoc/protobuf/src/google/protobuf/stubs/structurally_valid_unittest.cc +40 -0
  410. data/ext/protoc/protobuf/src/google/protobuf/stubs/strutil.cc +1279 -0
  411. data/ext/protoc/protobuf/src/google/protobuf/stubs/strutil.h +562 -0
  412. data/ext/protoc/protobuf/src/google/protobuf/stubs/strutil_unittest.cc +73 -0
  413. data/ext/protoc/protobuf/src/google/protobuf/stubs/substitute.cc +134 -0
  414. data/ext/protoc/protobuf/src/google/protobuf/stubs/substitute.h +170 -0
  415. data/ext/protoc/protobuf/src/google/protobuf/stubs/template_util.h +138 -0
  416. data/ext/protoc/protobuf/src/google/protobuf/stubs/template_util_unittest.cc +130 -0
  417. data/ext/protoc/protobuf/src/google/protobuf/stubs/type_traits.h +336 -0
  418. data/ext/protoc/protobuf/src/google/protobuf/stubs/type_traits_unittest.cc +628 -0
  419. data/ext/protoc/protobuf/src/google/protobuf/test_util.cc +3345 -0
  420. data/ext/protoc/protobuf/src/google/protobuf/test_util.h +215 -0
  421. data/ext/protoc/protobuf/src/google/protobuf/test_util_lite.cc +1585 -0
  422. data/ext/protoc/protobuf/src/google/protobuf/test_util_lite.h +101 -0
  423. data/ext/protoc/protobuf/src/google/protobuf/testdata/bad_utf8_string +1 -0
  424. data/ext/protoc/protobuf/src/google/protobuf/testdata/golden_message +0 -0
  425. data/ext/protoc/protobuf/src/google/protobuf/testdata/golden_message_oneof_implemented +0 -0
  426. data/ext/protoc/protobuf/src/google/protobuf/testdata/golden_packed_fields_message +0 -0
  427. data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_data.txt +134 -0
  428. data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_data_oneof_implemented.txt +129 -0
  429. data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_data_pointy.txt +134 -0
  430. data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_data_pointy_oneof.txt +129 -0
  431. data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_extensions_data.txt +134 -0
  432. data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_extensions_data_pointy.txt +134 -0
  433. data/ext/protoc/protobuf/src/google/protobuf/testing/file.cc +194 -0
  434. data/ext/protoc/protobuf/src/google/protobuf/testing/file.h +97 -0
  435. data/ext/protoc/protobuf/src/google/protobuf/testing/googletest.cc +255 -0
  436. data/ext/protoc/protobuf/src/google/protobuf/testing/googletest.h +102 -0
  437. data/ext/protoc/protobuf/src/google/protobuf/testing/zcgunzip.cc +73 -0
  438. data/ext/protoc/protobuf/src/google/protobuf/testing/zcgzip.cc +79 -0
  439. data/ext/protoc/protobuf/src/google/protobuf/text_format.cc +1746 -0
  440. data/ext/protoc/protobuf/src/google/protobuf/text_format.h +473 -0
  441. data/ext/protoc/protobuf/src/google/protobuf/text_format_unittest.cc +1479 -0
  442. data/ext/protoc/protobuf/src/google/protobuf/unittest.proto +861 -0
  443. data/ext/protoc/protobuf/src/google/protobuf/unittest_custom_options.proto +393 -0
  444. data/ext/protoc/protobuf/src/google/protobuf/unittest_embed_optimize_for.proto +50 -0
  445. data/ext/protoc/protobuf/src/google/protobuf/unittest_empty.proto +37 -0
  446. data/ext/protoc/protobuf/src/google/protobuf/unittest_enormous_descriptor.proto +1046 -0
  447. data/ext/protoc/protobuf/src/google/protobuf/unittest_import.proto +64 -0
  448. data/ext/protoc/protobuf/src/google/protobuf/unittest_import_lite.proto +51 -0
  449. data/ext/protoc/protobuf/src/google/protobuf/unittest_import_public.proto +40 -0
  450. data/ext/protoc/protobuf/src/google/protobuf/unittest_import_public_lite.proto +42 -0
  451. data/ext/protoc/protobuf/src/google/protobuf/unittest_lite.proto +384 -0
  452. data/ext/protoc/protobuf/src/google/protobuf/unittest_lite_imports_nonlite.proto +43 -0
  453. data/ext/protoc/protobuf/src/google/protobuf/unittest_mset.proto +83 -0
  454. data/ext/protoc/protobuf/src/google/protobuf/unittest_no_generic_services.proto +53 -0
  455. data/ext/protoc/protobuf/src/google/protobuf/unittest_optimize_for.proto +66 -0
  456. data/ext/protoc/protobuf/src/google/protobuf/unknown_field_set.cc +265 -0
  457. data/ext/protoc/protobuf/src/google/protobuf/unknown_field_set.h +318 -0
  458. data/ext/protoc/protobuf/src/google/protobuf/unknown_field_set_unittest.cc +599 -0
  459. data/ext/protoc/protobuf/src/google/protobuf/wire_format.cc +1101 -0
  460. data/ext/protoc/protobuf/src/google/protobuf/wire_format.h +336 -0
  461. data/ext/protoc/protobuf/src/google/protobuf/wire_format_lite.cc +471 -0
  462. data/ext/protoc/protobuf/src/google/protobuf/wire_format_lite.h +661 -0
  463. data/ext/protoc/protobuf/src/google/protobuf/wire_format_lite_inl.h +860 -0
  464. data/ext/protoc/protobuf/src/google/protobuf/wire_format_unittest.cc +1120 -0
  465. data/ext/protoc/protobuf/src/solaris/libstdc++.la +51 -0
  466. data/ext/protoc/protobuf/vsprojects/config.h +29 -0
  467. data/ext/protoc/protobuf/vsprojects/convert2008to2005.sh +20 -0
  468. data/ext/protoc/protobuf/vsprojects/extract_includes.bat +50 -0
  469. data/ext/protoc/protobuf/vsprojects/libprotobuf-lite.vcproj +302 -0
  470. data/ext/protoc/protobuf/vsprojects/libprotobuf.vcproj +470 -0
  471. data/ext/protoc/protobuf/vsprojects/libprotoc.vcproj +466 -0
  472. data/ext/protoc/protobuf/vsprojects/lite-test.vcproj +305 -0
  473. data/ext/protoc/protobuf/vsprojects/protobuf.sln +92 -0
  474. data/ext/protoc/protobuf/vsprojects/protoc.vcproj +192 -0
  475. data/ext/protoc/protobuf/vsprojects/readme.txt +114 -0
  476. data/ext/protoc/protobuf/vsprojects/test_plugin.vcproj +209 -0
  477. data/ext/protoc/protobuf/vsprojects/tests.vcproj +681 -0
  478. data/lib/protoc/version.rb +1 -1
  479. metadata +480 -3
@@ -0,0 +1,1120 @@
1
+ // Protocol Buffers - Google's data interchange format
2
+ // Copyright 2008 Google Inc. All rights reserved.
3
+ // https://developers.google.com/protocol-buffers/
4
+ //
5
+ // Redistribution and use in source and binary forms, with or without
6
+ // modification, are permitted provided that the following conditions are
7
+ // met:
8
+ //
9
+ // * Redistributions of source code must retain the above copyright
10
+ // notice, this list of conditions and the following disclaimer.
11
+ // * Redistributions in binary form must reproduce the above
12
+ // copyright notice, this list of conditions and the following disclaimer
13
+ // in the documentation and/or other materials provided with the
14
+ // distribution.
15
+ // * Neither the name of Google Inc. nor the names of its
16
+ // contributors may be used to endorse or promote products derived from
17
+ // this software without specific prior written permission.
18
+ //
19
+ // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20
+ // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21
+ // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22
+ // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23
+ // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24
+ // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25
+ // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26
+ // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27
+ // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28
+ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30
+
31
+ // Author: kenton@google.com (Kenton Varda)
32
+ // Based on original Protocol Buffers design by
33
+ // Sanjay Ghemawat, Jeff Dean, and others.
34
+
35
+ #include <google/protobuf/wire_format.h>
36
+ #include <google/protobuf/wire_format_lite_inl.h>
37
+ #include <google/protobuf/descriptor.h>
38
+ #include <google/protobuf/io/zero_copy_stream_impl.h>
39
+ #include <google/protobuf/io/coded_stream.h>
40
+ #include <google/protobuf/unittest.pb.h>
41
+ #include <google/protobuf/unittest_mset.pb.h>
42
+ #include <google/protobuf/test_util.h>
43
+
44
+ #include <google/protobuf/stubs/common.h>
45
+ #include <google/protobuf/testing/googletest.h>
46
+ #include <gtest/gtest.h>
47
+ #include <google/protobuf/stubs/stl_util.h>
48
+
49
+ namespace google {
50
+ namespace protobuf {
51
+ namespace internal {
52
+ namespace {
53
+
54
+ TEST(WireFormatTest, EnumsInSync) {
55
+ // Verify that WireFormatLite::FieldType and WireFormatLite::CppType match
56
+ // FieldDescriptor::Type and FieldDescriptor::CppType.
57
+
58
+ EXPECT_EQ(implicit_cast<int>(FieldDescriptor::MAX_TYPE),
59
+ implicit_cast<int>(WireFormatLite::MAX_FIELD_TYPE));
60
+ EXPECT_EQ(implicit_cast<int>(FieldDescriptor::MAX_CPPTYPE),
61
+ implicit_cast<int>(WireFormatLite::MAX_CPPTYPE));
62
+
63
+ for (int i = 1; i <= WireFormatLite::MAX_FIELD_TYPE; i++) {
64
+ EXPECT_EQ(
65
+ implicit_cast<int>(FieldDescriptor::TypeToCppType(
66
+ static_cast<FieldDescriptor::Type>(i))),
67
+ implicit_cast<int>(WireFormatLite::FieldTypeToCppType(
68
+ static_cast<WireFormatLite::FieldType>(i))));
69
+ }
70
+ }
71
+
72
+ TEST(WireFormatTest, MaxFieldNumber) {
73
+ // Make sure the max field number constant is accurate.
74
+ EXPECT_EQ((1 << (32 - WireFormatLite::kTagTypeBits)) - 1,
75
+ FieldDescriptor::kMaxNumber);
76
+ }
77
+
78
+ TEST(WireFormatTest, Parse) {
79
+ unittest::TestAllTypes source, dest;
80
+ string data;
81
+
82
+ // Serialize using the generated code.
83
+ TestUtil::SetAllFields(&source);
84
+ source.SerializeToString(&data);
85
+
86
+ // Parse using WireFormat.
87
+ io::ArrayInputStream raw_input(data.data(), data.size());
88
+ io::CodedInputStream input(&raw_input);
89
+ WireFormat::ParseAndMergePartial(&input, &dest);
90
+
91
+ // Check.
92
+ TestUtil::ExpectAllFieldsSet(dest);
93
+ }
94
+
95
+ TEST(WireFormatTest, ParseExtensions) {
96
+ unittest::TestAllExtensions source, dest;
97
+ string data;
98
+
99
+ // Serialize using the generated code.
100
+ TestUtil::SetAllExtensions(&source);
101
+ source.SerializeToString(&data);
102
+
103
+ // Parse using WireFormat.
104
+ io::ArrayInputStream raw_input(data.data(), data.size());
105
+ io::CodedInputStream input(&raw_input);
106
+ WireFormat::ParseAndMergePartial(&input, &dest);
107
+
108
+ // Check.
109
+ TestUtil::ExpectAllExtensionsSet(dest);
110
+ }
111
+
112
+ TEST(WireFormatTest, ParsePacked) {
113
+ unittest::TestPackedTypes source, dest;
114
+ string data;
115
+
116
+ // Serialize using the generated code.
117
+ TestUtil::SetPackedFields(&source);
118
+ source.SerializeToString(&data);
119
+
120
+ // Parse using WireFormat.
121
+ io::ArrayInputStream raw_input(data.data(), data.size());
122
+ io::CodedInputStream input(&raw_input);
123
+ WireFormat::ParseAndMergePartial(&input, &dest);
124
+
125
+ // Check.
126
+ TestUtil::ExpectPackedFieldsSet(dest);
127
+ }
128
+
129
+ TEST(WireFormatTest, ParsePackedFromUnpacked) {
130
+ // Serialize using the generated code.
131
+ unittest::TestUnpackedTypes source;
132
+ TestUtil::SetUnpackedFields(&source);
133
+ string data = source.SerializeAsString();
134
+
135
+ // Parse using WireFormat.
136
+ unittest::TestPackedTypes dest;
137
+ io::ArrayInputStream raw_input(data.data(), data.size());
138
+ io::CodedInputStream input(&raw_input);
139
+ WireFormat::ParseAndMergePartial(&input, &dest);
140
+
141
+ // Check.
142
+ TestUtil::ExpectPackedFieldsSet(dest);
143
+ }
144
+
145
+ TEST(WireFormatTest, ParseUnpackedFromPacked) {
146
+ // Serialize using the generated code.
147
+ unittest::TestPackedTypes source;
148
+ TestUtil::SetPackedFields(&source);
149
+ string data = source.SerializeAsString();
150
+
151
+ // Parse using WireFormat.
152
+ unittest::TestUnpackedTypes dest;
153
+ io::ArrayInputStream raw_input(data.data(), data.size());
154
+ io::CodedInputStream input(&raw_input);
155
+ WireFormat::ParseAndMergePartial(&input, &dest);
156
+
157
+ // Check.
158
+ TestUtil::ExpectUnpackedFieldsSet(dest);
159
+ }
160
+
161
+ TEST(WireFormatTest, ParsePackedExtensions) {
162
+ unittest::TestPackedExtensions source, dest;
163
+ string data;
164
+
165
+ // Serialize using the generated code.
166
+ TestUtil::SetPackedExtensions(&source);
167
+ source.SerializeToString(&data);
168
+
169
+ // Parse using WireFormat.
170
+ io::ArrayInputStream raw_input(data.data(), data.size());
171
+ io::CodedInputStream input(&raw_input);
172
+ WireFormat::ParseAndMergePartial(&input, &dest);
173
+
174
+ // Check.
175
+ TestUtil::ExpectPackedExtensionsSet(dest);
176
+ }
177
+
178
+ TEST(WireFormatTest, ParseOneof) {
179
+ unittest::TestOneof2 source, dest;
180
+ string data;
181
+
182
+ // Serialize using the generated code.
183
+ TestUtil::SetOneof1(&source);
184
+ source.SerializeToString(&data);
185
+
186
+ // Parse using WireFormat.
187
+ io::ArrayInputStream raw_input(data.data(), data.size());
188
+ io::CodedInputStream input(&raw_input);
189
+ WireFormat::ParseAndMergePartial(&input, &dest);
190
+
191
+ // Check.
192
+ TestUtil::ExpectOneofSet1(dest);
193
+ }
194
+
195
+ TEST(WireFormatTest, OneofOnlySetLast) {
196
+ unittest::TestOneofBackwardsCompatible source;
197
+ unittest::TestOneof oneof_dest;
198
+ string data;
199
+
200
+ // Set two fields
201
+ source.set_foo_int(100);
202
+ source.set_foo_string("101");
203
+
204
+ // Serialize and parse to oneof message.
205
+ source.SerializeToString(&data);
206
+ io::ArrayInputStream raw_input(data.data(), data.size());
207
+ io::CodedInputStream input(&raw_input);
208
+ WireFormat::ParseAndMergePartial(&input, &oneof_dest);
209
+
210
+ // Only the last field is set.
211
+ EXPECT_FALSE(oneof_dest.has_foo_int());
212
+ EXPECT_TRUE(oneof_dest.has_foo_string());
213
+ }
214
+
215
+ TEST(WireFormatTest, ByteSize) {
216
+ unittest::TestAllTypes message;
217
+ TestUtil::SetAllFields(&message);
218
+
219
+ EXPECT_EQ(message.ByteSize(), WireFormat::ByteSize(message));
220
+ message.Clear();
221
+ EXPECT_EQ(0, message.ByteSize());
222
+ EXPECT_EQ(0, WireFormat::ByteSize(message));
223
+ }
224
+
225
+ TEST(WireFormatTest, ByteSizeExtensions) {
226
+ unittest::TestAllExtensions message;
227
+ TestUtil::SetAllExtensions(&message);
228
+
229
+ EXPECT_EQ(message.ByteSize(),
230
+ WireFormat::ByteSize(message));
231
+ message.Clear();
232
+ EXPECT_EQ(0, message.ByteSize());
233
+ EXPECT_EQ(0, WireFormat::ByteSize(message));
234
+ }
235
+
236
+ TEST(WireFormatTest, ByteSizePacked) {
237
+ unittest::TestPackedTypes message;
238
+ TestUtil::SetPackedFields(&message);
239
+
240
+ EXPECT_EQ(message.ByteSize(), WireFormat::ByteSize(message));
241
+ message.Clear();
242
+ EXPECT_EQ(0, message.ByteSize());
243
+ EXPECT_EQ(0, WireFormat::ByteSize(message));
244
+ }
245
+
246
+ TEST(WireFormatTest, ByteSizePackedExtensions) {
247
+ unittest::TestPackedExtensions message;
248
+ TestUtil::SetPackedExtensions(&message);
249
+
250
+ EXPECT_EQ(message.ByteSize(),
251
+ WireFormat::ByteSize(message));
252
+ message.Clear();
253
+ EXPECT_EQ(0, message.ByteSize());
254
+ EXPECT_EQ(0, WireFormat::ByteSize(message));
255
+ }
256
+
257
+ TEST(WireFormatTest, ByteSizeOneof) {
258
+ unittest::TestOneof2 message;
259
+ TestUtil::SetOneof1(&message);
260
+
261
+ EXPECT_EQ(message.ByteSize(),
262
+ WireFormat::ByteSize(message));
263
+ message.Clear();
264
+
265
+ EXPECT_EQ(0, message.ByteSize());
266
+ EXPECT_EQ(0, WireFormat::ByteSize(message));
267
+ }
268
+
269
+ TEST(WireFormatTest, Serialize) {
270
+ unittest::TestAllTypes message;
271
+ string generated_data;
272
+ string dynamic_data;
273
+
274
+ TestUtil::SetAllFields(&message);
275
+ int size = message.ByteSize();
276
+
277
+ // Serialize using the generated code.
278
+ {
279
+ io::StringOutputStream raw_output(&generated_data);
280
+ io::CodedOutputStream output(&raw_output);
281
+ message.SerializeWithCachedSizes(&output);
282
+ ASSERT_FALSE(output.HadError());
283
+ }
284
+
285
+ // Serialize using WireFormat.
286
+ {
287
+ io::StringOutputStream raw_output(&dynamic_data);
288
+ io::CodedOutputStream output(&raw_output);
289
+ WireFormat::SerializeWithCachedSizes(message, size, &output);
290
+ ASSERT_FALSE(output.HadError());
291
+ }
292
+
293
+ // Should be the same.
294
+ // Don't use EXPECT_EQ here because we're comparing raw binary data and
295
+ // we really don't want it dumped to stdout on failure.
296
+ EXPECT_TRUE(dynamic_data == generated_data);
297
+ }
298
+
299
+ TEST(WireFormatTest, SerializeExtensions) {
300
+ unittest::TestAllExtensions message;
301
+ string generated_data;
302
+ string dynamic_data;
303
+
304
+ TestUtil::SetAllExtensions(&message);
305
+ int size = message.ByteSize();
306
+
307
+ // Serialize using the generated code.
308
+ {
309
+ io::StringOutputStream raw_output(&generated_data);
310
+ io::CodedOutputStream output(&raw_output);
311
+ message.SerializeWithCachedSizes(&output);
312
+ ASSERT_FALSE(output.HadError());
313
+ }
314
+
315
+ // Serialize using WireFormat.
316
+ {
317
+ io::StringOutputStream raw_output(&dynamic_data);
318
+ io::CodedOutputStream output(&raw_output);
319
+ WireFormat::SerializeWithCachedSizes(message, size, &output);
320
+ ASSERT_FALSE(output.HadError());
321
+ }
322
+
323
+ // Should be the same.
324
+ // Don't use EXPECT_EQ here because we're comparing raw binary data and
325
+ // we really don't want it dumped to stdout on failure.
326
+ EXPECT_TRUE(dynamic_data == generated_data);
327
+ }
328
+
329
+ TEST(WireFormatTest, SerializeFieldsAndExtensions) {
330
+ unittest::TestFieldOrderings message;
331
+ string generated_data;
332
+ string dynamic_data;
333
+
334
+ TestUtil::SetAllFieldsAndExtensions(&message);
335
+ int size = message.ByteSize();
336
+
337
+ // Serialize using the generated code.
338
+ {
339
+ io::StringOutputStream raw_output(&generated_data);
340
+ io::CodedOutputStream output(&raw_output);
341
+ message.SerializeWithCachedSizes(&output);
342
+ ASSERT_FALSE(output.HadError());
343
+ }
344
+
345
+ // Serialize using WireFormat.
346
+ {
347
+ io::StringOutputStream raw_output(&dynamic_data);
348
+ io::CodedOutputStream output(&raw_output);
349
+ WireFormat::SerializeWithCachedSizes(message, size, &output);
350
+ ASSERT_FALSE(output.HadError());
351
+ }
352
+
353
+ // Should be the same.
354
+ // Don't use EXPECT_EQ here because we're comparing raw binary data and
355
+ // we really don't want it dumped to stdout on failure.
356
+ EXPECT_TRUE(dynamic_data == generated_data);
357
+
358
+ // Should output in canonical order.
359
+ TestUtil::ExpectAllFieldsAndExtensionsInOrder(dynamic_data);
360
+ TestUtil::ExpectAllFieldsAndExtensionsInOrder(generated_data);
361
+ }
362
+
363
+ TEST(WireFormatTest, SerializeOneof) {
364
+ unittest::TestOneof2 message;
365
+ string generated_data;
366
+ string dynamic_data;
367
+
368
+ TestUtil::SetOneof1(&message);
369
+ int size = message.ByteSize();
370
+
371
+ // Serialize using the generated code.
372
+ {
373
+ io::StringOutputStream raw_output(&generated_data);
374
+ io::CodedOutputStream output(&raw_output);
375
+ message.SerializeWithCachedSizes(&output);
376
+ ASSERT_FALSE(output.HadError());
377
+ }
378
+
379
+ // Serialize using WireFormat.
380
+ {
381
+ io::StringOutputStream raw_output(&dynamic_data);
382
+ io::CodedOutputStream output(&raw_output);
383
+ WireFormat::SerializeWithCachedSizes(message, size, &output);
384
+ ASSERT_FALSE(output.HadError());
385
+ }
386
+
387
+ // Should be the same.
388
+ // Don't use EXPECT_EQ here because we're comparing raw binary data and
389
+ // we really don't want it dumped to stdout on failure.
390
+ EXPECT_TRUE(dynamic_data == generated_data);
391
+ }
392
+
393
+ TEST(WireFormatTest, ParseMultipleExtensionRanges) {
394
+ // Make sure we can parse a message that contains multiple extensions ranges.
395
+ unittest::TestFieldOrderings source;
396
+ string data;
397
+
398
+ TestUtil::SetAllFieldsAndExtensions(&source);
399
+ source.SerializeToString(&data);
400
+
401
+ {
402
+ unittest::TestFieldOrderings dest;
403
+ EXPECT_TRUE(dest.ParseFromString(data));
404
+ EXPECT_EQ(source.DebugString(), dest.DebugString());
405
+ }
406
+
407
+ // Also test using reflection-based parsing.
408
+ {
409
+ unittest::TestFieldOrderings dest;
410
+ io::ArrayInputStream raw_input(data.data(), data.size());
411
+ io::CodedInputStream coded_input(&raw_input);
412
+ EXPECT_TRUE(WireFormat::ParseAndMergePartial(&coded_input, &dest));
413
+ EXPECT_EQ(source.DebugString(), dest.DebugString());
414
+ }
415
+ }
416
+
417
+ const int kUnknownTypeId = 1550055;
418
+
419
+ TEST(WireFormatTest, SerializeMessageSet) {
420
+ // Set up a TestMessageSet with two known messages and an unknown one.
421
+ unittest::TestMessageSet message_set;
422
+ message_set.MutableExtension(
423
+ unittest::TestMessageSetExtension1::message_set_extension)->set_i(123);
424
+ message_set.MutableExtension(
425
+ unittest::TestMessageSetExtension2::message_set_extension)->set_str("foo");
426
+ message_set.mutable_unknown_fields()->AddLengthDelimited(
427
+ kUnknownTypeId, "bar");
428
+
429
+ string data;
430
+ ASSERT_TRUE(message_set.SerializeToString(&data));
431
+
432
+ // Parse back using RawMessageSet and check the contents.
433
+ unittest::RawMessageSet raw;
434
+ ASSERT_TRUE(raw.ParseFromString(data));
435
+
436
+ EXPECT_EQ(0, raw.unknown_fields().field_count());
437
+
438
+ ASSERT_EQ(3, raw.item_size());
439
+ EXPECT_EQ(
440
+ unittest::TestMessageSetExtension1::descriptor()->extension(0)->number(),
441
+ raw.item(0).type_id());
442
+ EXPECT_EQ(
443
+ unittest::TestMessageSetExtension2::descriptor()->extension(0)->number(),
444
+ raw.item(1).type_id());
445
+ EXPECT_EQ(kUnknownTypeId, raw.item(2).type_id());
446
+
447
+ unittest::TestMessageSetExtension1 message1;
448
+ EXPECT_TRUE(message1.ParseFromString(raw.item(0).message()));
449
+ EXPECT_EQ(123, message1.i());
450
+
451
+ unittest::TestMessageSetExtension2 message2;
452
+ EXPECT_TRUE(message2.ParseFromString(raw.item(1).message()));
453
+ EXPECT_EQ("foo", message2.str());
454
+
455
+ EXPECT_EQ("bar", raw.item(2).message());
456
+ }
457
+
458
+ TEST(WireFormatTest, SerializeMessageSetVariousWaysAreEqual) {
459
+ // Serialize a MessageSet to a stream and to a flat array using generated
460
+ // code, and also using WireFormat, and check that the results are equal.
461
+ // Set up a TestMessageSet with two known messages and an unknown one, as
462
+ // above.
463
+
464
+ unittest::TestMessageSet message_set;
465
+ message_set.MutableExtension(
466
+ unittest::TestMessageSetExtension1::message_set_extension)->set_i(123);
467
+ message_set.MutableExtension(
468
+ unittest::TestMessageSetExtension2::message_set_extension)->set_str("foo");
469
+ message_set.mutable_unknown_fields()->AddLengthDelimited(
470
+ kUnknownTypeId, "bar");
471
+
472
+ int size = message_set.ByteSize();
473
+ EXPECT_EQ(size, message_set.GetCachedSize());
474
+ ASSERT_EQ(size, WireFormat::ByteSize(message_set));
475
+
476
+ string flat_data;
477
+ string stream_data;
478
+ string dynamic_data;
479
+ flat_data.resize(size);
480
+ stream_data.resize(size);
481
+
482
+ // Serialize to flat array
483
+ {
484
+ uint8* target = reinterpret_cast<uint8*>(string_as_array(&flat_data));
485
+ uint8* end = message_set.SerializeWithCachedSizesToArray(target);
486
+ EXPECT_EQ(size, end - target);
487
+ }
488
+
489
+ // Serialize to buffer
490
+ {
491
+ io::ArrayOutputStream array_stream(string_as_array(&stream_data), size, 1);
492
+ io::CodedOutputStream output_stream(&array_stream);
493
+ message_set.SerializeWithCachedSizes(&output_stream);
494
+ ASSERT_FALSE(output_stream.HadError());
495
+ }
496
+
497
+ // Serialize to buffer with WireFormat.
498
+ {
499
+ io::StringOutputStream string_stream(&dynamic_data);
500
+ io::CodedOutputStream output_stream(&string_stream);
501
+ WireFormat::SerializeWithCachedSizes(message_set, size, &output_stream);
502
+ ASSERT_FALSE(output_stream.HadError());
503
+ }
504
+
505
+ EXPECT_TRUE(flat_data == stream_data);
506
+ EXPECT_TRUE(flat_data == dynamic_data);
507
+ }
508
+
509
+ TEST(WireFormatTest, ParseMessageSet) {
510
+ // Set up a RawMessageSet with two known messages and an unknown one.
511
+ unittest::RawMessageSet raw;
512
+
513
+ {
514
+ unittest::RawMessageSet::Item* item = raw.add_item();
515
+ item->set_type_id(
516
+ unittest::TestMessageSetExtension1::descriptor()->extension(0)->number());
517
+ unittest::TestMessageSetExtension1 message;
518
+ message.set_i(123);
519
+ message.SerializeToString(item->mutable_message());
520
+ }
521
+
522
+ {
523
+ unittest::RawMessageSet::Item* item = raw.add_item();
524
+ item->set_type_id(
525
+ unittest::TestMessageSetExtension2::descriptor()->extension(0)->number());
526
+ unittest::TestMessageSetExtension2 message;
527
+ message.set_str("foo");
528
+ message.SerializeToString(item->mutable_message());
529
+ }
530
+
531
+ {
532
+ unittest::RawMessageSet::Item* item = raw.add_item();
533
+ item->set_type_id(kUnknownTypeId);
534
+ item->set_message("bar");
535
+ }
536
+
537
+ string data;
538
+ ASSERT_TRUE(raw.SerializeToString(&data));
539
+
540
+ // Parse as a TestMessageSet and check the contents.
541
+ unittest::TestMessageSet message_set;
542
+ ASSERT_TRUE(message_set.ParseFromString(data));
543
+
544
+ EXPECT_EQ(123, message_set.GetExtension(
545
+ unittest::TestMessageSetExtension1::message_set_extension).i());
546
+ EXPECT_EQ("foo", message_set.GetExtension(
547
+ unittest::TestMessageSetExtension2::message_set_extension).str());
548
+
549
+ ASSERT_EQ(1, message_set.unknown_fields().field_count());
550
+ ASSERT_EQ(UnknownField::TYPE_LENGTH_DELIMITED,
551
+ message_set.unknown_fields().field(0).type());
552
+ EXPECT_EQ("bar", message_set.unknown_fields().field(0).length_delimited());
553
+
554
+ // Also parse using WireFormat.
555
+ unittest::TestMessageSet dynamic_message_set;
556
+ io::CodedInputStream input(reinterpret_cast<const uint8*>(data.data()),
557
+ data.size());
558
+ ASSERT_TRUE(WireFormat::ParseAndMergePartial(&input, &dynamic_message_set));
559
+ EXPECT_EQ(message_set.DebugString(), dynamic_message_set.DebugString());
560
+ }
561
+
562
+ TEST(WireFormatTest, ParseMessageSetWithReverseTagOrder) {
563
+ string data;
564
+ {
565
+ unittest::TestMessageSetExtension1 message;
566
+ message.set_i(123);
567
+ // Build a MessageSet manually with its message content put before its
568
+ // type_id.
569
+ io::StringOutputStream output_stream(&data);
570
+ io::CodedOutputStream coded_output(&output_stream);
571
+ coded_output.WriteTag(WireFormatLite::kMessageSetItemStartTag);
572
+ // Write the message content first.
573
+ WireFormatLite::WriteTag(WireFormatLite::kMessageSetMessageNumber,
574
+ WireFormatLite::WIRETYPE_LENGTH_DELIMITED,
575
+ &coded_output);
576
+ coded_output.WriteVarint32(message.ByteSize());
577
+ message.SerializeWithCachedSizes(&coded_output);
578
+ // Write the type id.
579
+ uint32 type_id = message.GetDescriptor()->extension(0)->number();
580
+ WireFormatLite::WriteUInt32(WireFormatLite::kMessageSetTypeIdNumber,
581
+ type_id, &coded_output);
582
+ coded_output.WriteTag(WireFormatLite::kMessageSetItemEndTag);
583
+ }
584
+ {
585
+ unittest::TestMessageSet message_set;
586
+ ASSERT_TRUE(message_set.ParseFromString(data));
587
+
588
+ EXPECT_EQ(123, message_set.GetExtension(
589
+ unittest::TestMessageSetExtension1::message_set_extension).i());
590
+ }
591
+ {
592
+ // Test parse the message via Reflection.
593
+ unittest::TestMessageSet message_set;
594
+ io::CodedInputStream input(
595
+ reinterpret_cast<const uint8*>(data.data()), data.size());
596
+ EXPECT_TRUE(WireFormat::ParseAndMergePartial(&input, &message_set));
597
+ EXPECT_TRUE(input.ConsumedEntireMessage());
598
+
599
+ EXPECT_EQ(123, message_set.GetExtension(
600
+ unittest::TestMessageSetExtension1::message_set_extension).i());
601
+ }
602
+ }
603
+
604
+ TEST(WireFormatTest, ParseBrokenMessageSet) {
605
+ unittest::TestMessageSet message_set;
606
+ string input("goodbye"); // Invalid wire format data.
607
+ EXPECT_FALSE(message_set.ParseFromString(input));
608
+ }
609
+
610
+ TEST(WireFormatTest, RecursionLimit) {
611
+ unittest::TestRecursiveMessage message;
612
+ message.mutable_a()->mutable_a()->mutable_a()->mutable_a()->set_i(1);
613
+ string data;
614
+ message.SerializeToString(&data);
615
+
616
+ {
617
+ io::ArrayInputStream raw_input(data.data(), data.size());
618
+ io::CodedInputStream input(&raw_input);
619
+ input.SetRecursionLimit(4);
620
+ unittest::TestRecursiveMessage message2;
621
+ EXPECT_TRUE(message2.ParseFromCodedStream(&input));
622
+ }
623
+
624
+ {
625
+ io::ArrayInputStream raw_input(data.data(), data.size());
626
+ io::CodedInputStream input(&raw_input);
627
+ input.SetRecursionLimit(3);
628
+ unittest::TestRecursiveMessage message2;
629
+ EXPECT_FALSE(message2.ParseFromCodedStream(&input));
630
+ }
631
+ }
632
+
633
+ TEST(WireFormatTest, UnknownFieldRecursionLimit) {
634
+ unittest::TestEmptyMessage message;
635
+ message.mutable_unknown_fields()
636
+ ->AddGroup(1234)
637
+ ->AddGroup(1234)
638
+ ->AddGroup(1234)
639
+ ->AddGroup(1234)
640
+ ->AddVarint(1234, 123);
641
+ string data;
642
+ message.SerializeToString(&data);
643
+
644
+ {
645
+ io::ArrayInputStream raw_input(data.data(), data.size());
646
+ io::CodedInputStream input(&raw_input);
647
+ input.SetRecursionLimit(4);
648
+ unittest::TestEmptyMessage message2;
649
+ EXPECT_TRUE(message2.ParseFromCodedStream(&input));
650
+ }
651
+
652
+ {
653
+ io::ArrayInputStream raw_input(data.data(), data.size());
654
+ io::CodedInputStream input(&raw_input);
655
+ input.SetRecursionLimit(3);
656
+ unittest::TestEmptyMessage message2;
657
+ EXPECT_FALSE(message2.ParseFromCodedStream(&input));
658
+ }
659
+ }
660
+
661
+ TEST(WireFormatTest, ZigZag) {
662
+ // avoid line-wrapping
663
+ #define LL(x) GOOGLE_LONGLONG(x)
664
+ #define ULL(x) GOOGLE_ULONGLONG(x)
665
+ #define ZigZagEncode32(x) WireFormatLite::ZigZagEncode32(x)
666
+ #define ZigZagDecode32(x) WireFormatLite::ZigZagDecode32(x)
667
+ #define ZigZagEncode64(x) WireFormatLite::ZigZagEncode64(x)
668
+ #define ZigZagDecode64(x) WireFormatLite::ZigZagDecode64(x)
669
+
670
+ EXPECT_EQ(0u, ZigZagEncode32( 0));
671
+ EXPECT_EQ(1u, ZigZagEncode32(-1));
672
+ EXPECT_EQ(2u, ZigZagEncode32( 1));
673
+ EXPECT_EQ(3u, ZigZagEncode32(-2));
674
+ EXPECT_EQ(0x7FFFFFFEu, ZigZagEncode32(0x3FFFFFFF));
675
+ EXPECT_EQ(0x7FFFFFFFu, ZigZagEncode32(0xC0000000));
676
+ EXPECT_EQ(0xFFFFFFFEu, ZigZagEncode32(0x7FFFFFFF));
677
+ EXPECT_EQ(0xFFFFFFFFu, ZigZagEncode32(0x80000000));
678
+
679
+ EXPECT_EQ( 0, ZigZagDecode32(0u));
680
+ EXPECT_EQ(-1, ZigZagDecode32(1u));
681
+ EXPECT_EQ( 1, ZigZagDecode32(2u));
682
+ EXPECT_EQ(-2, ZigZagDecode32(3u));
683
+ EXPECT_EQ(0x3FFFFFFF, ZigZagDecode32(0x7FFFFFFEu));
684
+ EXPECT_EQ(0xC0000000, ZigZagDecode32(0x7FFFFFFFu));
685
+ EXPECT_EQ(0x7FFFFFFF, ZigZagDecode32(0xFFFFFFFEu));
686
+ EXPECT_EQ(0x80000000, ZigZagDecode32(0xFFFFFFFFu));
687
+
688
+ EXPECT_EQ(0u, ZigZagEncode64( 0));
689
+ EXPECT_EQ(1u, ZigZagEncode64(-1));
690
+ EXPECT_EQ(2u, ZigZagEncode64( 1));
691
+ EXPECT_EQ(3u, ZigZagEncode64(-2));
692
+ EXPECT_EQ(ULL(0x000000007FFFFFFE), ZigZagEncode64(LL(0x000000003FFFFFFF)));
693
+ EXPECT_EQ(ULL(0x000000007FFFFFFF), ZigZagEncode64(LL(0xFFFFFFFFC0000000)));
694
+ EXPECT_EQ(ULL(0x00000000FFFFFFFE), ZigZagEncode64(LL(0x000000007FFFFFFF)));
695
+ EXPECT_EQ(ULL(0x00000000FFFFFFFF), ZigZagEncode64(LL(0xFFFFFFFF80000000)));
696
+ EXPECT_EQ(ULL(0xFFFFFFFFFFFFFFFE), ZigZagEncode64(LL(0x7FFFFFFFFFFFFFFF)));
697
+ EXPECT_EQ(ULL(0xFFFFFFFFFFFFFFFF), ZigZagEncode64(LL(0x8000000000000000)));
698
+
699
+ EXPECT_EQ( 0, ZigZagDecode64(0u));
700
+ EXPECT_EQ(-1, ZigZagDecode64(1u));
701
+ EXPECT_EQ( 1, ZigZagDecode64(2u));
702
+ EXPECT_EQ(-2, ZigZagDecode64(3u));
703
+ EXPECT_EQ(LL(0x000000003FFFFFFF), ZigZagDecode64(ULL(0x000000007FFFFFFE)));
704
+ EXPECT_EQ(LL(0xFFFFFFFFC0000000), ZigZagDecode64(ULL(0x000000007FFFFFFF)));
705
+ EXPECT_EQ(LL(0x000000007FFFFFFF), ZigZagDecode64(ULL(0x00000000FFFFFFFE)));
706
+ EXPECT_EQ(LL(0xFFFFFFFF80000000), ZigZagDecode64(ULL(0x00000000FFFFFFFF)));
707
+ EXPECT_EQ(LL(0x7FFFFFFFFFFFFFFF), ZigZagDecode64(ULL(0xFFFFFFFFFFFFFFFE)));
708
+ EXPECT_EQ(LL(0x8000000000000000), ZigZagDecode64(ULL(0xFFFFFFFFFFFFFFFF)));
709
+
710
+ // Some easier-to-verify round-trip tests. The inputs (other than 0, 1, -1)
711
+ // were chosen semi-randomly via keyboard bashing.
712
+ EXPECT_EQ( 0, ZigZagDecode32(ZigZagEncode32( 0)));
713
+ EXPECT_EQ( 1, ZigZagDecode32(ZigZagEncode32( 1)));
714
+ EXPECT_EQ( -1, ZigZagDecode32(ZigZagEncode32( -1)));
715
+ EXPECT_EQ(14927, ZigZagDecode32(ZigZagEncode32(14927)));
716
+ EXPECT_EQ(-3612, ZigZagDecode32(ZigZagEncode32(-3612)));
717
+
718
+ EXPECT_EQ( 0, ZigZagDecode64(ZigZagEncode64( 0)));
719
+ EXPECT_EQ( 1, ZigZagDecode64(ZigZagEncode64( 1)));
720
+ EXPECT_EQ( -1, ZigZagDecode64(ZigZagEncode64( -1)));
721
+ EXPECT_EQ(14927, ZigZagDecode64(ZigZagEncode64(14927)));
722
+ EXPECT_EQ(-3612, ZigZagDecode64(ZigZagEncode64(-3612)));
723
+
724
+ EXPECT_EQ(LL(856912304801416), ZigZagDecode64(ZigZagEncode64(
725
+ LL(856912304801416))));
726
+ EXPECT_EQ(LL(-75123905439571256), ZigZagDecode64(ZigZagEncode64(
727
+ LL(-75123905439571256))));
728
+ }
729
+
730
+ TEST(WireFormatTest, RepeatedScalarsDifferentTagSizes) {
731
+ // At one point checks would trigger when parsing repeated fixed scalar
732
+ // fields.
733
+ protobuf_unittest::TestRepeatedScalarDifferentTagSizes msg1, msg2;
734
+ for (int i = 0; i < 100; ++i) {
735
+ msg1.add_repeated_fixed32(i);
736
+ msg1.add_repeated_int32(i);
737
+ msg1.add_repeated_fixed64(i);
738
+ msg1.add_repeated_int64(i);
739
+ msg1.add_repeated_float(i);
740
+ msg1.add_repeated_uint64(i);
741
+ }
742
+
743
+ // Make sure that we have a variety of tag sizes.
744
+ const google::protobuf::Descriptor* desc = msg1.GetDescriptor();
745
+ const google::protobuf::FieldDescriptor* field;
746
+ field = desc->FindFieldByName("repeated_fixed32");
747
+ ASSERT_TRUE(field != NULL);
748
+ ASSERT_EQ(1, WireFormat::TagSize(field->number(), field->type()));
749
+ field = desc->FindFieldByName("repeated_int32");
750
+ ASSERT_TRUE(field != NULL);
751
+ ASSERT_EQ(1, WireFormat::TagSize(field->number(), field->type()));
752
+ field = desc->FindFieldByName("repeated_fixed64");
753
+ ASSERT_TRUE(field != NULL);
754
+ ASSERT_EQ(2, WireFormat::TagSize(field->number(), field->type()));
755
+ field = desc->FindFieldByName("repeated_int64");
756
+ ASSERT_TRUE(field != NULL);
757
+ ASSERT_EQ(2, WireFormat::TagSize(field->number(), field->type()));
758
+ field = desc->FindFieldByName("repeated_float");
759
+ ASSERT_TRUE(field != NULL);
760
+ ASSERT_EQ(3, WireFormat::TagSize(field->number(), field->type()));
761
+ field = desc->FindFieldByName("repeated_uint64");
762
+ ASSERT_TRUE(field != NULL);
763
+ ASSERT_EQ(3, WireFormat::TagSize(field->number(), field->type()));
764
+
765
+ EXPECT_TRUE(msg2.ParseFromString(msg1.SerializeAsString()));
766
+ EXPECT_EQ(msg1.DebugString(), msg2.DebugString());
767
+ }
768
+
769
+ TEST(WireFormatTest, CompatibleTypes) {
770
+ const int64 data = 0x100000000;
771
+ unittest::Int64Message msg1;
772
+ msg1.set_data(data);
773
+ string serialized;
774
+ msg1.SerializeToString(&serialized);
775
+
776
+ // Test int64 is compatible with bool
777
+ unittest::BoolMessage msg2;
778
+ ASSERT_TRUE(msg2.ParseFromString(serialized));
779
+ ASSERT_EQ(static_cast<bool>(data), msg2.data());
780
+
781
+ // Test int64 is compatible with uint64
782
+ unittest::Uint64Message msg3;
783
+ ASSERT_TRUE(msg3.ParseFromString(serialized));
784
+ ASSERT_EQ(static_cast<uint64>(data), msg3.data());
785
+
786
+ // Test int64 is compatible with int32
787
+ unittest::Int32Message msg4;
788
+ ASSERT_TRUE(msg4.ParseFromString(serialized));
789
+ ASSERT_EQ(static_cast<int32>(data), msg4.data());
790
+
791
+ // Test int64 is compatible with uint32
792
+ unittest::Uint32Message msg5;
793
+ ASSERT_TRUE(msg5.ParseFromString(serialized));
794
+ ASSERT_EQ(static_cast<uint32>(data), msg5.data());
795
+ }
796
+
797
+ class WireFormatInvalidInputTest : public testing::Test {
798
+ protected:
799
+ // Make a serialized TestAllTypes in which the field optional_nested_message
800
+ // contains exactly the given bytes, which may be invalid.
801
+ string MakeInvalidEmbeddedMessage(const char* bytes, int size) {
802
+ const FieldDescriptor* field =
803
+ unittest::TestAllTypes::descriptor()->FindFieldByName(
804
+ "optional_nested_message");
805
+ GOOGLE_CHECK(field != NULL);
806
+
807
+ string result;
808
+
809
+ {
810
+ io::StringOutputStream raw_output(&result);
811
+ io::CodedOutputStream output(&raw_output);
812
+
813
+ WireFormatLite::WriteBytes(field->number(), string(bytes, size), &output);
814
+ }
815
+
816
+ return result;
817
+ }
818
+
819
+ // Make a serialized TestAllTypes in which the field optionalgroup
820
+ // contains exactly the given bytes -- which may be invalid -- and
821
+ // possibly no end tag.
822
+ string MakeInvalidGroup(const char* bytes, int size, bool include_end_tag) {
823
+ const FieldDescriptor* field =
824
+ unittest::TestAllTypes::descriptor()->FindFieldByName(
825
+ "optionalgroup");
826
+ GOOGLE_CHECK(field != NULL);
827
+
828
+ string result;
829
+
830
+ {
831
+ io::StringOutputStream raw_output(&result);
832
+ io::CodedOutputStream output(&raw_output);
833
+
834
+ output.WriteVarint32(WireFormat::MakeTag(field));
835
+ output.WriteString(string(bytes, size));
836
+ if (include_end_tag) {
837
+ output.WriteVarint32(WireFormatLite::MakeTag(
838
+ field->number(), WireFormatLite::WIRETYPE_END_GROUP));
839
+ }
840
+ }
841
+
842
+ return result;
843
+ }
844
+ };
845
+
846
+ TEST_F(WireFormatInvalidInputTest, InvalidSubMessage) {
847
+ unittest::TestAllTypes message;
848
+
849
+ // Control case.
850
+ EXPECT_TRUE(message.ParseFromString(MakeInvalidEmbeddedMessage("", 0)));
851
+
852
+ // The byte is a valid varint, but not a valid tag (zero).
853
+ EXPECT_FALSE(message.ParseFromString(MakeInvalidEmbeddedMessage("\0", 1)));
854
+
855
+ // The byte is a malformed varint.
856
+ EXPECT_FALSE(message.ParseFromString(MakeInvalidEmbeddedMessage("\200", 1)));
857
+
858
+ // The byte is an endgroup tag, but we aren't parsing a group.
859
+ EXPECT_FALSE(message.ParseFromString(MakeInvalidEmbeddedMessage("\014", 1)));
860
+
861
+ // The byte is a valid varint but not a valid tag (bad wire type).
862
+ EXPECT_FALSE(message.ParseFromString(MakeInvalidEmbeddedMessage("\017", 1)));
863
+ }
864
+
865
+ TEST_F(WireFormatInvalidInputTest, InvalidGroup) {
866
+ unittest::TestAllTypes message;
867
+
868
+ // Control case.
869
+ EXPECT_TRUE(message.ParseFromString(MakeInvalidGroup("", 0, true)));
870
+
871
+ // Missing end tag. Groups cannot end at EOF.
872
+ EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("", 0, false)));
873
+
874
+ // The byte is a valid varint, but not a valid tag (zero).
875
+ EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("\0", 1, false)));
876
+
877
+ // The byte is a malformed varint.
878
+ EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("\200", 1, false)));
879
+
880
+ // The byte is an endgroup tag, but not the right one for this group.
881
+ EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("\014", 1, false)));
882
+
883
+ // The byte is a valid varint but not a valid tag (bad wire type).
884
+ EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("\017", 1, true)));
885
+ }
886
+
887
+ TEST_F(WireFormatInvalidInputTest, InvalidUnknownGroup) {
888
+ // Use TestEmptyMessage so that the group made by MakeInvalidGroup will not
889
+ // be a known tag number.
890
+ unittest::TestEmptyMessage message;
891
+
892
+ // Control case.
893
+ EXPECT_TRUE(message.ParseFromString(MakeInvalidGroup("", 0, true)));
894
+
895
+ // Missing end tag. Groups cannot end at EOF.
896
+ EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("", 0, false)));
897
+
898
+ // The byte is a valid varint, but not a valid tag (zero).
899
+ EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("\0", 1, false)));
900
+
901
+ // The byte is a malformed varint.
902
+ EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("\200", 1, false)));
903
+
904
+ // The byte is an endgroup tag, but not the right one for this group.
905
+ EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("\014", 1, false)));
906
+
907
+ // The byte is a valid varint but not a valid tag (bad wire type).
908
+ EXPECT_FALSE(message.ParseFromString(MakeInvalidGroup("\017", 1, true)));
909
+ }
910
+
911
+ TEST_F(WireFormatInvalidInputTest, InvalidStringInUnknownGroup) {
912
+ // Test a bug fix: SkipMessage should fail if the message contains a string
913
+ // whose length would extend beyond the message end.
914
+
915
+ unittest::TestAllTypes message;
916
+ message.set_optional_string("foo foo foo foo");
917
+ string data;
918
+ message.SerializeToString(&data);
919
+
920
+ // Chop some bytes off the end.
921
+ data.resize(data.size() - 4);
922
+
923
+ // Try to skip it. Note that the bug was only present when parsing to an
924
+ // UnknownFieldSet.
925
+ io::ArrayInputStream raw_input(data.data(), data.size());
926
+ io::CodedInputStream coded_input(&raw_input);
927
+ UnknownFieldSet unknown_fields;
928
+ EXPECT_FALSE(WireFormat::SkipMessage(&coded_input, &unknown_fields));
929
+ }
930
+
931
+ // Test differences between string and bytes.
932
+ // Value of a string type must be valid UTF-8 string. When UTF-8
933
+ // validation is enabled (GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED):
934
+ // WriteInvalidUTF8String: see error message.
935
+ // ReadInvalidUTF8String: see error message.
936
+ // WriteValidUTF8String: fine.
937
+ // ReadValidUTF8String: fine.
938
+ // WriteAnyBytes: fine.
939
+ // ReadAnyBytes: fine.
940
+ const char * kInvalidUTF8String = "Invalid UTF-8: \xA0\xB0\xC0\xD0";
941
+ // This used to be "Valid UTF-8: \x01\x02\u8C37\u6B4C", but MSVC seems to
942
+ // interpret \u differently from GCC.
943
+ const char * kValidUTF8String = "Valid UTF-8: \x01\x02\350\260\267\346\255\214";
944
+
945
+ template<typename T>
946
+ bool WriteMessage(const char *value, T *message, string *wire_buffer) {
947
+ message->set_data(value);
948
+ wire_buffer->clear();
949
+ message->AppendToString(wire_buffer);
950
+ return (wire_buffer->size() > 0);
951
+ }
952
+
953
+ template<typename T>
954
+ bool ReadMessage(const string &wire_buffer, T *message) {
955
+ return message->ParseFromArray(wire_buffer.data(), wire_buffer.size());
956
+ }
957
+
958
+ bool StartsWith(const string& s, const string& prefix) {
959
+ return s.substr(0, prefix.length()) == prefix;
960
+ }
961
+
962
+ class Utf8ValidationTest : public ::testing::Test {
963
+ protected:
964
+ Utf8ValidationTest() {}
965
+ virtual ~Utf8ValidationTest() {}
966
+ virtual void SetUp() {
967
+ }
968
+
969
+ };
970
+
971
+ TEST_F(Utf8ValidationTest, WriteInvalidUTF8String) {
972
+ string wire_buffer;
973
+ protobuf_unittest::OneString input;
974
+ vector<string> errors;
975
+ {
976
+ ScopedMemoryLog log;
977
+ WriteMessage(kInvalidUTF8String, &input, &wire_buffer);
978
+ errors = log.GetMessages(ERROR);
979
+ }
980
+ #ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
981
+ ASSERT_EQ(1, errors.size());
982
+ EXPECT_TRUE(StartsWith(errors[0],
983
+ "String field 'data' contains invalid UTF-8 data when "
984
+ "serializing a protocol buffer. Use the "
985
+ "'bytes' type if you intend to send raw bytes."));
986
+ #else
987
+ ASSERT_EQ(0, errors.size());
988
+ #endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
989
+ }
990
+
991
+
992
+ TEST_F(Utf8ValidationTest, ReadInvalidUTF8String) {
993
+ string wire_buffer;
994
+ protobuf_unittest::OneString input;
995
+ WriteMessage(kInvalidUTF8String, &input, &wire_buffer);
996
+ protobuf_unittest::OneString output;
997
+ vector<string> errors;
998
+ {
999
+ ScopedMemoryLog log;
1000
+ ReadMessage(wire_buffer, &output);
1001
+ errors = log.GetMessages(ERROR);
1002
+ }
1003
+ #ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
1004
+ ASSERT_EQ(1, errors.size());
1005
+ EXPECT_TRUE(StartsWith(errors[0],
1006
+ "String field 'data' contains invalid UTF-8 data when "
1007
+ "parsing a protocol buffer. Use the "
1008
+ "'bytes' type if you intend to send raw bytes."));
1009
+
1010
+ #else
1011
+ ASSERT_EQ(0, errors.size());
1012
+ #endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
1013
+ }
1014
+
1015
+
1016
+ TEST_F(Utf8ValidationTest, WriteValidUTF8String) {
1017
+ string wire_buffer;
1018
+ protobuf_unittest::OneString input;
1019
+ vector<string> errors;
1020
+ {
1021
+ ScopedMemoryLog log;
1022
+ WriteMessage(kValidUTF8String, &input, &wire_buffer);
1023
+ errors = log.GetMessages(ERROR);
1024
+ }
1025
+ ASSERT_EQ(0, errors.size());
1026
+ }
1027
+
1028
+ TEST_F(Utf8ValidationTest, ReadValidUTF8String) {
1029
+ string wire_buffer;
1030
+ protobuf_unittest::OneString input;
1031
+ WriteMessage(kValidUTF8String, &input, &wire_buffer);
1032
+ protobuf_unittest::OneString output;
1033
+ vector<string> errors;
1034
+ {
1035
+ ScopedMemoryLog log;
1036
+ ReadMessage(wire_buffer, &output);
1037
+ errors = log.GetMessages(ERROR);
1038
+ }
1039
+ ASSERT_EQ(0, errors.size());
1040
+ EXPECT_EQ(input.data(), output.data());
1041
+ }
1042
+
1043
+ // Bytes: anything can pass as bytes, use invalid UTF-8 string to test
1044
+ TEST_F(Utf8ValidationTest, WriteArbitraryBytes) {
1045
+ string wire_buffer;
1046
+ protobuf_unittest::OneBytes input;
1047
+ vector<string> errors;
1048
+ {
1049
+ ScopedMemoryLog log;
1050
+ WriteMessage(kInvalidUTF8String, &input, &wire_buffer);
1051
+ errors = log.GetMessages(ERROR);
1052
+ }
1053
+ ASSERT_EQ(0, errors.size());
1054
+ }
1055
+
1056
+ TEST_F(Utf8ValidationTest, ReadArbitraryBytes) {
1057
+ string wire_buffer;
1058
+ protobuf_unittest::OneBytes input;
1059
+ WriteMessage(kInvalidUTF8String, &input, &wire_buffer);
1060
+ protobuf_unittest::OneBytes output;
1061
+ vector<string> errors;
1062
+ {
1063
+ ScopedMemoryLog log;
1064
+ ReadMessage(wire_buffer, &output);
1065
+ errors = log.GetMessages(ERROR);
1066
+ }
1067
+ ASSERT_EQ(0, errors.size());
1068
+ EXPECT_EQ(input.data(), output.data());
1069
+ }
1070
+
1071
+ TEST_F(Utf8ValidationTest, ParseRepeatedString) {
1072
+ protobuf_unittest::MoreBytes input;
1073
+ input.add_data(kValidUTF8String);
1074
+ input.add_data(kInvalidUTF8String);
1075
+ input.add_data(kInvalidUTF8String);
1076
+ string wire_buffer = input.SerializeAsString();
1077
+
1078
+ protobuf_unittest::MoreString output;
1079
+ vector<string> errors;
1080
+ {
1081
+ ScopedMemoryLog log;
1082
+ ReadMessage(wire_buffer, &output);
1083
+ errors = log.GetMessages(ERROR);
1084
+ }
1085
+ #ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
1086
+ ASSERT_EQ(2, errors.size());
1087
+ #else
1088
+ ASSERT_EQ(0, errors.size());
1089
+ #endif // GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
1090
+ EXPECT_EQ(wire_buffer, output.SerializeAsString());
1091
+ }
1092
+
1093
+ // Test the old VerifyUTF8String() function, which may still be called by old
1094
+ // generated code.
1095
+ TEST_F(Utf8ValidationTest, OldVerifyUTF8String) {
1096
+ string data(kInvalidUTF8String);
1097
+
1098
+ vector<string> errors;
1099
+ {
1100
+ ScopedMemoryLog log;
1101
+ WireFormat::VerifyUTF8String(data.data(), data.size(),
1102
+ WireFormat::SERIALIZE);
1103
+ errors = log.GetMessages(ERROR);
1104
+ }
1105
+ #ifdef GOOGLE_PROTOBUF_UTF8_VALIDATION_ENABLED
1106
+ ASSERT_EQ(1, errors.size());
1107
+ EXPECT_TRUE(StartsWith(errors[0],
1108
+ "String field contains invalid UTF-8 data when "
1109
+ "serializing a protocol buffer. Use the "
1110
+ "'bytes' type if you intend to send raw bytes."));
1111
+ #else
1112
+ ASSERT_EQ(0, errors.size());
1113
+ #endif
1114
+ }
1115
+
1116
+
1117
+ } // namespace
1118
+ } // namespace internal
1119
+ } // namespace protobuf
1120
+ } // namespace google