diff options
author | Feng Xiao <xfxyjwf@gmail.com> | 2017-02-23 17:53:06 -0800 |
---|---|---|
committer | Feng Xiao <xfxyjwf@gmail.com> | 2017-02-27 17:38:54 -0800 |
commit | 9118ad659b21e98c5f44fe1b13f89ec1d23756b1 (patch) | |
tree | d13d83d3e2532aa6a7695c097de43a046e046b1f /ruby/compatibility_tests/v3.0.0/tests/stress.rb | |
parent | 963473b1dd4f37c5c0b8ca72f1c4a05225b927b7 (diff) | |
download | protobuf-9118ad659b21e98c5f44fe1b13f89ec1d23756b1.tar.gz protobuf-9118ad659b21e98c5f44fe1b13f89ec1d23756b1.tar.bz2 protobuf-9118ad659b21e98c5f44fe1b13f89ec1d23756b1.zip |
Add Ruby compatibilty test against 3.0.0.
Diffstat (limited to 'ruby/compatibility_tests/v3.0.0/tests/stress.rb')
-rw-r--r-- | ruby/compatibility_tests/v3.0.0/tests/stress.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/ruby/compatibility_tests/v3.0.0/tests/stress.rb b/ruby/compatibility_tests/v3.0.0/tests/stress.rb new file mode 100644 index 00000000..082d5e22 --- /dev/null +++ b/ruby/compatibility_tests/v3.0.0/tests/stress.rb @@ -0,0 +1,38 @@ +#!/usr/bin/ruby + +require 'google/protobuf' +require 'test/unit' + +module StressTest + pool = Google::Protobuf::DescriptorPool.new + pool.build do + add_message "TestMessage" do + optional :a, :int32, 1 + repeated :b, :message, 2, "M" + end + add_message "M" do + optional :foo, :string, 1 + end + end + + TestMessage = pool.lookup("TestMessage").msgclass + M = pool.lookup("M").msgclass + + class StressTest < Test::Unit::TestCase + def get_msg + TestMessage.new(:a => 1000, + :b => [M.new(:foo => "hello"), + M.new(:foo => "world")]) + end + def test_stress + m = get_msg + data = TestMessage.encode(m) + 100_000.times do + mnew = TestMessage.decode(data) + mnew = mnew.dup + assert_equal mnew.inspect, m.inspect + assert TestMessage.encode(mnew) == data + end + end + end +end |