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
6a618949
Commit
6a618949
authored
Jun 03, 2016
by
Josh Haberman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added test for surrogates (valid and invalid).
parent
84a1b607
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
json_format_test.py
python/google/protobuf/internal/json_format_test.py
+21
-0
No files found.
python/google/protobuf/internal/json_format_test.py
View file @
6a618949
...
...
@@ -247,6 +247,27 @@ class JsonFormatTest(JsonFormatBase):
parsed_message
=
json_format_proto3_pb2
.
TestOneof
()
self
.
CheckParseBack
(
message
,
parsed_message
)
def
testSurrogates
(
self
):
# Test correct surrogate handling.
message
=
json_format_proto3_pb2
.
TestMessage
()
json_format
.
Parse
(
'{"stringValue": "
\\
uD83D
\\
uDE01"}'
,
message
)
self
.
assertEqual
(
message
.
string_value
,
b
'
\xF0\x9F\x98\x81
'
.
decode
(
"utf-8"
,
"strict"
))
# TODO: add test that UTF-8 encoded surrogate code points are rejected.
# UTF-8 does not allow them.
# Error case: unpaired high surrogate.
self
.
CheckError
(
'{"stringValue": "
\\
uD83D"}'
,
r'Invalid \\uXXXX escape|Unpaired surrogate'
)
# Unpaired low surrogate.
self
.
CheckError
(
'{"stringValue": "
\\
uDE01"}'
,
r'Invalid \\uXXXX escape|Unpaired surrogate'
)
def
testTimestampMessage
(
self
):
message
=
json_format_proto3_pb2
.
TestTimestamp
()
message
.
value
.
seconds
=
0
...
...
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