| OLD | NEW |
| 1 #!/usr/bin/env ruby | 1 #!/usr/bin/env ruby |
| 2 # | 2 # |
| 3 # Protocol Buffers - Google's data interchange format | 3 # Protocol Buffers - Google's data interchange format |
| 4 # Copyright 2008 Google Inc. All rights reserved. | 4 # Copyright 2008 Google Inc. All rights reserved. |
| 5 # https://developers.google.com/protocol-buffers/ | 5 # https://developers.google.com/protocol-buffers/ |
| 6 # | 6 # |
| 7 # Redistribution and use in source and binary forms, with or without | 7 # Redistribution and use in source and binary forms, with or without |
| 8 # modification, are permitted provided that the following conditions are | 8 # modification, are permitted provided that the following conditions are |
| 9 # met: | 9 # met: |
| 10 # | 10 # |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | 23 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 24 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 24 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 25 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 25 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 26 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 26 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 27 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 27 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 28 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 28 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 29 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 29 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 30 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 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. | 31 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 32 | 32 |
| 33 require 'conformance' | 33 require 'conformance_pb' |
| 34 require 'google/protobuf/test_messages_proto3_pb' |
| 34 | 35 |
| 35 $test_count = 0 | 36 $test_count = 0 |
| 36 $verbose = false | 37 $verbose = false |
| 37 | 38 |
| 38 def do_test(request) | 39 def do_test(request) |
| 39 test_message = Conformance::TestAllTypes.new | 40 test_message = ProtobufTestMessages::Proto3::TestAllTypes.new |
| 40 response = Conformance::ConformanceResponse.new | 41 response = Conformance::ConformanceResponse.new |
| 41 | 42 |
| 42 begin | 43 begin |
| 43 case request.payload | 44 case request.payload |
| 44 when :protobuf_payload | 45 when :protobuf_payload |
| 45 begin | 46 begin |
| 46 test_message = | 47 test_message = ProtobufTestMessages::Proto3::TestAllTypes.decode( |
| 47 Conformance::TestAllTypes.decode(request.protobuf_payload) | 48 request.protobuf_payload) |
| 48 rescue Google::Protobuf::ParseError => err | 49 rescue Google::Protobuf::ParseError => err |
| 49 response.parse_error = err.message.encode('utf-8') | 50 response.parse_error = err.message.encode('utf-8') |
| 50 return response | 51 return response |
| 51 end | 52 end |
| 52 | 53 |
| 53 when :json_payload | 54 when :json_payload |
| 54 begin | 55 begin |
| 55 test_message = Conformance::TestAllTypes.decode_json(request.json_payloa
d) | 56 test_message = ProtobufTestMessages::Proto3::TestAllTypes.decode_json( |
| 57 request.json_payload) |
| 56 rescue Google::Protobuf::ParseError => err | 58 rescue Google::Protobuf::ParseError => err |
| 57 response.parse_error = err.message.encode('utf-8') | 59 response.parse_error = err.message.encode('utf-8') |
| 58 return response | 60 return response |
| 59 end | 61 end |
| 60 | 62 |
| 61 when nil | 63 when nil |
| 62 fail "Request didn't have payload" | 64 fail "Request didn't have payload" |
| 63 end | 65 end |
| 64 | 66 |
| 65 case request.requested_output_format | 67 case request.requested_output_format |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 true | 115 true |
| 114 end | 116 end |
| 115 | 117 |
| 116 loop do | 118 loop do |
| 117 unless do_test_io | 119 unless do_test_io |
| 118 STDERR.puts('conformance_ruby: received EOF from test runner ' \ | 120 STDERR.puts('conformance_ruby: received EOF from test runner ' \ |
| 119 "after #{$test_count} tests, exiting") | 121 "after #{$test_count} tests, exiting") |
| 120 break | 122 break |
| 121 end | 123 end |
| 122 end | 124 end |
| OLD | NEW |