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
17347e3d
Commit
17347e3d
authored
Dec 30, 2015
by
Feng Xiao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for Visual Studio 2008.
parent
283c40c8
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
35 deletions
+27
-35
js_generator.cc
src/google/protobuf/compiler/js/js_generator.cc
+7
-7
stringpiece_unittest.cc
src/google/protobuf/stubs/stringpiece_unittest.cc
+0
-17
protostream_objectwriter_test.cc
...e/protobuf/util/internal/protostream_objectwriter_test.cc
+6
-2
message_differencer_unittest.cc
src/google/protobuf/util/message_differencer_unittest.cc
+14
-9
No files found.
src/google/protobuf/compiler/js/js_generator.cc
View file @
17347e3d
...
...
@@ -447,7 +447,7 @@ string JSOneofIndex(const OneofDescriptor* oneof) {
// Decodes a codepoint in \x0000 -- \xFFFF. Since JS strings are UTF-16, we only
// need to handle the BMP (16-bit range) here.
uint16
_t
DecodeUTF8Codepoint
(
uint8_t
*
bytes
,
size_t
*
length
)
{
uint16
DecodeUTF8Codepoint
(
uint8
*
bytes
,
size_t
*
length
)
{
if
(
*
length
==
0
)
{
return
0
;
}
...
...
@@ -491,14 +491,14 @@ string EscapeJSString(const string& in, bool is_utf8) {
string
result
;
size_t
decoded
=
0
;
for
(
size_t
i
=
0
;
i
<
in
.
size
();
i
+=
decoded
)
{
uint16
_t
codepoint
=
0
;
uint16
codepoint
=
0
;
if
(
is_utf8
)
{
// Decode the next UTF-8 codepoint.
size_t
have_bytes
=
in
.
size
()
-
i
;
uint8
_t
bytes
[
3
]
=
{
static_cast
<
uint8
_t
>
(
in
[
i
]),
static_cast
<
uint8
_t
>
(((
i
+
1
)
<
in
.
size
())
?
in
[
i
+
1
]
:
0
),
static_cast
<
uint8
_t
>
(((
i
+
2
)
<
in
.
size
())
?
in
[
i
+
2
]
:
0
),
uint8
bytes
[
3
]
=
{
static_cast
<
uint8
>
(
in
[
i
]),
static_cast
<
uint8
>
(((
i
+
1
)
<
in
.
size
())
?
in
[
i
+
1
]
:
0
),
static_cast
<
uint8
>
(((
i
+
2
)
<
in
.
size
())
?
in
[
i
+
2
]
:
0
),
};
codepoint
=
DecodeUTF8Codepoint
(
bytes
,
&
have_bytes
);
if
(
have_bytes
==
0
)
{
...
...
@@ -506,7 +506,7 @@ string EscapeJSString(const string& in, bool is_utf8) {
}
decoded
=
have_bytes
;
}
else
{
codepoint
=
static_cast
<
uint16
_t
>
(
static_cast
<
uint8_t
>
(
in
[
i
]));
codepoint
=
static_cast
<
uint16
>
(
static_cast
<
uint8
>
(
in
[
i
]));
decoded
=
1
;
}
...
...
src/google/protobuf/stubs/stringpiece_unittest.cc
View file @
17347e3d
...
...
@@ -746,23 +746,6 @@ TEST(StringPiece, Comparisons2) {
EXPECT_TRUE
(
abc
.
ends_with
(
"nopqrstuvwxyz"
));
}
TEST
(
StringPiece
,
HashFunction
)
{
hash_set
<
StringPiece
>
set
;
set
.
insert
(
StringPiece
(
"hello"
));
EXPECT_EQ
(
1
,
set
.
size
());
// Insert a StringPiece of the same value again and should NOT increment
// size of the set.
set
.
insert
(
StringPiece
(
"hello"
));
EXPECT_EQ
(
1
,
set
.
size
());
// Insert a StringPiece with different value and check that size of the set
// has been increment by one.
set
.
insert
(
StringPiece
(
"world"
));
EXPECT_EQ
(
2
,
set
.
size
());
}
TEST
(
ComparisonOpsTest
,
StringCompareNotAmbiguous
)
{
EXPECT_EQ
(
"hello"
,
string
(
"hello"
));
EXPECT_LT
(
"hello"
,
string
(
"world"
));
...
...
src/google/protobuf/util/internal/protostream_objectwriter_test.cc
View file @
17347e3d
...
...
@@ -1685,13 +1685,17 @@ TEST_P(ProtoStreamObjectWriterFieldMaskTest, MapKeyMustBeEscapedCorrectly) {
TEST_P
(
ProtoStreamObjectWriterFieldMaskTest
,
MapKeyCanContainAnyChars
)
{
FieldMaskTest
expected
;
expected
.
mutable_single_mask
()
->
add_paths
(
"path.to.map[
\"
(),[],
\\\"
'!@#$%^&*123_|War孙天涌,./?><
\\\\\"
]"
);
// \xE5\xAD\x99 is the UTF-8 byte sequence for chinese character 孙.
// We cannot embed non-ASCII characters in the code directly because
// some windows compilers will try to interpret them using the system's
// current encoding and end up with invalid UTF-8 byte sequence.
"path.to.map[
\"
(),[],
\\\"
'!@#$%^&*123_|War
\xE5\xAD\x99
,./?><
\\\\\"
]"
);
expected
.
mutable_single_mask
()
->
add_paths
(
"path.to.map[
\"
key2
\"
]"
);
ow_
->
StartObject
(
""
);
ow_
->
RenderString
(
"single_mask"
,
"path.to.map[
\"
(),[],
\\\"
'!@#$%^&*123_|War
孙天涌
,./?><
\\\\\"
],"
"path.to.map[
\"
(),[],
\\\"
'!@#$%^&*123_|War
\xE5\xAD\x99
,./?><
\\\\\"
],"
"path.to.map[
\"
key2
\"
]"
);
ow_
->
EndObject
();
...
...
src/google/protobuf/util/message_differencer_unittest.cc
View file @
17347e3d
...
...
@@ -2816,15 +2816,20 @@ class MatchingTest : public testing::Test {
const
Message
&
msg1
,
const
Message
&
msg2
,
bool
result
)
{
string
output
;
io
::
StringOutputStream
output_stream
(
&
output
);
MessageDifferencer
::
StreamReporter
reporter
(
&
output_stream
);
reporter
.
set_report_modified_aggregates
(
true
);
differencer
->
set_report_matches
(
true
);
differencer
->
ReportDifferencesTo
(
&
reporter
);
if
(
result
)
{
EXPECT_TRUE
(
differencer
->
Compare
(
msg1
,
msg2
));
}
else
{
EXPECT_FALSE
(
differencer
->
Compare
(
msg1
,
msg2
));
{
// Before we return the "output" string, we must make sure the
// StreamReporter is destructored because its destructor will
// flush the stream.
io
::
StringOutputStream
output_stream
(
&
output
);
MessageDifferencer
::
StreamReporter
reporter
(
&
output_stream
);
reporter
.
set_report_modified_aggregates
(
true
);
differencer
->
set_report_matches
(
true
);
differencer
->
ReportDifferencesTo
(
&
reporter
);
if
(
result
)
{
EXPECT_TRUE
(
differencer
->
Compare
(
msg1
,
msg2
));
}
else
{
EXPECT_FALSE
(
differencer
->
Compare
(
msg1
,
msg2
));
}
}
return
output
;
}
...
...
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