Skip to content

Commit

Permalink
Fixed conformance test regression: empty string wrapper.
Browse files Browse the repository at this point in the history
  • Loading branch information
haberman committed Oct 30, 2019
1 parent aae5c49 commit 5f25400
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 18 additions & 0 deletions ruby/ext/google/protobuf_c/encode_decode.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,14 @@ static bool uint32wrapper_handler(void* closure, const void* hd, uint32_t val) {
return true;
}

static void* startstringwrapper_handler(void* closure, const void* hd,
size_t size_hint) {
VALUE* rbval = closure;
(void)size_hint;
*rbval = get_frozen_string(NULL, 0, false);
return closure;
}

static size_t stringwrapper_handler(void* closure, const void* hd,
const char* ptr, size_t len,
const upb_bufhandle* handle) {
Expand All @@ -634,6 +642,14 @@ static size_t stringwrapper_handler(void* closure, const void* hd,
return len;
}

static void* startbyteswrapper_handler(void* closure, const void* hd,
size_t size_hint) {
VALUE* rbval = closure;
(void)size_hint;
*rbval = get_frozen_string(NULL, 0, true);
return closure;
}

static size_t byteswrapper_handler(void* closure, const void* hd,
const char* ptr, size_t len,
const upb_bufhandle* handle) {
Expand Down Expand Up @@ -760,9 +776,11 @@ static void add_handlers_for_wrapper(const upb_msgdef* msgdef,
upb_handlers_setuint32(h, f, uint32wrapper_handler, NULL);
break;
case UPB_WELLKNOWN_STRINGVALUE:
upb_handlers_setstartstr(h, f, startstringwrapper_handler, NULL);
upb_handlers_setstring(h, f, stringwrapper_handler, NULL);
break;
case UPB_WELLKNOWN_BYTESVALUE:
upb_handlers_setstartstr(h, f, startbyteswrapper_handler, NULL);
upb_handlers_setstring(h, f, byteswrapper_handler, NULL);
break;
case UPB_WELLKNOWN_BOOLVALUE:
Expand Down
1 change: 0 additions & 1 deletion ruby/tests/common_tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1411,7 +1411,6 @@ def test_oneof_wrappers
run_test.call(m)
m.oneof_bytes_as_value = 'fun'
run_test.call(m)
puts m
end

def test_top_level_wrappers
Expand Down

0 comments on commit 5f25400

Please sign in to comment.