diff options
author | Joe Bolinger <jbolinger@google.com> | 2019-02-24 09:53:24 -0800 |
---|---|---|
committer | Paul Yang <TeBoring@users.noreply.github.com> | 2019-02-24 09:53:24 -0800 |
commit | bc929a3e82b7a131f9760af96f1baec5b2e4bc9b (patch) | |
tree | d2312dd1e92828b102175d4ac31e4f90b7b6a478 /ruby/tests | |
parent | 4b389fad575f830fee4a39287ebfd53a6f0862b2 (diff) | |
download | protobuf-bc929a3e82b7a131f9760af96f1baec5b2e4bc9b.tar.gz |
add eql? method (#5730)
Diffstat (limited to 'ruby/tests')
-rw-r--r-- | ruby/tests/common_tests.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/ruby/tests/common_tests.rb b/ruby/tests/common_tests.rb index 6e25b4db5..a9c44f5a3 100644 --- a/ruby/tests/common_tests.rb +++ b/ruby/tests/common_tests.rb @@ -1119,4 +1119,25 @@ module CommonTests def test_comparison_with_arbitrary_object assert proto_module::TestMessage.new != nil end + + def test_eq + m1 = proto_module::TestMessage.new(:optional_string => 'foo', :repeated_string => ['bar1', 'bar2']) + m2 = proto_module::TestMessage.new(:optional_string => 'foo', :repeated_string => ['bar1', 'bar2']) + + h = {} + h[m1] = :yes + + assert m1 == m2 + assert m1.eql?(m2) + assert m1.hash == m2.hash + assert h[m1] == :yes + assert h[m2] == :yes + + m1.optional_int32 = 2 + + assert m1 != m2 + assert !m1.eql?(m2) + assert m1.hash != m2.hash + assert_nil h[m2] + end end |