Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
protobuf
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
protobuf
Commits
bc929a3e
Commit
bc929a3e
authored
Feb 24, 2019
by
Joe Bolinger
Committed by
Paul Yang
Feb 24, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add eql? method (#5730)
parent
4b389fad
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
0 deletions
+22
-0
message.c
ruby/ext/google/protobuf_c/message.c
+1
-0
common_tests.rb
ruby/tests/common_tests.rb
+21
-0
No files found.
ruby/ext/google/protobuf_c/message.c
View file @
bc929a3e
...
...
@@ -622,6 +622,7 @@ VALUE build_class_from_descriptor(Descriptor* desc) {
// Also define #clone so that we don't inherit Object#clone.
rb_define_method
(
klass
,
"clone"
,
Message_dup
,
0
);
rb_define_method
(
klass
,
"=="
,
Message_eq
,
1
);
rb_define_method
(
klass
,
"eql?"
,
Message_eq
,
1
);
rb_define_method
(
klass
,
"hash"
,
Message_hash
,
0
);
rb_define_method
(
klass
,
"to_h"
,
Message_to_h
,
0
);
rb_define_method
(
klass
,
"to_hash"
,
Message_to_h
,
0
);
...
...
ruby/tests/common_tests.rb
View file @
bc929a3e
...
...
@@ -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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment