diff options
author | Yilun Chong <chongyilun250@sina.com> | 2017-07-24 14:50:52 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-24 14:50:52 -0700 |
commit | a713b73076f1d90bdc39ea8805b50421a59d7986 (patch) | |
tree | cea38fdfe5c1d93b6291e96332961b2c3bf5439f /conformance/conformance_ruby.rb | |
parent | f15185d370a5789c65105f77ba806c9faa563325 (diff) | |
parent | bceb830c396e3370d4cc15e0d4f96ed1819dcca9 (diff) |
Merge pull request #3281 from BSBandme/ConformanceTestYilunChong
Proto2 test message support to conformance test
Diffstat (limited to 'conformance/conformance_ruby.rb')
-rwxr-xr-x | conformance/conformance_ruby.rb | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/conformance/conformance_ruby.rb b/conformance/conformance_ruby.rb index b7b7cf1c..df63bf7c 100755 --- a/conformance/conformance_ruby.rb +++ b/conformance/conformance_ruby.rb @@ -37,23 +37,30 @@ $test_count = 0 $verbose = false def do_test(request) - test_message = ProtobufTestMessages::Proto3::TestAllTypes.new + test_message = ProtobufTestMessages::Proto3::TestAllTypesProto3.new response = Conformance::ConformanceResponse.new begin case request.payload when :protobuf_payload - begin - test_message = ProtobufTestMessages::Proto3::TestAllTypes.decode( - request.protobuf_payload) - rescue Google::Protobuf::ParseError => err - response.parse_error = err.message.encode('utf-8') + if request.message_type.eql?('protobuf_test_messages.proto3.TestAllTypesProto3') + begin + test_message = ProtobufTestMessages::Proto3::TestAllTypesProto3.decode( + request.protobuf_payload) + rescue Google::Protobuf::ParseError => err + response.parse_error = err.message.encode('utf-8') + return response + end + elsif request.message_type.eql?('protobuf_test_messages.proto2.TestAllTypesProto2') + response.skipped = "Ruby doesn't support proto2" return response + else + fail "Protobuf request doesn't have specific payload type" end when :json_payload begin - test_message = ProtobufTestMessages::Proto3::TestAllTypes.decode_json( + test_message = ProtobufTestMessages::Proto3::TestAllTypesProto3.decode_json( request.json_payload) rescue Google::Protobuf::ParseError => err response.parse_error = err.message.encode('utf-8') |