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
2ad74e16
Commit
2ad74e16
authored
Jun 27, 2017
by
Yilun Chong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add support for proto2
parent
4e67590e
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
34 additions
and
17 deletions
+34
-17
conformance.proto
conformance/conformance.proto
+2
-0
conformance_ruby.rb
conformance/conformance_ruby.rb
+13
-6
conformance_test.cc
conformance/conformance_test.cc
+0
-0
conformance_test.h
conformance/conformance_test.h
+14
-7
test_messages_proto2.proto
src/google/protobuf/test_messages_proto2.proto
+5
-4
No files found.
conformance/conformance.proto
View file @
2ad74e16
...
...
@@ -77,6 +77,8 @@ message ConformanceRequest {
// Which format should the testee serialize its message to?
WireFormat
requested_output_format
=
3
;
string
message_type
=
4
;
}
// Represents a single test case's output.
...
...
conformance/conformance_ruby.rb
View file @
2ad74e16
...
...
@@ -43,12 +43,19 @@ def do_test(request)
begin
case
request
.
payload
when
:protobuf_payload
begin
test_message
=
ProtobufTestMessages
::
Proto3
::
TestAllTypes
.
decode
(
request
.
protobuf_payload
)
rescue
Google
::
Protobuf
::
ParseError
=>
err
response
.
parse_error
=
err
.
message
.
encode
(
'utf-8'
)
return
response
if
request
.
message_type
.
eql?
(
'proto3'
)
begin
test_message
=
ProtobufTestMessages
::
Proto3
::
TestAllTypes
.
decode
(
request
.
protobuf_payload
)
rescue
Google
::
Protobuf
::
ParseError
=>
err
response
.
parse_error
=
err
.
message
.
encode
(
'utf-8'
)
return
response
end
elsif
request
.
message_type
.
eql?
(
'proto2'
)
response
.
skipped
=
"Ruby doesn't support proto2"
return
respons
else
fail
"Protobuf request doesn't have specific type"
end
when
:json_payload
...
...
conformance/conformance_test.cc
View file @
2ad74e16
This diff is collapsed.
Click to expand it.
conformance/conformance_test.h
View file @
2ad74e16
...
...
@@ -165,7 +165,8 @@ class ConformanceTestSuite {
const
string
&
input
,
conformance
::
WireFormat
input_format
,
const
string
&
equivalent_text_format
,
conformance
::
WireFormat
requested_output
);
conformance
::
WireFormat
requested_output
,
bool
isProto3
);
void
RunValidJsonTest
(
const
string
&
test_name
,
ConformanceLevel
level
,
const
string
&
input_json
,
...
...
@@ -174,14 +175,17 @@ class ConformanceTestSuite {
const
string
&
test_name
,
ConformanceLevel
level
,
const
protobuf_test_messages
::
proto3
::
TestAllTypes
&
input
,
const
string
&
equivalent_text_format
);
const
string
&
equivalent_text_format
,
bool
isProto3
);
void
RunValidProtobufTest
(
const
string
&
test_name
,
ConformanceLevel
level
,
const
string
&
input_protobuf
,
const
string
&
equivalent_text_format
);
const
string
&
equivalent_text_format
,
bool
isProto3
);
void
RunValidProtobufTestWithMessage
(
const
string
&
test_name
,
ConformanceLevel
level
,
const
protobuf_test_messages
::
proto3
::
TestAllTypes
&
input
,
const
string
&
equivalent_text_format
);
const
string
&
equivalent_text_format
,
bool
isProto3
);
typedef
std
::
function
<
bool
(
const
Json
::
Value
&
)
>
Validator
;
void
RunValidJsonTestWithValidator
(
const
string
&
test_name
,
...
...
@@ -196,15 +200,18 @@ class ConformanceTestSuite {
const
string
&
text_format
);
void
ExpectParseFailureForProto
(
const
std
::
string
&
proto
,
const
std
::
string
&
test_name
,
ConformanceLevel
level
);
ConformanceLevel
level
,
bool
isProto3
);
void
ExpectHardParseFailureForProto
(
const
std
::
string
&
proto
,
const
std
::
string
&
test_name
,
ConformanceLevel
level
);
ConformanceLevel
level
,
bool
isProto3
);
void
TestPrematureEOFForType
(
google
::
protobuf
::
FieldDescriptor
::
Type
type
);
void
TestIllegalTags
();
void
TestValidDataForType
(
google
::
protobuf
::
FieldDescriptor
::
Type
,
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
values
);
std
::
vector
<
std
::
pair
<
std
::
string
,
std
::
string
>>
values
,
bool
isProto3
);
bool
CheckSetEmpty
(
const
set
<
string
>&
set_to_check
,
const
std
::
string
&
write_to_file
,
const
std
::
string
&
msg
);
ConformanceTestRunner
*
runner_
;
...
...
src/google/protobuf/test_messages_proto2.proto
View file @
2ad74e16
...
...
@@ -50,10 +50,10 @@ option cc_enable_arenas = true;
// submessages of this message. So for example, a fuzz test of TestAllTypes
// could trigger bugs that occur in any message type in this file. We verify
// this stays true in a unit test.
message
TestAllTypes
{
message
TestAllTypes
Proto2
{
message
NestedMessage
{
optional
int32
a
=
1
;
optional
TestAllTypes
corecursive
=
2
;
optional
TestAllTypes
Proto2
corecursive
=
2
;
}
enum
NestedEnum
{
...
...
@@ -89,7 +89,7 @@ message TestAllTypes {
optional
string
optional_string_piece
=
24
[
ctype
=
STRING_PIECE
];
optional
string
optional_cord
=
25
[
ctype
=
CORD
];
optional
TestAllTypes
recursive_message
=
27
;
optional
TestAllTypes
Proto2
recursive_message
=
27
;
// Repeated
repeated
int32
repeated_int32
=
31
;
...
...
@@ -191,6 +191,6 @@ enum ForeignEnum {
FOREIGN_BAZ
=
2
;
}
extend
TestAllTypes
{
extend
TestAllTypes
Proto2
{
optional
int32
extension_int32
=
120
;
}
\ No newline at end of file
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