mirror of
https://github.com/protocolbuffers/protobuf
synced 2026-08-26 02:23:14 -04:00
Update the stress test to exercise `proto3_optional` fields.
Closes #15265
COPYBARA_INTEGRATE_REVIEW=https://github.com/protocolbuffers/protobuf/pull/15265 from protocolbuffers:fix_jruby_proto3_optional 4040e13a7b
PiperOrigin-RevId: 596028361
30 lines
767 B
Ruby
Executable file
30 lines
767 B
Ruby
Executable file
#!/usr/bin/ruby
|
|
|
|
require 'google/protobuf'
|
|
require 'stress_pb'
|
|
require 'test/unit'
|
|
|
|
module StressTest
|
|
TestMessage = StressTestProtos::TestMessage
|
|
M = StressTestProtos::M
|
|
|
|
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)
|
|
mnew2 = mnew.dup
|
|
assert_equal m.inspect, mnew.inspect
|
|
assert_equal data, TestMessage.encode(mnew)
|
|
assert_equal m.inspect, mnew2.inspect
|
|
assert_equal data, TestMessage.encode(mnew2)
|
|
end
|
|
end
|
|
end
|
|
end
|