Down integrate to GitHub
diff --git a/conformance/binary_json_conformance_suite.cc b/conformance/binary_json_conformance_suite.cc
index 236a0e2..74550b8 100644
--- a/conformance/binary_json_conformance_suite.cc
+++ b/conformance/binary_json_conformance_suite.cc
@@ -157,16 +157,16 @@
FALSE = 2,
};
-const FieldDescriptor* GetFieldForType(
- FieldDescriptor::Type type, bool repeated, bool is_proto3,
- Packed packed = Packed::UNSPECIFIED) {
+const FieldDescriptor* GetFieldForType(FieldDescriptor::Type type,
+ bool repeated, bool is_proto3,
+ Packed packed = Packed::UNSPECIFIED) {
const Descriptor* d = is_proto3 ?
TestAllTypesProto3().GetDescriptor() : TestAllTypesProto2().GetDescriptor();
for (int i = 0; i < d->field_count(); i++) {
const FieldDescriptor* f = d->field(i);
if (f->type() == type && f->is_repeated() == repeated) {
- if (packed == Packed::TRUE && !f->is_packed() ||
- packed == Packed::FALSE && f->is_packed()) {
+ if ((packed == Packed::TRUE && !f->is_packed()) ||
+ (packed == Packed::FALSE && f->is_packed())) {
continue;
}
return f;
@@ -183,10 +183,8 @@
packed_string = "Unpacked ";
}
GOOGLE_LOG(FATAL) << "Couldn't find field with type: "
- << repeated_string.c_str()
- << packed_string.c_str()
- << FieldDescriptor::TypeName(type)
- << " for "
+ << repeated_string.c_str() << packed_string.c_str()
+ << FieldDescriptor::TypeName(type) << " for "
<< proto_string.c_str();
return nullptr;
}
@@ -396,14 +394,13 @@
void BinaryAndJsonConformanceSuite::RunValidBinaryProtobufTest(
const string& test_name, ConformanceLevel level,
const string& input_protobuf, bool is_proto3) {
- RunValidBinaryProtobufTest(
- test_name, level, input_protobuf, input_protobuf, is_proto3);
+ RunValidBinaryProtobufTest(test_name, level, input_protobuf, input_protobuf,
+ is_proto3);
}
void BinaryAndJsonConformanceSuite::RunValidBinaryProtobufTest(
const string& test_name, ConformanceLevel level,
- const string& input_protobuf,
- const string& expected_protobuf,
+ const string& input_protobuf, const string& expected_protobuf,
bool is_proto3) {
std::unique_ptr<Message> prototype = NewTestMessage(is_proto3);
ConformanceRequestSetting setting(
@@ -625,8 +622,7 @@
// Test singular data for singular fields.
for (size_t i = 0; i < values.size(); i++) {
- string proto =
- cat(tag(field->number(), wire_type), values[i].first);
+ string proto = cat(tag(field->number(), wire_type), values[i].first);
string expected_proto =
cat(tag(field->number(), wire_type), values[i].second);
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
@@ -690,18 +686,15 @@
unpacked_proto_expected +=
cat(tag(unpacked_field->number(), wire_type), values[i].second);
}
- default_proto_packed =
- cat(tag(rep_field->number(),
- WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
- delim(default_proto_packed));
- default_proto_packed_expected =
- cat(tag(rep_field->number(),
- WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
- delim(default_proto_packed_expected));
- packed_proto_packed =
- cat(tag(packed_field->number(),
- WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
- delim(packed_proto_packed));
+ default_proto_packed = cat(
+ tag(rep_field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
+ delim(default_proto_packed));
+ default_proto_packed_expected = cat(
+ tag(rep_field->number(), WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
+ delim(default_proto_packed_expected));
+ packed_proto_packed = cat(tag(packed_field->number(),
+ WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
+ delim(packed_proto_packed));
packed_proto_expected =
cat(tag(packed_field->number(),
WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
@@ -711,60 +704,44 @@
WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
delim(unpacked_proto_packed));
-
std::unique_ptr<Message> test_message = NewTestMessage(is_proto3);
test_message->MergeFromString(default_proto_packed_expected);
string text = test_message->DebugString();
// Ensures both packed and unpacked data can be parsed.
RunValidProtobufTest(
- StrCat("ValidDataRepeated", type_name, ".UnpackedInput"),
- REQUIRED, default_proto_unpacked, text, is_proto3);
+ StrCat("ValidDataRepeated", type_name, ".UnpackedInput"), REQUIRED,
+ default_proto_unpacked, text, is_proto3);
RunValidProtobufTest(
- StrCat("ValidDataRepeated", type_name, ".PackedInput"),
- REQUIRED, default_proto_packed, text, is_proto3);
+ StrCat("ValidDataRepeated", type_name, ".PackedInput"), REQUIRED,
+ default_proto_packed, text, is_proto3);
// proto2 should encode as unpacked by default and proto3 should encode as
// packed by default.
- string expected_proto =
- rep_field->is_packed() ? default_proto_packed_expected :
- default_proto_unpacked_expected;
+ string expected_proto = rep_field->is_packed()
+ ? default_proto_packed_expected
+ : default_proto_unpacked_expected;
+ RunValidBinaryProtobufTest(StrCat("ValidDataRepeated", type_name,
+ ".UnpackedInput.DefaultOutput"),
+ RECOMMENDED, default_proto_unpacked,
+ expected_proto, is_proto3);
RunValidBinaryProtobufTest(
- StrCat("ValidDataRepeated", type_name,
- ".UnpackedInput.DefaultOutput"),
- RECOMMENDED,
- default_proto_unpacked,
- expected_proto, is_proto3);
+ StrCat("ValidDataRepeated", type_name, ".PackedInput.DefaultOutput"),
+ RECOMMENDED, default_proto_packed, expected_proto, is_proto3);
RunValidBinaryProtobufTest(
- StrCat("ValidDataRepeated", type_name,
- ".PackedInput.DefaultOutput"),
- RECOMMENDED,
- default_proto_packed,
- expected_proto, is_proto3);
+ StrCat("ValidDataRepeated", type_name, ".UnpackedInput.PackedOutput"),
+ RECOMMENDED, packed_proto_unpacked, packed_proto_expected, is_proto3);
RunValidBinaryProtobufTest(
- StrCat("ValidDataRepeated", type_name,
- ".UnpackedInput.PackedOutput"),
- RECOMMENDED,
- packed_proto_unpacked,
- packed_proto_expected, is_proto3);
+ StrCat("ValidDataRepeated", type_name, ".PackedInput.PackedOutput"),
+ RECOMMENDED, packed_proto_packed, packed_proto_expected, is_proto3);
+ RunValidBinaryProtobufTest(StrCat("ValidDataRepeated", type_name,
+ ".UnpackedInput.UnpackedOutput"),
+ RECOMMENDED, unpacked_proto_unpacked,
+ unpacked_proto_expected, is_proto3);
RunValidBinaryProtobufTest(
- StrCat("ValidDataRepeated", type_name,
- ".PackedInput.PackedOutput"),
- RECOMMENDED,
- packed_proto_packed,
- packed_proto_expected, is_proto3);
- RunValidBinaryProtobufTest(
- StrCat("ValidDataRepeated", type_name,
- ".UnpackedInput.UnpackedOutput"),
- RECOMMENDED,
- unpacked_proto_unpacked,
- unpacked_proto_expected, is_proto3);
- RunValidBinaryProtobufTest(
- StrCat("ValidDataRepeated", type_name,
- ".PackedInput.UnpackedOutput"),
- RECOMMENDED,
- unpacked_proto_packed,
- unpacked_proto_expected, is_proto3);
+ StrCat("ValidDataRepeated", type_name, ".PackedInput.UnpackedOutput"),
+ RECOMMENDED, unpacked_proto_packed, unpacked_proto_expected,
+ is_proto3);
} else {
string proto;
string expected_proto;
@@ -777,27 +754,24 @@
test_message->MergeFromString(expected_proto);
string text = test_message->DebugString();
- RunValidProtobufTest(
- StrCat("ValidDataRepeated", type_name),
- REQUIRED, proto, text, is_proto3);
+ RunValidProtobufTest(StrCat("ValidDataRepeated", type_name), REQUIRED,
+ proto, text, is_proto3);
}
}
}
void BinaryAndJsonConformanceSuite::TestValidDataForRepeatedScalarMessage() {
std::vector<std::string> values = {
- delim(cat(tag(2, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
- delim(cat(
- tag(1, WireFormatLite::WIRETYPE_VARINT), varint(1234),
+ delim(cat(
+ tag(2, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
+ delim(cat(tag(1, WireFormatLite::WIRETYPE_VARINT), varint(1234),
tag(2, WireFormatLite::WIRETYPE_VARINT), varint(1234),
- tag(31, WireFormatLite::WIRETYPE_VARINT), varint(1234)
- )))),
- delim(cat(tag(2, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
- delim(cat(
- tag(1, WireFormatLite::WIRETYPE_VARINT), varint(4321),
+ tag(31, WireFormatLite::WIRETYPE_VARINT), varint(1234))))),
+ delim(cat(
+ tag(2, WireFormatLite::WIRETYPE_LENGTH_DELIMITED),
+ delim(cat(tag(1, WireFormatLite::WIRETYPE_VARINT), varint(4321),
tag(3, WireFormatLite::WIRETYPE_VARINT), varint(4321),
- tag(31, WireFormatLite::WIRETYPE_VARINT), varint(4321)
- )))),
+ tag(31, WireFormatLite::WIRETYPE_VARINT), varint(4321))))),
};
const std::string expected =
@@ -820,9 +794,8 @@
values[i]);
}
- RunValidProtobufTest(
- "RepeatedScalarMessageMerge", REQUIRED, proto,
- field->name() + ": " + expected, is_proto3);
+ RunValidProtobufTest("RepeatedScalarMessageMerge", REQUIRED, proto,
+ field->name() + ": " + expected, is_proto3);
}
}
@@ -920,107 +893,106 @@
int32 kInt32Min = -2147483648;
uint32 kUint32Max = 4294967295UL;
- TestValidDataForType(FieldDescriptor::TYPE_DOUBLE, {
- {dbl(0.1), dbl(0.1)},
- {dbl(1.7976931348623157e+308), dbl(1.7976931348623157e+308)},
- {dbl(2.22507385850720138309e-308), dbl(2.22507385850720138309e-308)}
- });
- TestValidDataForType(FieldDescriptor::TYPE_FLOAT, {
- {flt(0.1), flt(0.1)},
- {flt(1.00000075e-36), flt(1.00000075e-36)},
- {flt(3.402823e+38), flt(3.402823e+38)}, // 3.40282347e+38
- {flt(1.17549435e-38f), flt(1.17549435e-38)}
- });
- TestValidDataForType(FieldDescriptor::TYPE_INT64, {
- {varint(12345), varint(12345)},
- {varint(kInt64Max), varint(kInt64Max)},
- {varint(kInt64Min), varint(kInt64Min)}
- });
- TestValidDataForType(FieldDescriptor::TYPE_UINT64, {
- {varint(12345), varint(12345)},
- {varint(kUint64Max), varint(kUint64Max)},
- {varint(0), varint(0)}
- });
- TestValidDataForType(FieldDescriptor::TYPE_INT32, {
- {varint(12345), varint(12345)},
- {longvarint(12345, 2), varint(12345)},
- {longvarint(12345, 7), varint(12345)},
- {varint(kInt32Max), varint(kInt32Max)},
- {varint(kInt32Min), varint(kInt32Min)},
- {varint(1LL << 33), varint(0)},
- {varint((1LL << 33) - 1), varint(-1)},
- });
- TestValidDataForType(FieldDescriptor::TYPE_UINT32, {
- {varint(12345), varint(12345)},
- {longvarint(12345, 2), varint(12345)},
- {longvarint(12345, 7), varint(12345)},
- {varint(kUint32Max), varint(kUint32Max)}, // UINT32_MAX
- {varint(0), varint(0)},
- {varint(1LL << 33), varint(0)},
- {varint((1LL << 33) - 1), varint((1LL << 32) - 1)},
- });
- TestValidDataForType(FieldDescriptor::TYPE_FIXED64, {
- {u64(12345), u64(12345)},
- {u64(kUint64Max), u64(kUint64Max)},
- {u64(0), u64(0)}
- });
- TestValidDataForType(FieldDescriptor::TYPE_FIXED32, {
- {u32(12345), u32(12345)},
- {u32(kUint32Max), u32(kUint32Max)}, // UINT32_MAX
- {u32(0), u32(0)}
- });
- TestValidDataForType(FieldDescriptor::TYPE_SFIXED64, {
- {u64(12345), u64(12345)},
- {u64(kInt64Max), u64(kInt64Max)},
- {u64(kInt64Min), u64(kInt64Min)}
- });
- TestValidDataForType(FieldDescriptor::TYPE_SFIXED32, {
- {u32(12345), u32(12345)},
- {u32(kInt32Max), u32(kInt32Max)},
- {u32(kInt32Min), u32(kInt32Min)}
- });
- TestValidDataForType(FieldDescriptor::TYPE_BOOL, {
- {varint(1), varint(1)},
- {varint(0), varint(0)},
- {varint(12345678), varint(1)}
- });
- TestValidDataForType(FieldDescriptor::TYPE_SINT32, {
- {zz32(12345), zz32(12345)},
- {zz32(kInt32Max), zz32(kInt32Max)},
- {zz32(kInt32Min), zz32(kInt32Min)}
- });
- TestValidDataForType(FieldDescriptor::TYPE_SINT64, {
- {zz64(12345), zz64(12345)},
- {zz64(kInt64Max), zz64(kInt64Max)},
- {zz64(kInt64Min), zz64(kInt64Min)}
- });
- TestValidDataForType(FieldDescriptor::TYPE_STRING, {
- {delim("Hello world!"), delim("Hello world!")},
- {delim("\'\"\?\\\a\b\f\n\r\t\v"),
- delim("\'\"\?\\\a\b\f\n\r\t\v")}, // escape
- {delim("谷歌"), delim("谷歌")}, // Google in Chinese
- {delim("\u8C37\u6B4C"), delim("谷歌")}, // unicode escape
- {delim("\u8c37\u6b4c"), delim("谷歌")}, // lowercase unicode
- {delim("\xF0\x9F\x98\x81"), delim("\xF0\x9F\x98\x81")}, // emoji: 😁
- {delim(""), delim("")},
- });
- TestValidDataForType(FieldDescriptor::TYPE_BYTES, {
- {delim("\x01\x02"), delim("\x01\x02")},
- {delim("\xfb"), delim("\xfb")},
- {delim(""), delim("")},
- });
+ TestValidDataForType(
+ FieldDescriptor::TYPE_DOUBLE,
+ {{dbl(0.1), dbl(0.1)},
+ {dbl(1.7976931348623157e+308), dbl(1.7976931348623157e+308)},
+ {dbl(2.22507385850720138309e-308), dbl(2.22507385850720138309e-308)}});
+ TestValidDataForType(
+ FieldDescriptor::TYPE_FLOAT,
+ {{flt(0.1), flt(0.1)},
+ {flt(1.00000075e-36), flt(1.00000075e-36)},
+ {flt(3.402823e+38), flt(3.402823e+38)}, // 3.40282347e+38
+ {flt(1.17549435e-38f), flt(1.17549435e-38)}});
+ TestValidDataForType(FieldDescriptor::TYPE_INT64,
+ {{varint(12345), varint(12345)},
+ {varint(kInt64Max), varint(kInt64Max)},
+ {varint(kInt64Min), varint(kInt64Min)}});
+ TestValidDataForType(FieldDescriptor::TYPE_UINT64,
+ {{varint(12345), varint(12345)},
+ {varint(kUint64Max), varint(kUint64Max)},
+ {varint(0), varint(0)}});
+ TestValidDataForType(FieldDescriptor::TYPE_INT32,
+ {
+ {varint(12345), varint(12345)},
+ {longvarint(12345, 2), varint(12345)},
+ {longvarint(12345, 7), varint(12345)},
+ {varint(kInt32Max), varint(kInt32Max)},
+ {varint(kInt32Min), varint(kInt32Min)},
+ {varint(1LL << 33), varint(0)},
+ {varint((1LL << 33) - 1), varint(-1)},
+ });
+ TestValidDataForType(
+ FieldDescriptor::TYPE_UINT32,
+ {
+ {varint(12345), varint(12345)},
+ {longvarint(12345, 2), varint(12345)},
+ {longvarint(12345, 7), varint(12345)},
+ {varint(kUint32Max), varint(kUint32Max)}, // UINT32_MAX
+ {varint(0), varint(0)},
+ {varint(1LL << 33), varint(0)},
+ {varint((1LL << 33) - 1), varint((1LL << 32) - 1)},
+ });
+ TestValidDataForType(FieldDescriptor::TYPE_FIXED64,
+ {{u64(12345), u64(12345)},
+ {u64(kUint64Max), u64(kUint64Max)},
+ {u64(0), u64(0)}});
+ TestValidDataForType(FieldDescriptor::TYPE_FIXED32,
+ {{u32(12345), u32(12345)},
+ {u32(kUint32Max), u32(kUint32Max)}, // UINT32_MAX
+ {u32(0), u32(0)}});
+ TestValidDataForType(FieldDescriptor::TYPE_SFIXED64,
+ {{u64(12345), u64(12345)},
+ {u64(kInt64Max), u64(kInt64Max)},
+ {u64(kInt64Min), u64(kInt64Min)}});
+ TestValidDataForType(FieldDescriptor::TYPE_SFIXED32,
+ {{u32(12345), u32(12345)},
+ {u32(kInt32Max), u32(kInt32Max)},
+ {u32(kInt32Min), u32(kInt32Min)}});
+ TestValidDataForType(FieldDescriptor::TYPE_BOOL,
+ {{varint(1), varint(1)},
+ {varint(0), varint(0)},
+ {varint(12345678), varint(1)}});
+ TestValidDataForType(FieldDescriptor::TYPE_SINT32,
+ {{zz32(12345), zz32(12345)},
+ {zz32(kInt32Max), zz32(kInt32Max)},
+ {zz32(kInt32Min), zz32(kInt32Min)}});
+ TestValidDataForType(FieldDescriptor::TYPE_SINT64,
+ {{zz64(12345), zz64(12345)},
+ {zz64(kInt64Max), zz64(kInt64Max)},
+ {zz64(kInt64Min), zz64(kInt64Min)}});
+ TestValidDataForType(
+ FieldDescriptor::TYPE_STRING,
+ {
+ {delim("Hello world!"), delim("Hello world!")},
+ {delim("\'\"\?\\\a\b\f\n\r\t\v"),
+ delim("\'\"\?\\\a\b\f\n\r\t\v")}, // escape
+ {delim("谷歌"), delim("谷歌")}, // Google in Chinese
+ {delim("\u8C37\u6B4C"), delim("谷歌")}, // unicode escape
+ {delim("\u8c37\u6b4c"), delim("谷歌")}, // lowercase unicode
+ {delim("\xF0\x9F\x98\x81"), delim("\xF0\x9F\x98\x81")}, // emoji: 😁
+ {delim(""), delim("")},
+ });
+ TestValidDataForType(FieldDescriptor::TYPE_BYTES,
+ {
+ {delim("\x01\x02"), delim("\x01\x02")},
+ {delim("\xfb"), delim("\xfb")},
+ {delim(""), delim("")},
+ });
TestValidDataForType(FieldDescriptor::TYPE_ENUM, {
- {varint(0), varint(0)},
- {varint(1), varint(1)},
- {varint(2), varint(2)},
- {varint(-1), varint(-1)},
- });
+ {varint(0), varint(0)},
+ {varint(1), varint(1)},
+ {varint(2), varint(2)},
+ {varint(-1), varint(-1)},
+ });
TestValidDataForRepeatedScalarMessage();
- TestValidDataForType(FieldDescriptor::TYPE_MESSAGE, {
- {delim(cat(tag(1, WireFormatLite::WIRETYPE_VARINT), varint(1234))),
- delim(cat(tag(1, WireFormatLite::WIRETYPE_VARINT), varint(1234)))},
- {delim(""), delim("")},
- });
+ TestValidDataForType(
+ FieldDescriptor::TYPE_MESSAGE,
+ {
+ {delim(cat(tag(1, WireFormatLite::WIRETYPE_VARINT), varint(1234))),
+ delim(cat(tag(1, WireFormatLite::WIRETYPE_VARINT), varint(1234)))},
+ {delim(""), delim("")},
+ });
// TODO(haberman):
// TestValidDataForType(FieldDescriptor::TYPE_GROUP
diff --git a/conformance/conformance_cpp.cc b/conformance/conformance_cpp.cc
index 5a1f214..c7f4b2d 100644
--- a/conformance/conformance_cpp.cc
+++ b/conformance/conformance_cpp.cc
@@ -60,32 +60,6 @@
static const char kTypeUrlPrefix[] = "type.googleapis.com";
const char* kFailures[] = {
-#if !GOOGLE_PROTOBUF_ENABLE_EXPERIMENTAL_PARSER
- "Required.Proto2.ProtobufInput."
- "PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE",
- "Required.Proto2.ProtobufInput."
- "PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE",
- "Required.Proto2.ProtobufInput.PrematureEofInPackedField.BOOL",
- "Required.Proto2.ProtobufInput.PrematureEofInPackedField.ENUM",
- "Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT32",
- "Required.Proto2.ProtobufInput.PrematureEofInPackedField.INT64",
- "Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT32",
- "Required.Proto2.ProtobufInput.PrematureEofInPackedField.SINT64",
- "Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT32",
- "Required.Proto2.ProtobufInput.PrematureEofInPackedField.UINT64",
- "Required.Proto3.ProtobufInput."
- "PrematureEofInDelimitedDataForKnownNonRepeatedValue.MESSAGE",
- "Required.Proto3.ProtobufInput."
- "PrematureEofInDelimitedDataForKnownRepeatedValue.MESSAGE",
- "Required.Proto3.ProtobufInput.PrematureEofInPackedField.BOOL",
- "Required.Proto3.ProtobufInput.PrematureEofInPackedField.ENUM",
- "Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT32",
- "Required.Proto3.ProtobufInput.PrematureEofInPackedField.INT64",
- "Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT32",
- "Required.Proto3.ProtobufInput.PrematureEofInPackedField.SINT64",
- "Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT32",
- "Required.Proto3.ProtobufInput.PrematureEofInPackedField.UINT64",
-#endif
};
static string GetTypeUrl(const Descriptor* message) {
diff --git a/conformance/conformance_objc.m b/conformance/conformance_objc.m
index 1d67703..ab751c8 100644
--- a/conformance/conformance_objc.m
+++ b/conformance/conformance_objc.m
@@ -80,8 +80,8 @@
msgClass = [TestAllTypesProto2 class];
} else {
response.runtimeError =
- [NSString stringWithFormat:
- @"Protobuf request had an unknown message_type: %@", request.messageType];
+ [NSString stringWithFormat:@"Protobuf request had an unknown message_type: %@",
+ request.messageType];
break;
}
NSError *error = nil;
diff --git a/conformance/conformance_test.cc b/conformance/conformance_test.cc
index 0ad929a..0743b5e 100644
--- a/conformance/conformance_test.cc
+++ b/conformance/conformance_test.cc
@@ -71,7 +71,7 @@
return oct_string;
}
-}
+} // namespace
namespace google {
namespace protobuf {
@@ -239,21 +239,18 @@
void ConformanceTestSuite::RunValidBinaryInputTest(
const ConformanceRequestSetting& setting,
- const string& equivalent_wire_format,
- bool require_same_wire_format) {
+ const string& equivalent_wire_format, bool require_same_wire_format) {
const ConformanceRequest& request = setting.GetRequest();
ConformanceResponse response;
RunTest(setting.GetTestName(), request, &response);
- VerifyResponse(setting, equivalent_wire_format, response,
- true, require_same_wire_format);
+ VerifyResponse(setting, equivalent_wire_format, response, true,
+ require_same_wire_format);
}
void ConformanceTestSuite::VerifyResponse(
const ConformanceRequestSetting& setting,
- const string& equivalent_wire_format,
- const ConformanceResponse& response,
- bool need_report_success,
- bool require_same_wire_format) {
+ const string& equivalent_wire_format, const ConformanceResponse& response,
+ bool need_report_success, bool require_same_wire_format) {
Message* test_message = setting.GetTestMessage();
const ConformanceRequest& request = setting.GetRequest();
const string& test_name = setting.GetTestName();
@@ -296,8 +293,8 @@
if (require_same_wire_format) {
GOOGLE_DCHECK_EQ(response.result_case(),
- ConformanceResponse::kProtobufPayload);
- const string& protobuf_payload = response.protobuf_payload();
+ ConformanceResponse::kProtobufPayload);
+ const string& protobuf_payload = response.protobuf_payload();
check = equivalent_wire_format == protobuf_payload;
differences = StrCat("Expect: ", ToOctString(equivalent_wire_format),
", but got: ", ToOctString(protobuf_payload));
diff --git a/conformance/conformance_test.h b/conformance/conformance_test.h
index 2f42d83..6a993de 100644
--- a/conformance/conformance_test.h
+++ b/conformance/conformance_test.h
@@ -38,14 +38,15 @@
#ifndef CONFORMANCE_CONFORMANCE_TEST_H
#define CONFORMANCE_CONFORMANCE_TEST_H
-#include <functional>
-#include <string>
-
#include <google/protobuf/descriptor.h>
#include <google/protobuf/stubs/common.h>
#include <google/protobuf/util/type_resolver.h>
#include <google/protobuf/wire_format_lite.h>
+#include <functional>
+#include <string>
+#include <vector>
+
#include "conformance.pb.h"
namespace conformance {
@@ -88,7 +89,13 @@
static int Run(int argc, char *argv[],
const std::vector<ConformanceTestSuite*>& suites);
- ForkPipeRunner(const std::string &executable)
+ ForkPipeRunner(const std::string& executable,
+ const std::vector<string>& executable_args)
+ : child_pid_(-1),
+ executable_(executable),
+ executable_args_(executable_args) {}
+
+ explicit ForkPipeRunner(const std::string& executable)
: child_pid_(-1), executable_(executable) {}
virtual ~ForkPipeRunner() {}
@@ -108,6 +115,7 @@
int read_fd_;
pid_t child_pid_;
std::string executable_;
+ const std::vector<string> executable_args_;
std::string current_test_name_;
};
@@ -257,12 +265,10 @@
const ConformanceRequestSetting& setting,
Message* test_message) = 0;
- void VerifyResponse(
- const ConformanceRequestSetting& setting,
- const string& equivalent_wire_format,
- const conformance::ConformanceResponse& response,
- bool need_report_success,
- bool require_same_wire_format);
+ void VerifyResponse(const ConformanceRequestSetting& setting,
+ const string& equivalent_wire_format,
+ const conformance::ConformanceResponse& response,
+ bool need_report_success, bool require_same_wire_format);
void ReportSuccess(const std::string& test_name);
void ReportFailure(const string& test_name,
diff --git a/conformance/conformance_test_runner.cc b/conformance/conformance_test_runner.cc
index e7aa0a5..c68b2c7 100644
--- a/conformance/conformance_test_runner.cc
+++ b/conformance/conformance_test_runner.cc
@@ -195,7 +195,8 @@
}
bool all_ok = true;
for (ConformanceTestSuite* suite : suites) {
- char *program;
+ string program;
+ std::vector<string> program_args;
string failure_list_filename;
conformance::FailureSet failure_list;
@@ -221,15 +222,15 @@
UsageError();
}
} else {
- if (arg != argc - 1) {
- fprintf(stderr, "Too many arguments.\n");
- UsageError();
+ program += argv[arg];
+ while (arg < argc) {
+ program_args.push_back(argv[arg]);
+ arg++;
}
- program = argv[arg];
}
}
- ForkPipeRunner runner(program);
+ ForkPipeRunner runner(program, program_args);
std::string output;
all_ok = all_ok &&
@@ -295,8 +296,14 @@
memcpy(executable.get(), executable_.c_str(), executable_.size());
executable[executable_.size()] = '\0';
- char *const argv[] = {executable.get(), NULL};
- CHECK_SYSCALL(execv(executable.get(), argv)); // Never returns.
+ std::vector<const char *> argv;
+ argv.push_back(executable.get());
+ for (int i = 0; i < executable_args_.size(); ++i) {
+ argv.push_back(executable_args_[i].c_str());
+ }
+ argv.push_back(nullptr);
+ // Never returns.
+ CHECK_SYSCALL(execv(executable.get(), const_cast<char **>(argv.data())));
}
}