diff options
author | Joshua Haberman <jhaberman@gmail.com> | 2015-04-13 15:28:44 -0700 |
---|---|---|
committer | Joshua Haberman <jhaberman@gmail.com> | 2015-04-13 15:28:44 -0700 |
commit | 8fe135d212baeae8b754f08af9cb1854ad0b627f (patch) | |
tree | e95765d1b3d2dbc9ba4572e59c45e544fbdf6301 /ruby/tests/basic.rb | |
parent | be89e626a6d61be50844ba78cfbff857a4c59c3b (diff) | |
parent | 14fd96224c585a365f3859b9c1b1eb87b9ebc230 (diff) | |
download | protobuf-8fe135d212baeae8b754f08af9cb1854ad0b627f.tar.gz protobuf-8fe135d212baeae8b754f08af9cb1854ad0b627f.tar.bz2 protobuf-8fe135d212baeae8b754f08af9cb1854ad0b627f.zip |
Merge pull request #284 from cfallin/issue-283
Fix for issue 283: JSON handler cleanup typo causing segfault.
Diffstat (limited to 'ruby/tests/basic.rb')
-rw-r--r-- | ruby/tests/basic.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/ruby/tests/basic.rb b/ruby/tests/basic.rb index 9d0f0a98..1c3fb62c 100644 --- a/ruby/tests/basic.rb +++ b/ruby/tests/basic.rb @@ -8,6 +8,19 @@ require 'test/unit' module BasicTest pool = Google::Protobuf::DescriptorPool.new pool.build do + add_message "Foo" do + optional :bar, :message, 1, "Bar" + repeated :baz, :message, 2, "Baz" + end + + add_message "Bar" do + optional :msg, :string, 1 + end + + add_message "Baz" do + optional :msg, :string, 1 + end + add_message "TestMessage" do optional :optional_int32, :int32, 1 optional :optional_int64, :int64, 2 @@ -84,6 +97,9 @@ module BasicTest end end + Foo = pool.lookup("Foo").msgclass + Bar = pool.lookup("Bar").msgclass + Baz = pool.lookup("Baz").msgclass TestMessage = pool.lookup("TestMessage").msgclass TestMessage2 = pool.lookup("TestMessage2").msgclass Recursive1 = pool.lookup("Recursive1").msgclass @@ -992,6 +1008,14 @@ module BasicTest json_text = TestMessage.encode_json(m) m2 = TestMessage.decode_json(json_text) assert m == m2 + + # Crash case from GitHub issue 283. + bar = Bar.new(msg: "bar") + baz1 = Baz.new(msg: "baz") + baz2 = Baz.new(msg: "quux") + Foo.encode_json(Foo.new) + Foo.encode_json(Foo.new(bar: bar)) + Foo.encode_json(Foo.new(bar: bar, baz: [baz1, baz2])) end def test_json_maps |