diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2017-08-31 11:36:05 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-31 11:36:05 -0700 |
commit | 6699f2cf64c656d96f4d6f93fa9563faf02e94b4 (patch) | |
tree | 5444b3472663e4b2efcd5e224767ffa00c611c91 /ruby/tests/basic.rb | |
parent | b70e0fdf09506fcf53af951d64a3ae47309fa245 (diff) | |
parent | f55c6ec24f8ac51c80d40f06732537a2d2aa3ab1 (diff) | |
download | protobuf-6699f2cf64c656d96f4d6f93fa9563faf02e94b4.tar.gz protobuf-6699f2cf64c656d96f4d6f93fa9563faf02e94b4.tar.bz2 protobuf-6699f2cf64c656d96f4d6f93fa9563faf02e94b4.zip |
Merge pull request #3560 from tenderlove/thread-safe-map
Move parse frame array to the Map object
Diffstat (limited to 'ruby/tests/basic.rb')
-rw-r--r-- | ruby/tests/basic.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ruby/tests/basic.rb b/ruby/tests/basic.rb index 020effb0..94071ca0 100644 --- a/ruby/tests/basic.rb +++ b/ruby/tests/basic.rb @@ -96,8 +96,18 @@ module BasicTest optional :d, :enum, 4, "TestEnum" end end + + add_message "repro.Outer" do + map :items, :int32, :message, 1, "repro.Inner" + end + + add_message "repro.Inner" do + end end + + Outer = pool.lookup("repro.Outer").msgclass + Inner = pool.lookup("repro.Inner").msgclass Foo = pool.lookup("Foo").msgclass Bar = pool.lookup("Bar").msgclass Baz = pool.lookup("Baz").msgclass @@ -675,6 +685,21 @@ module BasicTest m.map_string_int32['aaa'] = 3 end + def test_concurrent_decoding + o = Outer.new + o.items[0] = Inner.new + raw = Outer.encode(o) + + thds = 2.times.map do + Thread.new do + 100000.times do + assert_equal o, Outer.decode(raw) + end + end + end + thds.map(&:join) + end + def test_map_encode_decode m = MapMessage.new( :map_string_int32 => {"a" => 1, "b" => 2}, |