Protocol Buffers - Google's data interchange format (grpc依赖) https://developers.google.com/protocol-buffers/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
767 B

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