Sha256: f88f2bd50dbabfed80d684423afaf4ce66bf1092ed8f7f1571747005d1d2615b

Contents?: true

Size: 907 Bytes

Versions: 489

Compression:

Stored size: 907 Bytes

Contents

#!/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

Version data entries

489 entries across 489 versions & 4 rubygems

Version Path
primary_connect_proto-0.20.0 vendor/bundle/ruby/3.0.0/gems/google-protobuf-4.0.0.rc.1/tests/stress.rb
primary_connect_proto-0.18.0 vendor/bundle/ruby/3.0.0/gems/google-protobuf-4.0.0.rc.1/tests/stress.rb
primary_connect_proto-0.17.0 vendor/bundle/ruby/3.0.0/gems/google-protobuf-4.0.0.rc.1/tests/stress.rb
google-protobuf-3.18.3-x86_64-linux tests/stress.rb
google-protobuf-3.18.3-x86-mingw32 tests/stress.rb
google-protobuf-3.18.3-x86-linux tests/stress.rb
google-protobuf-3.18.3-x64-mingw32 tests/stress.rb
google-protobuf-3.18.3 tests/stress.rb
google-protobuf-3.18.3-universal-darwin tests/stress.rb
primary_connect_proto-0.12.1 vendor/bundle/ruby/2.7.0/gems/google-protobuf-4.0.0.rc.1/tests/stress.rb
primary_connect_proto-0.10.2 vendor/bundle/ruby/2.7.0/gems/google-protobuf-4.0.0.rc.1/tests/stress.rb
primary_connect_proto-0.10.1 vendor/bundle/ruby/2.7.0/gems/google-protobuf-4.0.0.rc.1/tests/stress.rb
primary_connect_proto-0.8.2 vendor/bundle/ruby/2.7.0/gems/google-protobuf-4.0.0.rc.1/tests/stress.rb
primary_connect_proto-0.8.1 vendor/bundle/ruby/2.7.0/gems/google-protobuf-4.0.0.rc.1/tests/stress.rb
google-protobuf-3.18.2-x86_64-linux tests/stress.rb
google-protobuf-3.18.2-x86-mingw32 tests/stress.rb
google-protobuf-3.18.2-x86-linux tests/stress.rb
google-protobuf-3.18.2-x64-mingw32 tests/stress.rb
google-protobuf-3.18.2 tests/stress.rb
google-protobuf-3.18.2-universal-darwin tests/stress.rb