Commit 2ad74e16 authored by Yilun Chong's avatar Yilun Chong

add support for proto2

parent 4e67590e
......@@ -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.
......
......@@ -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
......
This diff is collapsed.
......@@ -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_;
......
......@@ -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 TestAllTypesProto2 {
message NestedMessage {
optional int32 a = 1;
optional TestAllTypes corecursive = 2;
optional TestAllTypesProto2 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 TestAllTypesProto2 recursive_message = 27;
// Repeated
repeated int32 repeated_int32 = 31;
......@@ -191,6 +191,6 @@ enum ForeignEnum {
FOREIGN_BAZ = 2;
}
extend TestAllTypes {
extend TestAllTypesProto2 {
optional int32 extension_int32 = 120;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment