Sha256: 6c7b3b6a5d187f712dbddfd51cff2896ab75b5b15e7e2844e7a3500df6ca9d58

Contents?: true

Size: 907 Bytes

Versions: 235

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 m.inspect, mnew.inspect
        assert TestMessage.encode(mnew) == data
      end
    end
  end
end

Version data entries

235 entries across 235 versions & 2 rubygems

Version Path
rubypitaya-3.12.5 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/google-protobuf-3.21.12-x86_64-linux/tests/stress.rb
rubypitaya-3.12.4 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/google-protobuf-3.21.12-x86_64-linux/tests/stress.rb
rubypitaya-3.12.3 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/google-protobuf-3.21.12-x86_64-linux/tests/stress.rb
rubypitaya-3.12.2 ./lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/google-protobuf-3.21.12-x86_64-linux/tests/stress.rb
google-protobuf-3.21.12-x86_64-linux tests/stress.rb
google-protobuf-3.21.12-x86-mingw32 tests/stress.rb
google-protobuf-3.21.12-x86-linux tests/stress.rb
google-protobuf-3.21.12-x64-mingw32 tests/stress.rb
google-protobuf-3.21.12-x64-mingw-ucrt tests/stress.rb
google-protobuf-3.21.12-java tests/stress.rb
google-protobuf-3.21.12 tests/stress.rb
google-protobuf-3.21.12-x86_64-darwin tests/stress.rb
google-protobuf-3.21.11-x86_64-linux tests/stress.rb
google-protobuf-3.21.11-x86-mingw32 tests/stress.rb
google-protobuf-3.21.11-x86-linux tests/stress.rb
google-protobuf-3.21.11-x64-mingw32 tests/stress.rb
google-protobuf-3.21.11-x64-mingw-ucrt tests/stress.rb
google-protobuf-3.21.11-java tests/stress.rb
google-protobuf-3.21.11 tests/stress.rb
google-protobuf-3.21.11-x86_64-darwin tests/stress.rb