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
781d6963
Commit
781d6963
authored
Oct 31, 2019
by
Joshua Haberman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed the case of multi-line strings in JSON.
parent
5f254002
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
8 deletions
+20
-8
encode_decode.c
ruby/ext/google/protobuf_c/encode_decode.c
+6
-4
common_tests.rb
ruby/tests/common_tests.rb
+14
-4
No files found.
ruby/ext/google/protobuf_c/encode_decode.c
View file @
781d6963
...
...
@@ -630,7 +630,8 @@ 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
);
*
rbval
=
rb_str_new
(
NULL
,
0
);
rb_enc_associate
(
*
rbval
,
kRubyStringUtf8Encoding
);
return
closure
;
}
...
...
@@ -638,7 +639,7 @@ static size_t stringwrapper_handler(void* closure, const void* hd,
const
char
*
ptr
,
size_t
len
,
const
upb_bufhandle
*
handle
)
{
VALUE
*
rbval
=
closure
;
*
rbval
=
get_frozen_string
(
ptr
,
len
,
false
);
*
rbval
=
noleak_rb_str_cat
(
*
rbval
,
ptr
,
len
);
return
len
;
}
...
...
@@ -646,7 +647,8 @@ 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
);
*
rbval
=
rb_str_new
(
NULL
,
0
);
rb_enc_associate
(
*
rbval
,
kRubyString8bitEncoding
);
return
closure
;
}
...
...
@@ -654,7 +656,7 @@ static size_t byteswrapper_handler(void* closure, const void* hd,
const
char
*
ptr
,
size_t
len
,
const
upb_bufhandle
*
handle
)
{
VALUE
*
rbval
=
closure
;
*
rbval
=
get_frozen_string
(
ptr
,
len
,
true
);
*
rbval
=
noleak_rb_str_cat
(
*
rbval
,
ptr
,
len
);
return
len
;
}
...
...
ruby/tests/common_tests.rb
View file @
781d6963
...
...
@@ -1295,9 +1295,9 @@ module CommonTests
assert_equal
true
,
m
.
bool
.
value
assert_equal
true
,
m
.
bool_as_value
assert_equal
'str'
,
m
.
string_as_value
assert_equal
'str'
,
m
.
string
.
value
assert_equal
'str'
,
m
.
string_as_value
assert_equal
"st
\n
r"
,
m
.
string_as_value
assert_equal
"st
\n
r"
,
m
.
string
.
value
assert_equal
"st
\n
r"
,
m
.
string_as_value
assert_equal
'fun'
,
m
.
bytes_as_value
assert_equal
'fun'
,
m
.
bytes
.
value
...
...
@@ -1312,7 +1312,7 @@ module CommonTests
uint32:
Google
::
Protobuf
::
UInt32Value
.
new
(
value:
5
),
uint64:
Google
::
Protobuf
::
UInt64Value
.
new
(
value:
6
),
bool:
Google
::
Protobuf
::
BoolValue
.
new
(
value:
true
),
string:
Google
::
Protobuf
::
StringValue
.
new
(
value:
'str'
),
string:
Google
::
Protobuf
::
StringValue
.
new
(
value:
"st
\n
r"
),
bytes:
Google
::
Protobuf
::
BytesValue
.
new
(
value:
'fun'
),
real_string:
'100'
)
...
...
@@ -1332,6 +1332,10 @@ module CommonTests
# Test that the lazy form compares equal to the expanded form.
m5
=
proto_module
::
Wrapper
::
decode
(
serialized2
)
assert_equal
m5
,
m
serialized_json
=
proto_module
::
Wrapper
::
encode_json
(
m
)
m6
=
proto_module
::
Wrapper
::
decode_json
(
serialized_json
)
assert_equal
m6
,
m
end
def
test_repeated_wrappers
...
...
@@ -1374,6 +1378,12 @@ module CommonTests
# Test that the lazy form compares equal to the expanded form.
m5
=
proto_module
::
Wrapper
::
decode
(
serialized2
)
assert_equal
m5
,
m
# Test JSON.
serialized_json
=
proto_module
::
Wrapper
::
encode_json
(
m5
)
m6
=
proto_module
::
Wrapper
::
decode_json
(
serialized_json
)
run_asserts
.
call
(
m6
)
assert_equal
m6
,
m
end
def
test_oneof_wrappers
...
...
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