Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Ruby] Fixed bug in string comparison logic. #8386

Merged
merged 1 commit into from Mar 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion ruby/ext/google/protobuf_c/convert.c
Expand Up @@ -315,7 +315,7 @@ bool Msgval_IsEqual(upb_msgval val1, upb_msgval val2, TypeInfo type_info) {
return memcmp(&val1, &val2, 8) == 0;
case UPB_TYPE_STRING:
case UPB_TYPE_BYTES:
return val1.str_val.size != val2.str_val.size ||
return val1.str_val.size == val2.str_val.size &&
memcmp(val1.str_val.data, val2.str_val.data,
val1.str_val.size) == 0;
case UPB_TYPE_MESSAGE:
Expand Down
12 changes: 12 additions & 0 deletions ruby/tests/common_tests.rb
Expand Up @@ -436,6 +436,18 @@ def test_map_basic
end
end

def test_b_8385
m1 = Google::Protobuf::Map.new(:string, :string)
m2 = Google::Protobuf::Map.new(:string, :string)

assert_equal m1, m2

m1["counter"] = "a"
m2["counter"] = "aa"

assert_not_equal m1, m2
end

def test_map_ctor
m = Google::Protobuf::Map.new(:string, :int32,
{"a" => 1, "b" => 2, "c" => 3})
Expand Down