protoc 2.6.1.1 → 2.6.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/protoc/Makefile.in +10 -13
- data/ext/protoc/extconf.rb +0 -1
- data/ext/protoc/protobuf/CHANGES.txt +593 -0
- data/ext/protoc/protobuf/CONTRIBUTORS.txt +93 -0
- data/ext/protoc/protobuf/INSTALL.txt +237 -0
- data/ext/protoc/protobuf/LICENSE +33 -0
- data/ext/protoc/protobuf/Makefile.am +267 -0
- data/ext/protoc/protobuf/README.md +167 -0
- data/ext/protoc/protobuf/autogen.sh +41 -0
- data/ext/protoc/protobuf/benchmarks/ProtoBench.java +203 -0
- data/ext/protoc/protobuf/benchmarks/google_message1.dat +0 -0
- data/ext/protoc/protobuf/benchmarks/google_message2.dat +0 -0
- data/ext/protoc/protobuf/benchmarks/google_size.proto +136 -0
- data/ext/protoc/protobuf/benchmarks/google_speed.proto +136 -0
- data/ext/protoc/protobuf/benchmarks/readme.txt +50 -0
- data/ext/protoc/protobuf/configure.ac +159 -0
- data/ext/protoc/protobuf/editors/README.txt +5 -0
- data/ext/protoc/protobuf/editors/proto.vim +105 -0
- data/ext/protoc/protobuf/editors/protobuf-mode.el +220 -0
- data/ext/protoc/protobuf/examples/AddPerson.java +95 -0
- data/ext/protoc/protobuf/examples/ListPeople.java +50 -0
- data/ext/protoc/protobuf/examples/Makefile +58 -0
- data/ext/protoc/protobuf/examples/README.txt +29 -0
- data/ext/protoc/protobuf/examples/add_person.cc +95 -0
- data/ext/protoc/protobuf/examples/add_person.py +58 -0
- data/ext/protoc/protobuf/examples/addressbook.proto +30 -0
- data/ext/protoc/protobuf/examples/list_people.cc +68 -0
- data/ext/protoc/protobuf/examples/list_people.py +38 -0
- data/ext/protoc/protobuf/generate_descriptor_proto.sh +33 -0
- data/ext/protoc/protobuf/java/README.txt +96 -0
- data/ext/protoc/protobuf/java/pom.xml +217 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/AbstractMessage.java +466 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/AbstractMessageLite.java +355 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/AbstractParser.java +253 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/BlockingRpcChannel.java +51 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/BlockingService.java +64 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/BoundedByteString.java +163 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ByteString.java +1022 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/CodedInputStream.java +1311 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/CodedOutputStream.java +1297 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Descriptors.java +2238 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/DynamicMessage.java +622 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Extension.java +96 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ExtensionRegistry.java +392 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ExtensionRegistryLite.java +185 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/FieldSet.java +907 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/GeneratedMessage.java +2213 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/GeneratedMessageLite.java +949 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Internal.java +391 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/InvalidProtocolBufferException.java +122 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LazyField.java +154 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LazyFieldLite.java +176 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LazyStringArrayList.java +367 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LazyStringList.java +163 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/LiteralByteString.java +362 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Message.java +244 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/MessageLite.java +320 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/MessageLiteOrBuilder.java +60 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/MessageOrBuilder.java +143 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/MessageReflection.java +931 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Parser.java +261 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ProtocolMessageEnum.java +58 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ProtocolStringList.java +48 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RepeatedFieldBuilder.java +696 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RopeByteString.java +957 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RpcCallback.java +47 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RpcChannel.java +71 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RpcController.java +118 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/RpcUtil.java +134 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Service.java +117 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/ServiceException.java +52 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/SingleFieldBuilder.java +241 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/SmallSortedMap.java +618 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/TextFormat.java +1984 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/UninitializedMessageException.java +99 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/UnknownFieldSet.java +995 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/UnmodifiableLazyStringList.java +205 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/Utf8.java +349 -0
- data/ext/protoc/protobuf/java/src/main/java/com/google/protobuf/WireFormat.java +163 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/AbstractMessageTest.java +527 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/BoundedByteStringTest.java +68 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/ByteStringTest.java +759 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/CheckUtf8Test.java +141 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/CodedInputStreamTest.java +769 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/CodedOutputStreamTest.java +401 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/DeprecatedFieldTest.java +80 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/DescriptorsTest.java +735 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/DynamicMessageTest.java +326 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/ForceFieldBuildersPreRun.java +48 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/GeneratedMessageTest.java +1515 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/IsValidUtf8Test.java +180 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/IsValidUtf8TestUtil.java +421 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyFieldLiteTest.java +134 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyFieldTest.java +121 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyMessageLiteTest.java +319 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyStringArrayListTest.java +174 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LazyStringEndToEndTest.java +143 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LiteEqualsAndHashTest.java +85 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LiteTest.java +148 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/LiteralByteStringTest.java +396 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/MessageTest.java +353 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/NestedBuildersTest.java +185 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/ParserTest.java +381 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/RepeatedFieldBuilderTest.java +190 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/RopeByteStringSubstringTest.java +97 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/RopeByteStringTest.java +115 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/ServiceTest.java +320 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/SingleFieldBuilderTest.java +155 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/SmallSortedMapTest.java +420 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/TestBadIdentifiers.java +96 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/TestUtil.java +4124 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/TextFormatTest.java +994 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/UnknownFieldSetTest.java +653 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/UnmodifiableLazyStringListTest.java +227 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/WireFormatTest.java +606 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/lazy_fields_lite.proto +61 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/lite_equals_and_hash.proto +55 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/multiple_files_test.proto +77 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/nested_builders_test.proto +53 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/nested_extension.proto +46 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/nested_extension_lite.proto +48 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/non_nested_extension.proto +49 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/non_nested_extension_lite.proto +50 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/outer_class_name_test.proto +38 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/outer_class_name_test2.proto +42 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/outer_class_name_test3.proto +43 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_bad_identifiers.proto +157 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_check_utf8.proto +50 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_check_utf8_size.proto +51 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_custom_options.proto +43 -0
- data/ext/protoc/protobuf/java/src/test/java/com/google/protobuf/test_extra_interfaces.proto +60 -0
- data/ext/protoc/protobuf/m4/ac_system_extensions.m4 +37 -0
- data/ext/protoc/protobuf/m4/acx_check_suncc.m4 +75 -0
- data/ext/protoc/protobuf/m4/acx_pthread.m4 +397 -0
- data/ext/protoc/protobuf/m4/stl_hash.m4 +72 -0
- data/ext/protoc/protobuf/more_tests/Makefile +41 -0
- data/ext/protoc/protobuf/post_process_dist.sh +60 -0
- data/ext/protoc/protobuf/protobuf-lite.pc.in +13 -0
- data/ext/protoc/protobuf/protobuf.pc.in +14 -0
- data/ext/protoc/protobuf/python/README.txt +105 -0
- data/ext/protoc/protobuf/python/ez_setup.py +284 -0
- data/ext/protoc/protobuf/python/google/__init__.py +1 -0
- data/ext/protoc/protobuf/python/google/protobuf/__init__.py +0 -0
- data/ext/protoc/protobuf/python/google/protobuf/descriptor.py +849 -0
- data/ext/protoc/protobuf/python/google/protobuf/descriptor_database.py +137 -0
- data/ext/protoc/protobuf/python/google/protobuf/descriptor_pool.py +643 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/__init__.py +0 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/api_implementation.cc +139 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/api_implementation.py +89 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/api_implementation_default_test.py +63 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/containers.py +269 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/cpp_message.py +663 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/decoder.py +831 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_database_test.py +63 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_pool_test.py +564 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_pool_test1.proto +94 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_pool_test2.proto +70 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_python_test.py +54 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/descriptor_test.py +669 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/encoder.py +788 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/enum_type_wrapper.py +89 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/factory_test1.proto +57 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/factory_test2.proto +92 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/generator_test.py +343 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/message_factory_python_test.py +54 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/message_factory_test.py +131 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/message_listener.py +78 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/message_python_test.py +54 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/message_test.py +681 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/missing_enum_values.proto +50 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/more_extensions.proto +58 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/more_extensions_dynamic.proto +49 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/more_messages.proto +51 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/python_message.py +1251 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/reflection_test.py +2934 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/service_reflection_test.py +136 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/symbol_database_test.py +120 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/test_bad_identifiers.proto +52 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/test_util.py +662 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/text_encoding_test.py +68 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/text_format_test.py +743 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/type_checkers.py +328 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/unknown_fields_test.py +231 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/wire_format.py +268 -0
- data/ext/protoc/protobuf/python/google/protobuf/internal/wire_format_test.py +253 -0
- data/ext/protoc/protobuf/python/google/protobuf/message.py +284 -0
- data/ext/protoc/protobuf/python/google/protobuf/message_factory.py +155 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/README +6 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/__init__.py +0 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/cpp_message.py +61 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/descriptor.cc +357 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/descriptor.h +96 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/descriptor_cpp2_test.py +58 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/extension_dict.cc +338 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/extension_dict.h +123 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/message.cc +2561 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/message.h +305 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/message_factory_cpp2_test.py +56 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/proto2_api_test.proto +38 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/python.proto +66 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/python_protobuf.h +57 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/reflection_cpp2_generated_test.py +94 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/repeated_composite_container.cc +763 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/repeated_composite_container.h +172 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/repeated_scalar_container.cc +825 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/repeated_scalar_container.h +112 -0
- data/ext/protoc/protobuf/python/google/protobuf/pyext/scoped_pyobject_ptr.h +95 -0
- data/ext/protoc/protobuf/python/google/protobuf/reflection.py +205 -0
- data/ext/protoc/protobuf/python/google/protobuf/service.py +226 -0
- data/ext/protoc/protobuf/python/google/protobuf/service_reflection.py +284 -0
- data/ext/protoc/protobuf/python/google/protobuf/symbol_database.py +185 -0
- data/ext/protoc/protobuf/python/google/protobuf/text_encoding.py +110 -0
- data/ext/protoc/protobuf/python/google/protobuf/text_format.py +873 -0
- data/ext/protoc/protobuf/python/mox.py +1401 -0
- data/ext/protoc/protobuf/python/setup.py +201 -0
- data/ext/protoc/protobuf/python/stubout.py +140 -0
- data/ext/protoc/protobuf/src/Makefile.am +418 -0
- data/ext/protoc/protobuf/src/google/protobuf/SEBS +240 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/code_generator.cc +84 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/code_generator.h +145 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/command_line_interface.cc +1603 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/command_line_interface.h +378 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/command_line_interface_unittest.cc +1654 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc +158 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.cc +288 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_enum.h +103 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.cc +431 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_enum_field.h +122 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.cc +210 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_extension.h +86 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_field.cc +166 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_field.h +185 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_file.cc +665 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_file.h +99 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.cc +125 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_generator.h +72 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.cc +494 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_helpers.h +206 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_message.cc +2645 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_message.h +175 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.cc +375 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_message_field.h +121 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_options.h +58 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc +123 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc +451 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_primitive_field.h +123 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_service.cc +334 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_service.h +118 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.cc +642 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_string_field.h +127 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto +132 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_unittest.cc +2074 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/cpp/cpp_unittest.h +51 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/importer.cc +480 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/importer.h +317 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/importer_unittest.cc +617 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_context.cc +195 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_context.h +95 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_doc_comment.cc +233 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_doc_comment.h +69 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_doc_comment_unittest.cc +67 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_enum.cc +333 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_enum.h +99 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_enum_field.cc +778 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_enum_field.h +158 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_extension.cc +207 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_extension.h +109 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_field.cc +213 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_field.h +162 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_file.cc +534 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_file.h +115 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_generator.cc +158 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_generator.h +72 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_generator_factory.cc +77 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_generator_factory.h +101 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_helpers.cc +737 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_helpers.h +322 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_lazy_message_field.cc +826 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_lazy_message_field.h +121 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_message.cc +1666 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_message.h +140 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_message_field.cc +1343 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_message_field.h +173 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_name_resolver.cc +266 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_name_resolver.h +124 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_plugin_unittest.cc +124 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_primitive_field.cc +877 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_primitive_field.h +160 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_service.cc +473 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_service.h +135 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.cc +201 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_shared_code_generator.h +90 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_string_field.cc +1056 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/java/java_string_field.h +160 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/main.cc +61 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/mock_code_generator.cc +240 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/mock_code_generator.h +117 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/package_info.h +64 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/parser.cc +1750 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/parser.h +522 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/parser_unittest.cc +2612 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.cc +163 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.h +72 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.pb.cc +1148 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.pb.h +897 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/plugin.proto +147 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/python/python_generator.cc +1262 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/python/python_generator.h +166 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/python/python_plugin_unittest.cc +118 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/subprocess.cc +463 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/subprocess.h +108 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/test_plugin.cc +51 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/zip_output_unittest.sh +91 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/zip_writer.cc +218 -0
- data/ext/protoc/protobuf/src/google/protobuf/compiler/zip_writer.h +93 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor.cc +5420 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor.h +1691 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor.pb.cc +9135 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor.pb.h +6761 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor.proto +687 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor_database.cc +543 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor_database.h +369 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor_database_unittest.cc +748 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor_pb2_test.py +54 -0
- data/ext/protoc/protobuf/src/google/protobuf/descriptor_unittest.cc +5501 -0
- data/ext/protoc/protobuf/src/google/protobuf/dynamic_message.cc +764 -0
- data/ext/protoc/protobuf/src/google/protobuf/dynamic_message.h +148 -0
- data/ext/protoc/protobuf/src/google/protobuf/dynamic_message_unittest.cc +230 -0
- data/ext/protoc/protobuf/src/google/protobuf/extension_set.cc +1663 -0
- data/ext/protoc/protobuf/src/google/protobuf/extension_set.h +1234 -0
- data/ext/protoc/protobuf/src/google/protobuf/extension_set_heavy.cc +734 -0
- data/ext/protoc/protobuf/src/google/protobuf/extension_set_unittest.cc +1095 -0
- data/ext/protoc/protobuf/src/google/protobuf/generated_enum_reflection.h +91 -0
- data/ext/protoc/protobuf/src/google/protobuf/generated_message_reflection.cc +1683 -0
- data/ext/protoc/protobuf/src/google/protobuf/generated_message_reflection.h +504 -0
- data/ext/protoc/protobuf/src/google/protobuf/generated_message_reflection_unittest.cc +795 -0
- data/ext/protoc/protobuf/src/google/protobuf/generated_message_util.cc +65 -0
- data/ext/protoc/protobuf/src/google/protobuf/generated_message_util.h +113 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/coded_stream.cc +914 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/coded_stream.h +1220 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/coded_stream_inl.h +69 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/coded_stream_unittest.cc +1378 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/gzip_stream.cc +326 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/gzip_stream.h +209 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/gzip_stream_unittest.sh +44 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/package_info.h +54 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/printer.cc +198 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/printer.h +136 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/printer_unittest.cc +285 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/strtod.cc +113 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/strtod.h +50 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/tokenizer.cc +1127 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/tokenizer.h +402 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/tokenizer_unittest.cc +999 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream.cc +57 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream.h +248 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_impl.cc +473 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_impl.h +358 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.cc +405 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_impl_lite.h +354 -0
- data/ext/protoc/protobuf/src/google/protobuf/io/zero_copy_stream_unittest.cc +965 -0
- data/ext/protoc/protobuf/src/google/protobuf/lite_unittest.cc +350 -0
- data/ext/protoc/protobuf/src/google/protobuf/message.cc +358 -0
- data/ext/protoc/protobuf/src/google/protobuf/message.h +866 -0
- data/ext/protoc/protobuf/src/google/protobuf/message_lite.cc +335 -0
- data/ext/protoc/protobuf/src/google/protobuf/message_lite.h +247 -0
- data/ext/protoc/protobuf/src/google/protobuf/message_unittest.cc +427 -0
- data/ext/protoc/protobuf/src/google/protobuf/package_info.h +64 -0
- data/ext/protoc/protobuf/src/google/protobuf/reflection_ops.cc +269 -0
- data/ext/protoc/protobuf/src/google/protobuf/reflection_ops.h +81 -0
- data/ext/protoc/protobuf/src/google/protobuf/reflection_ops_unittest.cc +475 -0
- data/ext/protoc/protobuf/src/google/protobuf/repeated_field.cc +87 -0
- data/ext/protoc/protobuf/src/google/protobuf/repeated_field.h +1603 -0
- data/ext/protoc/protobuf/src/google/protobuf/repeated_field_reflection_unittest.cc +195 -0
- data/ext/protoc/protobuf/src/google/protobuf/repeated_field_unittest.cc +1442 -0
- data/ext/protoc/protobuf/src/google/protobuf/service.cc +46 -0
- data/ext/protoc/protobuf/src/google/protobuf/service.h +291 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops.h +227 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_arm64_gcc.h +325 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_gcc.h +151 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_arm_qnx.h +146 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_atomicword_compat.h +122 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_generic_gcc.h +137 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_macosx.h +225 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_mips_gcc.h +313 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_pnacl.h +73 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_solaris.h +188 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_tsan.h +219 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc +137 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h +293 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc +112 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h +150 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/common.cc +395 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/common.h +1226 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/common_unittest.cc +357 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/hash.h +232 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/map_util.h +771 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/once.cc +99 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/once.h +166 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/once_unittest.cc +253 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/platform_macros.h +103 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/shared_ptr.h +470 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/stl_util.h +121 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/stringprintf.cc +175 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/stringprintf.h +76 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/stringprintf_unittest.cc +152 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/structurally_valid.cc +536 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/structurally_valid_unittest.cc +40 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/strutil.cc +1279 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/strutil.h +562 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/strutil_unittest.cc +73 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/substitute.cc +134 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/substitute.h +170 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/template_util.h +138 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/template_util_unittest.cc +130 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/type_traits.h +336 -0
- data/ext/protoc/protobuf/src/google/protobuf/stubs/type_traits_unittest.cc +628 -0
- data/ext/protoc/protobuf/src/google/protobuf/test_util.cc +3345 -0
- data/ext/protoc/protobuf/src/google/protobuf/test_util.h +215 -0
- data/ext/protoc/protobuf/src/google/protobuf/test_util_lite.cc +1585 -0
- data/ext/protoc/protobuf/src/google/protobuf/test_util_lite.h +101 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/bad_utf8_string +1 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/golden_message +0 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/golden_message_oneof_implemented +0 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/golden_packed_fields_message +0 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_data.txt +134 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_data_oneof_implemented.txt +129 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_data_pointy.txt +134 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_data_pointy_oneof.txt +129 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_extensions_data.txt +134 -0
- data/ext/protoc/protobuf/src/google/protobuf/testdata/text_format_unittest_extensions_data_pointy.txt +134 -0
- data/ext/protoc/protobuf/src/google/protobuf/testing/file.cc +194 -0
- data/ext/protoc/protobuf/src/google/protobuf/testing/file.h +97 -0
- data/ext/protoc/protobuf/src/google/protobuf/testing/googletest.cc +255 -0
- data/ext/protoc/protobuf/src/google/protobuf/testing/googletest.h +102 -0
- data/ext/protoc/protobuf/src/google/protobuf/testing/zcgunzip.cc +73 -0
- data/ext/protoc/protobuf/src/google/protobuf/testing/zcgzip.cc +79 -0
- data/ext/protoc/protobuf/src/google/protobuf/text_format.cc +1746 -0
- data/ext/protoc/protobuf/src/google/protobuf/text_format.h +473 -0
- data/ext/protoc/protobuf/src/google/protobuf/text_format_unittest.cc +1479 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest.proto +861 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_custom_options.proto +393 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_embed_optimize_for.proto +50 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_empty.proto +37 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_enormous_descriptor.proto +1046 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_import.proto +64 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_import_lite.proto +51 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_import_public.proto +40 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_import_public_lite.proto +42 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_lite.proto +384 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_lite_imports_nonlite.proto +43 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_mset.proto +83 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_no_generic_services.proto +53 -0
- data/ext/protoc/protobuf/src/google/protobuf/unittest_optimize_for.proto +66 -0
- data/ext/protoc/protobuf/src/google/protobuf/unknown_field_set.cc +265 -0
- data/ext/protoc/protobuf/src/google/protobuf/unknown_field_set.h +318 -0
- data/ext/protoc/protobuf/src/google/protobuf/unknown_field_set_unittest.cc +599 -0
- data/ext/protoc/protobuf/src/google/protobuf/wire_format.cc +1101 -0
- data/ext/protoc/protobuf/src/google/protobuf/wire_format.h +336 -0
- data/ext/protoc/protobuf/src/google/protobuf/wire_format_lite.cc +471 -0
- data/ext/protoc/protobuf/src/google/protobuf/wire_format_lite.h +661 -0
- data/ext/protoc/protobuf/src/google/protobuf/wire_format_lite_inl.h +860 -0
- data/ext/protoc/protobuf/src/google/protobuf/wire_format_unittest.cc +1120 -0
- data/ext/protoc/protobuf/src/solaris/libstdc++.la +51 -0
- data/ext/protoc/protobuf/vsprojects/config.h +29 -0
- data/ext/protoc/protobuf/vsprojects/convert2008to2005.sh +20 -0
- data/ext/protoc/protobuf/vsprojects/extract_includes.bat +50 -0
- data/ext/protoc/protobuf/vsprojects/libprotobuf-lite.vcproj +302 -0
- data/ext/protoc/protobuf/vsprojects/libprotobuf.vcproj +470 -0
- data/ext/protoc/protobuf/vsprojects/libprotoc.vcproj +466 -0
- data/ext/protoc/protobuf/vsprojects/lite-test.vcproj +305 -0
- data/ext/protoc/protobuf/vsprojects/protobuf.sln +92 -0
- data/ext/protoc/protobuf/vsprojects/protoc.vcproj +192 -0
- data/ext/protoc/protobuf/vsprojects/readme.txt +114 -0
- data/ext/protoc/protobuf/vsprojects/test_plugin.vcproj +209 -0
- data/ext/protoc/protobuf/vsprojects/tests.vcproj +681 -0
- data/lib/protoc/version.rb +1 -1
- metadata +480 -3
@@ -0,0 +1,136 @@
|
|
1
|
+
#! /usr/bin/python
|
2
|
+
#
|
3
|
+
# Protocol Buffers - Google's data interchange format
|
4
|
+
# Copyright 2008 Google Inc. All rights reserved.
|
5
|
+
# https://developers.google.com/protocol-buffers/
|
6
|
+
#
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
8
|
+
# modification, are permitted provided that the following conditions are
|
9
|
+
# met:
|
10
|
+
#
|
11
|
+
# * Redistributions of source code must retain the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer.
|
13
|
+
# * Redistributions in binary form must reproduce the above
|
14
|
+
# copyright notice, this list of conditions and the following disclaimer
|
15
|
+
# in the documentation and/or other materials provided with the
|
16
|
+
# distribution.
|
17
|
+
# * Neither the name of Google Inc. nor the names of its
|
18
|
+
# contributors may be used to endorse or promote products derived from
|
19
|
+
# this software without specific prior written permission.
|
20
|
+
#
|
21
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
23
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
24
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
25
|
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
26
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
27
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
28
|
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
29
|
+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
30
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
31
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
|
33
|
+
"""Tests for google.protobuf.internal.service_reflection."""
|
34
|
+
|
35
|
+
__author__ = 'petar@google.com (Petar Petrov)'
|
36
|
+
|
37
|
+
from google.apputils import basetest
|
38
|
+
from google.protobuf import unittest_pb2
|
39
|
+
from google.protobuf import service_reflection
|
40
|
+
from google.protobuf import service
|
41
|
+
|
42
|
+
|
43
|
+
class FooUnitTest(basetest.TestCase):
|
44
|
+
|
45
|
+
def testService(self):
|
46
|
+
class MockRpcChannel(service.RpcChannel):
|
47
|
+
def CallMethod(self, method, controller, request, response, callback):
|
48
|
+
self.method = method
|
49
|
+
self.controller = controller
|
50
|
+
self.request = request
|
51
|
+
callback(response)
|
52
|
+
|
53
|
+
class MockRpcController(service.RpcController):
|
54
|
+
def SetFailed(self, msg):
|
55
|
+
self.failure_message = msg
|
56
|
+
|
57
|
+
self.callback_response = None
|
58
|
+
|
59
|
+
class MyService(unittest_pb2.TestService):
|
60
|
+
pass
|
61
|
+
|
62
|
+
self.callback_response = None
|
63
|
+
|
64
|
+
def MyCallback(response):
|
65
|
+
self.callback_response = response
|
66
|
+
|
67
|
+
rpc_controller = MockRpcController()
|
68
|
+
channel = MockRpcChannel()
|
69
|
+
srvc = MyService()
|
70
|
+
srvc.Foo(rpc_controller, unittest_pb2.FooRequest(), MyCallback)
|
71
|
+
self.assertEqual('Method Foo not implemented.',
|
72
|
+
rpc_controller.failure_message)
|
73
|
+
self.assertEqual(None, self.callback_response)
|
74
|
+
|
75
|
+
rpc_controller.failure_message = None
|
76
|
+
|
77
|
+
service_descriptor = unittest_pb2.TestService.GetDescriptor()
|
78
|
+
srvc.CallMethod(service_descriptor.methods[1], rpc_controller,
|
79
|
+
unittest_pb2.BarRequest(), MyCallback)
|
80
|
+
self.assertEqual('Method Bar not implemented.',
|
81
|
+
rpc_controller.failure_message)
|
82
|
+
self.assertEqual(None, self.callback_response)
|
83
|
+
|
84
|
+
class MyServiceImpl(unittest_pb2.TestService):
|
85
|
+
def Foo(self, rpc_controller, request, done):
|
86
|
+
self.foo_called = True
|
87
|
+
def Bar(self, rpc_controller, request, done):
|
88
|
+
self.bar_called = True
|
89
|
+
|
90
|
+
srvc = MyServiceImpl()
|
91
|
+
rpc_controller.failure_message = None
|
92
|
+
srvc.Foo(rpc_controller, unittest_pb2.FooRequest(), MyCallback)
|
93
|
+
self.assertEqual(None, rpc_controller.failure_message)
|
94
|
+
self.assertEqual(True, srvc.foo_called)
|
95
|
+
|
96
|
+
rpc_controller.failure_message = None
|
97
|
+
srvc.CallMethod(service_descriptor.methods[1], rpc_controller,
|
98
|
+
unittest_pb2.BarRequest(), MyCallback)
|
99
|
+
self.assertEqual(None, rpc_controller.failure_message)
|
100
|
+
self.assertEqual(True, srvc.bar_called)
|
101
|
+
|
102
|
+
def testServiceStub(self):
|
103
|
+
class MockRpcChannel(service.RpcChannel):
|
104
|
+
def CallMethod(self, method, controller, request,
|
105
|
+
response_class, callback):
|
106
|
+
self.method = method
|
107
|
+
self.controller = controller
|
108
|
+
self.request = request
|
109
|
+
callback(response_class())
|
110
|
+
|
111
|
+
self.callback_response = None
|
112
|
+
|
113
|
+
def MyCallback(response):
|
114
|
+
self.callback_response = response
|
115
|
+
|
116
|
+
channel = MockRpcChannel()
|
117
|
+
stub = unittest_pb2.TestService_Stub(channel)
|
118
|
+
rpc_controller = 'controller'
|
119
|
+
request = 'request'
|
120
|
+
|
121
|
+
# GetDescriptor now static, still works as instance method for compatability
|
122
|
+
self.assertEqual(unittest_pb2.TestService_Stub.GetDescriptor(),
|
123
|
+
stub.GetDescriptor())
|
124
|
+
|
125
|
+
# Invoke method.
|
126
|
+
stub.Foo(rpc_controller, request, MyCallback)
|
127
|
+
|
128
|
+
self.assertTrue(isinstance(self.callback_response,
|
129
|
+
unittest_pb2.FooResponse))
|
130
|
+
self.assertEqual(request, channel.request)
|
131
|
+
self.assertEqual(rpc_controller, channel.controller)
|
132
|
+
self.assertEqual(stub.GetDescriptor().methods[0], channel.method)
|
133
|
+
|
134
|
+
|
135
|
+
if __name__ == '__main__':
|
136
|
+
basetest.main()
|
@@ -0,0 +1,120 @@
|
|
1
|
+
#! /usr/bin/python
|
2
|
+
#
|
3
|
+
# Protocol Buffers - Google's data interchange format
|
4
|
+
# Copyright 2008 Google Inc. All rights reserved.
|
5
|
+
# https://developers.google.com/protocol-buffers/
|
6
|
+
#
|
7
|
+
# Redistribution and use in source and binary forms, with or without
|
8
|
+
# modification, are permitted provided that the following conditions are
|
9
|
+
# met:
|
10
|
+
#
|
11
|
+
# * Redistributions of source code must retain the above copyright
|
12
|
+
# notice, this list of conditions and the following disclaimer.
|
13
|
+
# * Redistributions in binary form must reproduce the above
|
14
|
+
# copyright notice, this list of conditions and the following disclaimer
|
15
|
+
# in the documentation and/or other materials provided with the
|
16
|
+
# distribution.
|
17
|
+
# * Neither the name of Google Inc. nor the names of its
|
18
|
+
# contributors may be used to endorse or promote products derived from
|
19
|
+
# this software without specific prior written permission.
|
20
|
+
#
|
21
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
22
|
+
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
23
|
+
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
24
|
+
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
25
|
+
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
26
|
+
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
27
|
+
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
28
|
+
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
29
|
+
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
30
|
+
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
31
|
+
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
32
|
+
|
33
|
+
"""Tests for google.protobuf.symbol_database."""
|
34
|
+
|
35
|
+
from google.apputils import basetest
|
36
|
+
from google.protobuf import unittest_pb2
|
37
|
+
from google.protobuf import symbol_database
|
38
|
+
|
39
|
+
|
40
|
+
class SymbolDatabaseTest(basetest.TestCase):
|
41
|
+
|
42
|
+
def _Database(self):
|
43
|
+
db = symbol_database.SymbolDatabase()
|
44
|
+
# Register representative types from unittest_pb2.
|
45
|
+
db.RegisterFileDescriptor(unittest_pb2.DESCRIPTOR)
|
46
|
+
db.RegisterMessage(unittest_pb2.TestAllTypes)
|
47
|
+
db.RegisterMessage(unittest_pb2.TestAllTypes.NestedMessage)
|
48
|
+
db.RegisterMessage(unittest_pb2.TestAllTypes.OptionalGroup)
|
49
|
+
db.RegisterMessage(unittest_pb2.TestAllTypes.RepeatedGroup)
|
50
|
+
db.RegisterEnumDescriptor(unittest_pb2.ForeignEnum.DESCRIPTOR)
|
51
|
+
db.RegisterEnumDescriptor(unittest_pb2.TestAllTypes.NestedEnum.DESCRIPTOR)
|
52
|
+
return db
|
53
|
+
|
54
|
+
def testGetPrototype(self):
|
55
|
+
instance = self._Database().GetPrototype(
|
56
|
+
unittest_pb2.TestAllTypes.DESCRIPTOR)
|
57
|
+
self.assertTrue(instance is unittest_pb2.TestAllTypes)
|
58
|
+
|
59
|
+
def testGetMessages(self):
|
60
|
+
messages = self._Database().GetMessages(
|
61
|
+
['google/protobuf/unittest.proto'])
|
62
|
+
self.assertTrue(
|
63
|
+
unittest_pb2.TestAllTypes is
|
64
|
+
messages['protobuf_unittest.TestAllTypes'])
|
65
|
+
|
66
|
+
def testGetSymbol(self):
|
67
|
+
self.assertEquals(
|
68
|
+
unittest_pb2.TestAllTypes, self._Database().GetSymbol(
|
69
|
+
'protobuf_unittest.TestAllTypes'))
|
70
|
+
self.assertEquals(
|
71
|
+
unittest_pb2.TestAllTypes.NestedMessage, self._Database().GetSymbol(
|
72
|
+
'protobuf_unittest.TestAllTypes.NestedMessage'))
|
73
|
+
self.assertEquals(
|
74
|
+
unittest_pb2.TestAllTypes.OptionalGroup, self._Database().GetSymbol(
|
75
|
+
'protobuf_unittest.TestAllTypes.OptionalGroup'))
|
76
|
+
self.assertEquals(
|
77
|
+
unittest_pb2.TestAllTypes.RepeatedGroup, self._Database().GetSymbol(
|
78
|
+
'protobuf_unittest.TestAllTypes.RepeatedGroup'))
|
79
|
+
|
80
|
+
def testEnums(self):
|
81
|
+
# Check registration of types in the pool.
|
82
|
+
self.assertEquals(
|
83
|
+
'protobuf_unittest.ForeignEnum',
|
84
|
+
self._Database().pool.FindEnumTypeByName(
|
85
|
+
'protobuf_unittest.ForeignEnum').full_name)
|
86
|
+
self.assertEquals(
|
87
|
+
'protobuf_unittest.TestAllTypes.NestedEnum',
|
88
|
+
self._Database().pool.FindEnumTypeByName(
|
89
|
+
'protobuf_unittest.TestAllTypes.NestedEnum').full_name)
|
90
|
+
|
91
|
+
def testFindMessageTypeByName(self):
|
92
|
+
self.assertEquals(
|
93
|
+
'protobuf_unittest.TestAllTypes',
|
94
|
+
self._Database().pool.FindMessageTypeByName(
|
95
|
+
'protobuf_unittest.TestAllTypes').full_name)
|
96
|
+
self.assertEquals(
|
97
|
+
'protobuf_unittest.TestAllTypes.NestedMessage',
|
98
|
+
self._Database().pool.FindMessageTypeByName(
|
99
|
+
'protobuf_unittest.TestAllTypes.NestedMessage').full_name)
|
100
|
+
|
101
|
+
def testFindFindContainingSymbol(self):
|
102
|
+
# Lookup based on either enum or message.
|
103
|
+
self.assertEquals(
|
104
|
+
'google/protobuf/unittest.proto',
|
105
|
+
self._Database().pool.FindFileContainingSymbol(
|
106
|
+
'protobuf_unittest.TestAllTypes.NestedEnum').name)
|
107
|
+
self.assertEquals(
|
108
|
+
'google/protobuf/unittest.proto',
|
109
|
+
self._Database().pool.FindFileContainingSymbol(
|
110
|
+
'protobuf_unittest.TestAllTypes').name)
|
111
|
+
|
112
|
+
def testFindFileByName(self):
|
113
|
+
self.assertEquals(
|
114
|
+
'google/protobuf/unittest.proto',
|
115
|
+
self._Database().pool.FindFileByName(
|
116
|
+
'google/protobuf/unittest.proto').name)
|
117
|
+
|
118
|
+
|
119
|
+
if __name__ == '__main__':
|
120
|
+
basetest.main()
|
@@ -0,0 +1,52 @@
|
|
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
|
+
|
33
|
+
|
34
|
+
package protobuf_unittest;
|
35
|
+
|
36
|
+
option py_generic_services = true;
|
37
|
+
|
38
|
+
message TestBadIdentifiers {
|
39
|
+
extensions 100 to max;
|
40
|
+
}
|
41
|
+
|
42
|
+
// Make sure these reasonable extension names don't conflict with internal
|
43
|
+
// variables.
|
44
|
+
extend TestBadIdentifiers {
|
45
|
+
optional string message = 100 [default="foo"];
|
46
|
+
optional string descriptor = 101 [default="bar"];
|
47
|
+
optional string reflection = 102 [default="baz"];
|
48
|
+
optional string service = 103 [default="qux"];
|
49
|
+
}
|
50
|
+
|
51
|
+
message AnotherMessage {}
|
52
|
+
service AnotherService {}
|
@@ -0,0 +1,662 @@
|
|
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
|
+
"""Utilities for Python proto2 tests.
|
32
|
+
|
33
|
+
This is intentionally modeled on C++ code in
|
34
|
+
//google/protobuf/test_util.*.
|
35
|
+
"""
|
36
|
+
|
37
|
+
__author__ = 'robinson@google.com (Will Robinson)'
|
38
|
+
|
39
|
+
import os.path
|
40
|
+
|
41
|
+
from google.protobuf import unittest_import_pb2
|
42
|
+
from google.protobuf import unittest_pb2
|
43
|
+
|
44
|
+
|
45
|
+
def SetAllNonLazyFields(message):
|
46
|
+
"""Sets every non-lazy field in the message to a unique value.
|
47
|
+
|
48
|
+
Args:
|
49
|
+
message: A unittest_pb2.TestAllTypes instance.
|
50
|
+
"""
|
51
|
+
|
52
|
+
#
|
53
|
+
# Optional fields.
|
54
|
+
#
|
55
|
+
|
56
|
+
message.optional_int32 = 101
|
57
|
+
message.optional_int64 = 102
|
58
|
+
message.optional_uint32 = 103
|
59
|
+
message.optional_uint64 = 104
|
60
|
+
message.optional_sint32 = 105
|
61
|
+
message.optional_sint64 = 106
|
62
|
+
message.optional_fixed32 = 107
|
63
|
+
message.optional_fixed64 = 108
|
64
|
+
message.optional_sfixed32 = 109
|
65
|
+
message.optional_sfixed64 = 110
|
66
|
+
message.optional_float = 111
|
67
|
+
message.optional_double = 112
|
68
|
+
message.optional_bool = True
|
69
|
+
message.optional_string = u'115'
|
70
|
+
message.optional_bytes = b'116'
|
71
|
+
|
72
|
+
message.optionalgroup.a = 117
|
73
|
+
message.optional_nested_message.bb = 118
|
74
|
+
message.optional_foreign_message.c = 119
|
75
|
+
message.optional_import_message.d = 120
|
76
|
+
message.optional_public_import_message.e = 126
|
77
|
+
|
78
|
+
message.optional_nested_enum = unittest_pb2.TestAllTypes.BAZ
|
79
|
+
message.optional_foreign_enum = unittest_pb2.FOREIGN_BAZ
|
80
|
+
message.optional_import_enum = unittest_import_pb2.IMPORT_BAZ
|
81
|
+
|
82
|
+
message.optional_string_piece = u'124'
|
83
|
+
message.optional_cord = u'125'
|
84
|
+
|
85
|
+
#
|
86
|
+
# Repeated fields.
|
87
|
+
#
|
88
|
+
|
89
|
+
message.repeated_int32.append(201)
|
90
|
+
message.repeated_int64.append(202)
|
91
|
+
message.repeated_uint32.append(203)
|
92
|
+
message.repeated_uint64.append(204)
|
93
|
+
message.repeated_sint32.append(205)
|
94
|
+
message.repeated_sint64.append(206)
|
95
|
+
message.repeated_fixed32.append(207)
|
96
|
+
message.repeated_fixed64.append(208)
|
97
|
+
message.repeated_sfixed32.append(209)
|
98
|
+
message.repeated_sfixed64.append(210)
|
99
|
+
message.repeated_float.append(211)
|
100
|
+
message.repeated_double.append(212)
|
101
|
+
message.repeated_bool.append(True)
|
102
|
+
message.repeated_string.append(u'215')
|
103
|
+
message.repeated_bytes.append(b'216')
|
104
|
+
|
105
|
+
message.repeatedgroup.add().a = 217
|
106
|
+
message.repeated_nested_message.add().bb = 218
|
107
|
+
message.repeated_foreign_message.add().c = 219
|
108
|
+
message.repeated_import_message.add().d = 220
|
109
|
+
message.repeated_lazy_message.add().bb = 227
|
110
|
+
|
111
|
+
message.repeated_nested_enum.append(unittest_pb2.TestAllTypes.BAR)
|
112
|
+
message.repeated_foreign_enum.append(unittest_pb2.FOREIGN_BAR)
|
113
|
+
message.repeated_import_enum.append(unittest_import_pb2.IMPORT_BAR)
|
114
|
+
|
115
|
+
message.repeated_string_piece.append(u'224')
|
116
|
+
message.repeated_cord.append(u'225')
|
117
|
+
|
118
|
+
# Add a second one of each field.
|
119
|
+
message.repeated_int32.append(301)
|
120
|
+
message.repeated_int64.append(302)
|
121
|
+
message.repeated_uint32.append(303)
|
122
|
+
message.repeated_uint64.append(304)
|
123
|
+
message.repeated_sint32.append(305)
|
124
|
+
message.repeated_sint64.append(306)
|
125
|
+
message.repeated_fixed32.append(307)
|
126
|
+
message.repeated_fixed64.append(308)
|
127
|
+
message.repeated_sfixed32.append(309)
|
128
|
+
message.repeated_sfixed64.append(310)
|
129
|
+
message.repeated_float.append(311)
|
130
|
+
message.repeated_double.append(312)
|
131
|
+
message.repeated_bool.append(False)
|
132
|
+
message.repeated_string.append(u'315')
|
133
|
+
message.repeated_bytes.append(b'316')
|
134
|
+
|
135
|
+
message.repeatedgroup.add().a = 317
|
136
|
+
message.repeated_nested_message.add().bb = 318
|
137
|
+
message.repeated_foreign_message.add().c = 319
|
138
|
+
message.repeated_import_message.add().d = 320
|
139
|
+
message.repeated_lazy_message.add().bb = 327
|
140
|
+
|
141
|
+
message.repeated_nested_enum.append(unittest_pb2.TestAllTypes.BAZ)
|
142
|
+
message.repeated_foreign_enum.append(unittest_pb2.FOREIGN_BAZ)
|
143
|
+
message.repeated_import_enum.append(unittest_import_pb2.IMPORT_BAZ)
|
144
|
+
|
145
|
+
message.repeated_string_piece.append(u'324')
|
146
|
+
message.repeated_cord.append(u'325')
|
147
|
+
|
148
|
+
#
|
149
|
+
# Fields that have defaults.
|
150
|
+
#
|
151
|
+
|
152
|
+
message.default_int32 = 401
|
153
|
+
message.default_int64 = 402
|
154
|
+
message.default_uint32 = 403
|
155
|
+
message.default_uint64 = 404
|
156
|
+
message.default_sint32 = 405
|
157
|
+
message.default_sint64 = 406
|
158
|
+
message.default_fixed32 = 407
|
159
|
+
message.default_fixed64 = 408
|
160
|
+
message.default_sfixed32 = 409
|
161
|
+
message.default_sfixed64 = 410
|
162
|
+
message.default_float = 411
|
163
|
+
message.default_double = 412
|
164
|
+
message.default_bool = False
|
165
|
+
message.default_string = '415'
|
166
|
+
message.default_bytes = b'416'
|
167
|
+
|
168
|
+
message.default_nested_enum = unittest_pb2.TestAllTypes.FOO
|
169
|
+
message.default_foreign_enum = unittest_pb2.FOREIGN_FOO
|
170
|
+
message.default_import_enum = unittest_import_pb2.IMPORT_FOO
|
171
|
+
|
172
|
+
message.default_string_piece = '424'
|
173
|
+
message.default_cord = '425'
|
174
|
+
|
175
|
+
message.oneof_uint32 = 601
|
176
|
+
message.oneof_nested_message.bb = 602
|
177
|
+
message.oneof_string = '603'
|
178
|
+
message.oneof_bytes = b'604'
|
179
|
+
|
180
|
+
|
181
|
+
def SetAllFields(message):
|
182
|
+
SetAllNonLazyFields(message)
|
183
|
+
message.optional_lazy_message.bb = 127
|
184
|
+
|
185
|
+
|
186
|
+
def SetAllExtensions(message):
|
187
|
+
"""Sets every extension in the message to a unique value.
|
188
|
+
|
189
|
+
Args:
|
190
|
+
message: A unittest_pb2.TestAllExtensions instance.
|
191
|
+
"""
|
192
|
+
|
193
|
+
extensions = message.Extensions
|
194
|
+
pb2 = unittest_pb2
|
195
|
+
import_pb2 = unittest_import_pb2
|
196
|
+
|
197
|
+
#
|
198
|
+
# Optional fields.
|
199
|
+
#
|
200
|
+
|
201
|
+
extensions[pb2.optional_int32_extension] = 101
|
202
|
+
extensions[pb2.optional_int64_extension] = 102
|
203
|
+
extensions[pb2.optional_uint32_extension] = 103
|
204
|
+
extensions[pb2.optional_uint64_extension] = 104
|
205
|
+
extensions[pb2.optional_sint32_extension] = 105
|
206
|
+
extensions[pb2.optional_sint64_extension] = 106
|
207
|
+
extensions[pb2.optional_fixed32_extension] = 107
|
208
|
+
extensions[pb2.optional_fixed64_extension] = 108
|
209
|
+
extensions[pb2.optional_sfixed32_extension] = 109
|
210
|
+
extensions[pb2.optional_sfixed64_extension] = 110
|
211
|
+
extensions[pb2.optional_float_extension] = 111
|
212
|
+
extensions[pb2.optional_double_extension] = 112
|
213
|
+
extensions[pb2.optional_bool_extension] = True
|
214
|
+
extensions[pb2.optional_string_extension] = u'115'
|
215
|
+
extensions[pb2.optional_bytes_extension] = b'116'
|
216
|
+
|
217
|
+
extensions[pb2.optionalgroup_extension].a = 117
|
218
|
+
extensions[pb2.optional_nested_message_extension].bb = 118
|
219
|
+
extensions[pb2.optional_foreign_message_extension].c = 119
|
220
|
+
extensions[pb2.optional_import_message_extension].d = 120
|
221
|
+
extensions[pb2.optional_public_import_message_extension].e = 126
|
222
|
+
extensions[pb2.optional_lazy_message_extension].bb = 127
|
223
|
+
|
224
|
+
extensions[pb2.optional_nested_enum_extension] = pb2.TestAllTypes.BAZ
|
225
|
+
extensions[pb2.optional_nested_enum_extension] = pb2.TestAllTypes.BAZ
|
226
|
+
extensions[pb2.optional_foreign_enum_extension] = pb2.FOREIGN_BAZ
|
227
|
+
extensions[pb2.optional_import_enum_extension] = import_pb2.IMPORT_BAZ
|
228
|
+
|
229
|
+
extensions[pb2.optional_string_piece_extension] = u'124'
|
230
|
+
extensions[pb2.optional_cord_extension] = u'125'
|
231
|
+
|
232
|
+
#
|
233
|
+
# Repeated fields.
|
234
|
+
#
|
235
|
+
|
236
|
+
extensions[pb2.repeated_int32_extension].append(201)
|
237
|
+
extensions[pb2.repeated_int64_extension].append(202)
|
238
|
+
extensions[pb2.repeated_uint32_extension].append(203)
|
239
|
+
extensions[pb2.repeated_uint64_extension].append(204)
|
240
|
+
extensions[pb2.repeated_sint32_extension].append(205)
|
241
|
+
extensions[pb2.repeated_sint64_extension].append(206)
|
242
|
+
extensions[pb2.repeated_fixed32_extension].append(207)
|
243
|
+
extensions[pb2.repeated_fixed64_extension].append(208)
|
244
|
+
extensions[pb2.repeated_sfixed32_extension].append(209)
|
245
|
+
extensions[pb2.repeated_sfixed64_extension].append(210)
|
246
|
+
extensions[pb2.repeated_float_extension].append(211)
|
247
|
+
extensions[pb2.repeated_double_extension].append(212)
|
248
|
+
extensions[pb2.repeated_bool_extension].append(True)
|
249
|
+
extensions[pb2.repeated_string_extension].append(u'215')
|
250
|
+
extensions[pb2.repeated_bytes_extension].append(b'216')
|
251
|
+
|
252
|
+
extensions[pb2.repeatedgroup_extension].add().a = 217
|
253
|
+
extensions[pb2.repeated_nested_message_extension].add().bb = 218
|
254
|
+
extensions[pb2.repeated_foreign_message_extension].add().c = 219
|
255
|
+
extensions[pb2.repeated_import_message_extension].add().d = 220
|
256
|
+
extensions[pb2.repeated_lazy_message_extension].add().bb = 227
|
257
|
+
|
258
|
+
extensions[pb2.repeated_nested_enum_extension].append(pb2.TestAllTypes.BAR)
|
259
|
+
extensions[pb2.repeated_foreign_enum_extension].append(pb2.FOREIGN_BAR)
|
260
|
+
extensions[pb2.repeated_import_enum_extension].append(import_pb2.IMPORT_BAR)
|
261
|
+
|
262
|
+
extensions[pb2.repeated_string_piece_extension].append(u'224')
|
263
|
+
extensions[pb2.repeated_cord_extension].append(u'225')
|
264
|
+
|
265
|
+
# Append a second one of each field.
|
266
|
+
extensions[pb2.repeated_int32_extension].append(301)
|
267
|
+
extensions[pb2.repeated_int64_extension].append(302)
|
268
|
+
extensions[pb2.repeated_uint32_extension].append(303)
|
269
|
+
extensions[pb2.repeated_uint64_extension].append(304)
|
270
|
+
extensions[pb2.repeated_sint32_extension].append(305)
|
271
|
+
extensions[pb2.repeated_sint64_extension].append(306)
|
272
|
+
extensions[pb2.repeated_fixed32_extension].append(307)
|
273
|
+
extensions[pb2.repeated_fixed64_extension].append(308)
|
274
|
+
extensions[pb2.repeated_sfixed32_extension].append(309)
|
275
|
+
extensions[pb2.repeated_sfixed64_extension].append(310)
|
276
|
+
extensions[pb2.repeated_float_extension].append(311)
|
277
|
+
extensions[pb2.repeated_double_extension].append(312)
|
278
|
+
extensions[pb2.repeated_bool_extension].append(False)
|
279
|
+
extensions[pb2.repeated_string_extension].append(u'315')
|
280
|
+
extensions[pb2.repeated_bytes_extension].append(b'316')
|
281
|
+
|
282
|
+
extensions[pb2.repeatedgroup_extension].add().a = 317
|
283
|
+
extensions[pb2.repeated_nested_message_extension].add().bb = 318
|
284
|
+
extensions[pb2.repeated_foreign_message_extension].add().c = 319
|
285
|
+
extensions[pb2.repeated_import_message_extension].add().d = 320
|
286
|
+
extensions[pb2.repeated_lazy_message_extension].add().bb = 327
|
287
|
+
|
288
|
+
extensions[pb2.repeated_nested_enum_extension].append(pb2.TestAllTypes.BAZ)
|
289
|
+
extensions[pb2.repeated_foreign_enum_extension].append(pb2.FOREIGN_BAZ)
|
290
|
+
extensions[pb2.repeated_import_enum_extension].append(import_pb2.IMPORT_BAZ)
|
291
|
+
|
292
|
+
extensions[pb2.repeated_string_piece_extension].append(u'324')
|
293
|
+
extensions[pb2.repeated_cord_extension].append(u'325')
|
294
|
+
|
295
|
+
#
|
296
|
+
# Fields with defaults.
|
297
|
+
#
|
298
|
+
|
299
|
+
extensions[pb2.default_int32_extension] = 401
|
300
|
+
extensions[pb2.default_int64_extension] = 402
|
301
|
+
extensions[pb2.default_uint32_extension] = 403
|
302
|
+
extensions[pb2.default_uint64_extension] = 404
|
303
|
+
extensions[pb2.default_sint32_extension] = 405
|
304
|
+
extensions[pb2.default_sint64_extension] = 406
|
305
|
+
extensions[pb2.default_fixed32_extension] = 407
|
306
|
+
extensions[pb2.default_fixed64_extension] = 408
|
307
|
+
extensions[pb2.default_sfixed32_extension] = 409
|
308
|
+
extensions[pb2.default_sfixed64_extension] = 410
|
309
|
+
extensions[pb2.default_float_extension] = 411
|
310
|
+
extensions[pb2.default_double_extension] = 412
|
311
|
+
extensions[pb2.default_bool_extension] = False
|
312
|
+
extensions[pb2.default_string_extension] = u'415'
|
313
|
+
extensions[pb2.default_bytes_extension] = b'416'
|
314
|
+
|
315
|
+
extensions[pb2.default_nested_enum_extension] = pb2.TestAllTypes.FOO
|
316
|
+
extensions[pb2.default_foreign_enum_extension] = pb2.FOREIGN_FOO
|
317
|
+
extensions[pb2.default_import_enum_extension] = import_pb2.IMPORT_FOO
|
318
|
+
|
319
|
+
extensions[pb2.default_string_piece_extension] = u'424'
|
320
|
+
extensions[pb2.default_cord_extension] = '425'
|
321
|
+
|
322
|
+
extensions[pb2.oneof_uint32_extension] = 601
|
323
|
+
extensions[pb2.oneof_nested_message_extension].bb = 602
|
324
|
+
extensions[pb2.oneof_string_extension] = u'603'
|
325
|
+
extensions[pb2.oneof_bytes_extension] = b'604'
|
326
|
+
|
327
|
+
|
328
|
+
def SetAllFieldsAndExtensions(message):
|
329
|
+
"""Sets every field and extension in the message to a unique value.
|
330
|
+
|
331
|
+
Args:
|
332
|
+
message: A unittest_pb2.TestAllExtensions message.
|
333
|
+
"""
|
334
|
+
message.my_int = 1
|
335
|
+
message.my_string = 'foo'
|
336
|
+
message.my_float = 1.0
|
337
|
+
message.Extensions[unittest_pb2.my_extension_int] = 23
|
338
|
+
message.Extensions[unittest_pb2.my_extension_string] = 'bar'
|
339
|
+
|
340
|
+
|
341
|
+
def ExpectAllFieldsAndExtensionsInOrder(serialized):
|
342
|
+
"""Ensures that serialized is the serialization we expect for a message
|
343
|
+
filled with SetAllFieldsAndExtensions(). (Specifically, ensures that the
|
344
|
+
serialization is in canonical, tag-number order).
|
345
|
+
"""
|
346
|
+
my_extension_int = unittest_pb2.my_extension_int
|
347
|
+
my_extension_string = unittest_pb2.my_extension_string
|
348
|
+
expected_strings = []
|
349
|
+
message = unittest_pb2.TestFieldOrderings()
|
350
|
+
message.my_int = 1 # Field 1.
|
351
|
+
expected_strings.append(message.SerializeToString())
|
352
|
+
message.Clear()
|
353
|
+
message.Extensions[my_extension_int] = 23 # Field 5.
|
354
|
+
expected_strings.append(message.SerializeToString())
|
355
|
+
message.Clear()
|
356
|
+
message.my_string = 'foo' # Field 11.
|
357
|
+
expected_strings.append(message.SerializeToString())
|
358
|
+
message.Clear()
|
359
|
+
message.Extensions[my_extension_string] = 'bar' # Field 50.
|
360
|
+
expected_strings.append(message.SerializeToString())
|
361
|
+
message.Clear()
|
362
|
+
message.my_float = 1.0
|
363
|
+
expected_strings.append(message.SerializeToString())
|
364
|
+
message.Clear()
|
365
|
+
expected = b''.join(expected_strings)
|
366
|
+
|
367
|
+
if expected != serialized:
|
368
|
+
raise ValueError('Expected %r, found %r' % (expected, serialized))
|
369
|
+
|
370
|
+
|
371
|
+
def ExpectAllFieldsSet(test_case, message):
|
372
|
+
"""Check all fields for correct values have after Set*Fields() is called."""
|
373
|
+
test_case.assertTrue(message.HasField('optional_int32'))
|
374
|
+
test_case.assertTrue(message.HasField('optional_int64'))
|
375
|
+
test_case.assertTrue(message.HasField('optional_uint32'))
|
376
|
+
test_case.assertTrue(message.HasField('optional_uint64'))
|
377
|
+
test_case.assertTrue(message.HasField('optional_sint32'))
|
378
|
+
test_case.assertTrue(message.HasField('optional_sint64'))
|
379
|
+
test_case.assertTrue(message.HasField('optional_fixed32'))
|
380
|
+
test_case.assertTrue(message.HasField('optional_fixed64'))
|
381
|
+
test_case.assertTrue(message.HasField('optional_sfixed32'))
|
382
|
+
test_case.assertTrue(message.HasField('optional_sfixed64'))
|
383
|
+
test_case.assertTrue(message.HasField('optional_float'))
|
384
|
+
test_case.assertTrue(message.HasField('optional_double'))
|
385
|
+
test_case.assertTrue(message.HasField('optional_bool'))
|
386
|
+
test_case.assertTrue(message.HasField('optional_string'))
|
387
|
+
test_case.assertTrue(message.HasField('optional_bytes'))
|
388
|
+
|
389
|
+
test_case.assertTrue(message.HasField('optionalgroup'))
|
390
|
+
test_case.assertTrue(message.HasField('optional_nested_message'))
|
391
|
+
test_case.assertTrue(message.HasField('optional_foreign_message'))
|
392
|
+
test_case.assertTrue(message.HasField('optional_import_message'))
|
393
|
+
|
394
|
+
test_case.assertTrue(message.optionalgroup.HasField('a'))
|
395
|
+
test_case.assertTrue(message.optional_nested_message.HasField('bb'))
|
396
|
+
test_case.assertTrue(message.optional_foreign_message.HasField('c'))
|
397
|
+
test_case.assertTrue(message.optional_import_message.HasField('d'))
|
398
|
+
|
399
|
+
test_case.assertTrue(message.HasField('optional_nested_enum'))
|
400
|
+
test_case.assertTrue(message.HasField('optional_foreign_enum'))
|
401
|
+
test_case.assertTrue(message.HasField('optional_import_enum'))
|
402
|
+
|
403
|
+
test_case.assertTrue(message.HasField('optional_string_piece'))
|
404
|
+
test_case.assertTrue(message.HasField('optional_cord'))
|
405
|
+
|
406
|
+
test_case.assertEqual(101, message.optional_int32)
|
407
|
+
test_case.assertEqual(102, message.optional_int64)
|
408
|
+
test_case.assertEqual(103, message.optional_uint32)
|
409
|
+
test_case.assertEqual(104, message.optional_uint64)
|
410
|
+
test_case.assertEqual(105, message.optional_sint32)
|
411
|
+
test_case.assertEqual(106, message.optional_sint64)
|
412
|
+
test_case.assertEqual(107, message.optional_fixed32)
|
413
|
+
test_case.assertEqual(108, message.optional_fixed64)
|
414
|
+
test_case.assertEqual(109, message.optional_sfixed32)
|
415
|
+
test_case.assertEqual(110, message.optional_sfixed64)
|
416
|
+
test_case.assertEqual(111, message.optional_float)
|
417
|
+
test_case.assertEqual(112, message.optional_double)
|
418
|
+
test_case.assertEqual(True, message.optional_bool)
|
419
|
+
test_case.assertEqual('115', message.optional_string)
|
420
|
+
test_case.assertEqual(b'116', message.optional_bytes)
|
421
|
+
|
422
|
+
test_case.assertEqual(117, message.optionalgroup.a)
|
423
|
+
test_case.assertEqual(118, message.optional_nested_message.bb)
|
424
|
+
test_case.assertEqual(119, message.optional_foreign_message.c)
|
425
|
+
test_case.assertEqual(120, message.optional_import_message.d)
|
426
|
+
test_case.assertEqual(126, message.optional_public_import_message.e)
|
427
|
+
test_case.assertEqual(127, message.optional_lazy_message.bb)
|
428
|
+
|
429
|
+
test_case.assertEqual(unittest_pb2.TestAllTypes.BAZ,
|
430
|
+
message.optional_nested_enum)
|
431
|
+
test_case.assertEqual(unittest_pb2.FOREIGN_BAZ,
|
432
|
+
message.optional_foreign_enum)
|
433
|
+
test_case.assertEqual(unittest_import_pb2.IMPORT_BAZ,
|
434
|
+
message.optional_import_enum)
|
435
|
+
|
436
|
+
# -----------------------------------------------------------------
|
437
|
+
|
438
|
+
test_case.assertEqual(2, len(message.repeated_int32))
|
439
|
+
test_case.assertEqual(2, len(message.repeated_int64))
|
440
|
+
test_case.assertEqual(2, len(message.repeated_uint32))
|
441
|
+
test_case.assertEqual(2, len(message.repeated_uint64))
|
442
|
+
test_case.assertEqual(2, len(message.repeated_sint32))
|
443
|
+
test_case.assertEqual(2, len(message.repeated_sint64))
|
444
|
+
test_case.assertEqual(2, len(message.repeated_fixed32))
|
445
|
+
test_case.assertEqual(2, len(message.repeated_fixed64))
|
446
|
+
test_case.assertEqual(2, len(message.repeated_sfixed32))
|
447
|
+
test_case.assertEqual(2, len(message.repeated_sfixed64))
|
448
|
+
test_case.assertEqual(2, len(message.repeated_float))
|
449
|
+
test_case.assertEqual(2, len(message.repeated_double))
|
450
|
+
test_case.assertEqual(2, len(message.repeated_bool))
|
451
|
+
test_case.assertEqual(2, len(message.repeated_string))
|
452
|
+
test_case.assertEqual(2, len(message.repeated_bytes))
|
453
|
+
|
454
|
+
test_case.assertEqual(2, len(message.repeatedgroup))
|
455
|
+
test_case.assertEqual(2, len(message.repeated_nested_message))
|
456
|
+
test_case.assertEqual(2, len(message.repeated_foreign_message))
|
457
|
+
test_case.assertEqual(2, len(message.repeated_import_message))
|
458
|
+
test_case.assertEqual(2, len(message.repeated_nested_enum))
|
459
|
+
test_case.assertEqual(2, len(message.repeated_foreign_enum))
|
460
|
+
test_case.assertEqual(2, len(message.repeated_import_enum))
|
461
|
+
|
462
|
+
test_case.assertEqual(2, len(message.repeated_string_piece))
|
463
|
+
test_case.assertEqual(2, len(message.repeated_cord))
|
464
|
+
|
465
|
+
test_case.assertEqual(201, message.repeated_int32[0])
|
466
|
+
test_case.assertEqual(202, message.repeated_int64[0])
|
467
|
+
test_case.assertEqual(203, message.repeated_uint32[0])
|
468
|
+
test_case.assertEqual(204, message.repeated_uint64[0])
|
469
|
+
test_case.assertEqual(205, message.repeated_sint32[0])
|
470
|
+
test_case.assertEqual(206, message.repeated_sint64[0])
|
471
|
+
test_case.assertEqual(207, message.repeated_fixed32[0])
|
472
|
+
test_case.assertEqual(208, message.repeated_fixed64[0])
|
473
|
+
test_case.assertEqual(209, message.repeated_sfixed32[0])
|
474
|
+
test_case.assertEqual(210, message.repeated_sfixed64[0])
|
475
|
+
test_case.assertEqual(211, message.repeated_float[0])
|
476
|
+
test_case.assertEqual(212, message.repeated_double[0])
|
477
|
+
test_case.assertEqual(True, message.repeated_bool[0])
|
478
|
+
test_case.assertEqual('215', message.repeated_string[0])
|
479
|
+
test_case.assertEqual(b'216', message.repeated_bytes[0])
|
480
|
+
|
481
|
+
test_case.assertEqual(217, message.repeatedgroup[0].a)
|
482
|
+
test_case.assertEqual(218, message.repeated_nested_message[0].bb)
|
483
|
+
test_case.assertEqual(219, message.repeated_foreign_message[0].c)
|
484
|
+
test_case.assertEqual(220, message.repeated_import_message[0].d)
|
485
|
+
test_case.assertEqual(227, message.repeated_lazy_message[0].bb)
|
486
|
+
|
487
|
+
test_case.assertEqual(unittest_pb2.TestAllTypes.BAR,
|
488
|
+
message.repeated_nested_enum[0])
|
489
|
+
test_case.assertEqual(unittest_pb2.FOREIGN_BAR,
|
490
|
+
message.repeated_foreign_enum[0])
|
491
|
+
test_case.assertEqual(unittest_import_pb2.IMPORT_BAR,
|
492
|
+
message.repeated_import_enum[0])
|
493
|
+
|
494
|
+
test_case.assertEqual(301, message.repeated_int32[1])
|
495
|
+
test_case.assertEqual(302, message.repeated_int64[1])
|
496
|
+
test_case.assertEqual(303, message.repeated_uint32[1])
|
497
|
+
test_case.assertEqual(304, message.repeated_uint64[1])
|
498
|
+
test_case.assertEqual(305, message.repeated_sint32[1])
|
499
|
+
test_case.assertEqual(306, message.repeated_sint64[1])
|
500
|
+
test_case.assertEqual(307, message.repeated_fixed32[1])
|
501
|
+
test_case.assertEqual(308, message.repeated_fixed64[1])
|
502
|
+
test_case.assertEqual(309, message.repeated_sfixed32[1])
|
503
|
+
test_case.assertEqual(310, message.repeated_sfixed64[1])
|
504
|
+
test_case.assertEqual(311, message.repeated_float[1])
|
505
|
+
test_case.assertEqual(312, message.repeated_double[1])
|
506
|
+
test_case.assertEqual(False, message.repeated_bool[1])
|
507
|
+
test_case.assertEqual('315', message.repeated_string[1])
|
508
|
+
test_case.assertEqual(b'316', message.repeated_bytes[1])
|
509
|
+
|
510
|
+
test_case.assertEqual(317, message.repeatedgroup[1].a)
|
511
|
+
test_case.assertEqual(318, message.repeated_nested_message[1].bb)
|
512
|
+
test_case.assertEqual(319, message.repeated_foreign_message[1].c)
|
513
|
+
test_case.assertEqual(320, message.repeated_import_message[1].d)
|
514
|
+
test_case.assertEqual(327, message.repeated_lazy_message[1].bb)
|
515
|
+
|
516
|
+
test_case.assertEqual(unittest_pb2.TestAllTypes.BAZ,
|
517
|
+
message.repeated_nested_enum[1])
|
518
|
+
test_case.assertEqual(unittest_pb2.FOREIGN_BAZ,
|
519
|
+
message.repeated_foreign_enum[1])
|
520
|
+
test_case.assertEqual(unittest_import_pb2.IMPORT_BAZ,
|
521
|
+
message.repeated_import_enum[1])
|
522
|
+
|
523
|
+
# -----------------------------------------------------------------
|
524
|
+
|
525
|
+
test_case.assertTrue(message.HasField('default_int32'))
|
526
|
+
test_case.assertTrue(message.HasField('default_int64'))
|
527
|
+
test_case.assertTrue(message.HasField('default_uint32'))
|
528
|
+
test_case.assertTrue(message.HasField('default_uint64'))
|
529
|
+
test_case.assertTrue(message.HasField('default_sint32'))
|
530
|
+
test_case.assertTrue(message.HasField('default_sint64'))
|
531
|
+
test_case.assertTrue(message.HasField('default_fixed32'))
|
532
|
+
test_case.assertTrue(message.HasField('default_fixed64'))
|
533
|
+
test_case.assertTrue(message.HasField('default_sfixed32'))
|
534
|
+
test_case.assertTrue(message.HasField('default_sfixed64'))
|
535
|
+
test_case.assertTrue(message.HasField('default_float'))
|
536
|
+
test_case.assertTrue(message.HasField('default_double'))
|
537
|
+
test_case.assertTrue(message.HasField('default_bool'))
|
538
|
+
test_case.assertTrue(message.HasField('default_string'))
|
539
|
+
test_case.assertTrue(message.HasField('default_bytes'))
|
540
|
+
|
541
|
+
test_case.assertTrue(message.HasField('default_nested_enum'))
|
542
|
+
test_case.assertTrue(message.HasField('default_foreign_enum'))
|
543
|
+
test_case.assertTrue(message.HasField('default_import_enum'))
|
544
|
+
|
545
|
+
test_case.assertEqual(401, message.default_int32)
|
546
|
+
test_case.assertEqual(402, message.default_int64)
|
547
|
+
test_case.assertEqual(403, message.default_uint32)
|
548
|
+
test_case.assertEqual(404, message.default_uint64)
|
549
|
+
test_case.assertEqual(405, message.default_sint32)
|
550
|
+
test_case.assertEqual(406, message.default_sint64)
|
551
|
+
test_case.assertEqual(407, message.default_fixed32)
|
552
|
+
test_case.assertEqual(408, message.default_fixed64)
|
553
|
+
test_case.assertEqual(409, message.default_sfixed32)
|
554
|
+
test_case.assertEqual(410, message.default_sfixed64)
|
555
|
+
test_case.assertEqual(411, message.default_float)
|
556
|
+
test_case.assertEqual(412, message.default_double)
|
557
|
+
test_case.assertEqual(False, message.default_bool)
|
558
|
+
test_case.assertEqual('415', message.default_string)
|
559
|
+
test_case.assertEqual(b'416', message.default_bytes)
|
560
|
+
|
561
|
+
test_case.assertEqual(unittest_pb2.TestAllTypes.FOO,
|
562
|
+
message.default_nested_enum)
|
563
|
+
test_case.assertEqual(unittest_pb2.FOREIGN_FOO,
|
564
|
+
message.default_foreign_enum)
|
565
|
+
test_case.assertEqual(unittest_import_pb2.IMPORT_FOO,
|
566
|
+
message.default_import_enum)
|
567
|
+
|
568
|
+
|
569
|
+
def GoldenFile(filename):
|
570
|
+
"""Finds the given golden file and returns a file object representing it."""
|
571
|
+
|
572
|
+
# Search up the directory tree looking for the C++ protobuf source code.
|
573
|
+
path = '.'
|
574
|
+
while os.path.exists(path):
|
575
|
+
if os.path.exists(os.path.join(path, 'src/google/protobuf')):
|
576
|
+
# Found it. Load the golden file from the testdata directory.
|
577
|
+
full_path = os.path.join(path, 'src/google/protobuf/testdata', filename)
|
578
|
+
return open(full_path, 'rb')
|
579
|
+
path = os.path.join(path, '..')
|
580
|
+
|
581
|
+
raise RuntimeError(
|
582
|
+
'Could not find golden files. This test must be run from within the '
|
583
|
+
'protobuf source package so that it can read test data files from the '
|
584
|
+
'C++ source tree.')
|
585
|
+
|
586
|
+
|
587
|
+
def GoldenFileData(filename):
|
588
|
+
"""Finds the given golden file and returns its contents."""
|
589
|
+
with GoldenFile(filename) as f:
|
590
|
+
return f.read()
|
591
|
+
|
592
|
+
|
593
|
+
def SetAllPackedFields(message):
|
594
|
+
"""Sets every field in the message to a unique value.
|
595
|
+
|
596
|
+
Args:
|
597
|
+
message: A unittest_pb2.TestPackedTypes instance.
|
598
|
+
"""
|
599
|
+
message.packed_int32.extend([601, 701])
|
600
|
+
message.packed_int64.extend([602, 702])
|
601
|
+
message.packed_uint32.extend([603, 703])
|
602
|
+
message.packed_uint64.extend([604, 704])
|
603
|
+
message.packed_sint32.extend([605, 705])
|
604
|
+
message.packed_sint64.extend([606, 706])
|
605
|
+
message.packed_fixed32.extend([607, 707])
|
606
|
+
message.packed_fixed64.extend([608, 708])
|
607
|
+
message.packed_sfixed32.extend([609, 709])
|
608
|
+
message.packed_sfixed64.extend([610, 710])
|
609
|
+
message.packed_float.extend([611.0, 711.0])
|
610
|
+
message.packed_double.extend([612.0, 712.0])
|
611
|
+
message.packed_bool.extend([True, False])
|
612
|
+
message.packed_enum.extend([unittest_pb2.FOREIGN_BAR,
|
613
|
+
unittest_pb2.FOREIGN_BAZ])
|
614
|
+
|
615
|
+
|
616
|
+
def SetAllPackedExtensions(message):
|
617
|
+
"""Sets every extension in the message to a unique value.
|
618
|
+
|
619
|
+
Args:
|
620
|
+
message: A unittest_pb2.TestPackedExtensions instance.
|
621
|
+
"""
|
622
|
+
extensions = message.Extensions
|
623
|
+
pb2 = unittest_pb2
|
624
|
+
|
625
|
+
extensions[pb2.packed_int32_extension].extend([601, 701])
|
626
|
+
extensions[pb2.packed_int64_extension].extend([602, 702])
|
627
|
+
extensions[pb2.packed_uint32_extension].extend([603, 703])
|
628
|
+
extensions[pb2.packed_uint64_extension].extend([604, 704])
|
629
|
+
extensions[pb2.packed_sint32_extension].extend([605, 705])
|
630
|
+
extensions[pb2.packed_sint64_extension].extend([606, 706])
|
631
|
+
extensions[pb2.packed_fixed32_extension].extend([607, 707])
|
632
|
+
extensions[pb2.packed_fixed64_extension].extend([608, 708])
|
633
|
+
extensions[pb2.packed_sfixed32_extension].extend([609, 709])
|
634
|
+
extensions[pb2.packed_sfixed64_extension].extend([610, 710])
|
635
|
+
extensions[pb2.packed_float_extension].extend([611.0, 711.0])
|
636
|
+
extensions[pb2.packed_double_extension].extend([612.0, 712.0])
|
637
|
+
extensions[pb2.packed_bool_extension].extend([True, False])
|
638
|
+
extensions[pb2.packed_enum_extension].extend([unittest_pb2.FOREIGN_BAR,
|
639
|
+
unittest_pb2.FOREIGN_BAZ])
|
640
|
+
|
641
|
+
|
642
|
+
def SetAllUnpackedFields(message):
|
643
|
+
"""Sets every field in the message to a unique value.
|
644
|
+
|
645
|
+
Args:
|
646
|
+
message: A unittest_pb2.TestUnpackedTypes instance.
|
647
|
+
"""
|
648
|
+
message.unpacked_int32.extend([601, 701])
|
649
|
+
message.unpacked_int64.extend([602, 702])
|
650
|
+
message.unpacked_uint32.extend([603, 703])
|
651
|
+
message.unpacked_uint64.extend([604, 704])
|
652
|
+
message.unpacked_sint32.extend([605, 705])
|
653
|
+
message.unpacked_sint64.extend([606, 706])
|
654
|
+
message.unpacked_fixed32.extend([607, 707])
|
655
|
+
message.unpacked_fixed64.extend([608, 708])
|
656
|
+
message.unpacked_sfixed32.extend([609, 709])
|
657
|
+
message.unpacked_sfixed64.extend([610, 710])
|
658
|
+
message.unpacked_float.extend([611.0, 711.0])
|
659
|
+
message.unpacked_double.extend([612.0, 712.0])
|
660
|
+
message.unpacked_bool.extend([True, False])
|
661
|
+
message.unpacked_enum.extend([unittest_pb2.FOREIGN_BAR,
|
662
|
+
unittest_pb2.FOREIGN_BAZ])
|