Commit fcb92682 authored by Yilun Chong's avatar Yilun Chong

change java to uniform message, revert TestValidDataForType's parameters

parent 020a24df
This diff is collapsed.
...@@ -674,7 +674,8 @@ void ConformanceTestSuite::TestPrematureEOFForType(FieldDescriptor::Type type) { ...@@ -674,7 +674,8 @@ void ConformanceTestSuite::TestPrematureEOFForType(FieldDescriptor::Type type) {
void ConformanceTestSuite::TestValidDataForType( void ConformanceTestSuite::TestValidDataForType(
FieldDescriptor::Type type, FieldDescriptor::Type type,
std::vector<std::pair<std::string, std::string>> values, bool isProto3) { std::vector<std::pair<std::string, std::string>> values) {
for (int isProto3 = 0; isProto3 < 2; isProto3++) {
const string type_name = const string type_name =
UpperCase(string(".") + FieldDescriptor::TypeName(type)); UpperCase(string(".") + FieldDescriptor::TypeName(type));
WireFormatLite::WireType wire_type = WireFormatLite::WireTypeForFieldType( WireFormatLite::WireType wire_type = WireFormatLite::WireTypeForFieldType(
...@@ -703,6 +704,7 @@ void ConformanceTestSuite::TestValidDataForType( ...@@ -703,6 +704,7 @@ void ConformanceTestSuite::TestValidDataForType(
} }
RunValidProtobufTest("ValidDataRepeated" + type_name, REQUIRED, RunValidProtobufTest("ValidDataRepeated" + type_name, REQUIRED,
proto, text, isProto3); proto, text, isProto3);
}
} }
void ConformanceTestSuite::SetFailureList(const string& filename, void ConformanceTestSuite::SetFailureList(const string& filename,
...@@ -793,29 +795,23 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, ...@@ -793,29 +795,23 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
{dbl(0.1), "0.1"}, {dbl(0.1), "0.1"},
{dbl(1.7976931348623157e+308), "1.7976931348623157e+308"}, {dbl(1.7976931348623157e+308), "1.7976931348623157e+308"},
{dbl(2.22507385850720138309e-308), "2.22507385850720138309e-308"} {dbl(2.22507385850720138309e-308), "2.22507385850720138309e-308"}
}, true); });
TestValidDataForType(FieldDescriptor::TYPE_DOUBLE, {
{dbl(0.1), "0.1"},
{dbl(1.7976931348623157e+308), "1.7976931348623157e+308"},
{dbl(2.22507385850720138309e-308), "2.22507385850720138309e-308"}
}, false);
TestValidDataForType(FieldDescriptor::TYPE_FLOAT, { TestValidDataForType(FieldDescriptor::TYPE_FLOAT, {
{flt(0.1), "0.1"}, {flt(0.1), "0.1"},
{flt(1.00000075e-36), "1.00000075e-36"}, {flt(1.00000075e-36), "1.00000075e-36"},
{flt(3.402823e+38), "3.402823e+38"}, // 3.40282347e+38 {flt(3.402823e+38), "3.402823e+38"}, // 3.40282347e+38
{flt(1.17549435e-38f), "1.17549435e-38"} {flt(1.17549435e-38f), "1.17549435e-38"}
}, true); });
TestValidDataForType(FieldDescriptor::TYPE_INT64, { TestValidDataForType(FieldDescriptor::TYPE_INT64, {
{varint(12345), "12345"}, {varint(12345), "12345"},
{varint(kInt64Max), std::to_string(kInt64Max)}, {varint(kInt64Max), std::to_string(kInt64Max)},
{varint(kInt64Min), std::to_string(kInt64Min)} {varint(kInt64Min), std::to_string(kInt64Min)}
}, true); });
TestValidDataForType(FieldDescriptor::TYPE_UINT64, { TestValidDataForType(FieldDescriptor::TYPE_UINT64, {
{varint(12345), "12345"}, {varint(12345), "12345"},
{varint(kUint64Max), std::to_string(kUint64Max)}, {varint(kUint64Max), std::to_string(kUint64Max)},
{varint(0), "0"} {varint(0), "0"}
}, true); });
TestValidDataForType(FieldDescriptor::TYPE_INT32, { TestValidDataForType(FieldDescriptor::TYPE_INT32, {
{varint(12345), "12345"}, {varint(12345), "12345"},
{longvarint(12345, 2), "12345"}, {longvarint(12345, 2), "12345"},
...@@ -825,7 +821,7 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, ...@@ -825,7 +821,7 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
{varint(1LL << 33), std::to_string(static_cast<int32>(1LL << 33))}, {varint(1LL << 33), std::to_string(static_cast<int32>(1LL << 33))},
{varint((1LL << 33) - 1), {varint((1LL << 33) - 1),
std::to_string(static_cast<int32>((1LL << 33) - 1))}, std::to_string(static_cast<int32>((1LL << 33) - 1))},
}, true); });
TestValidDataForType(FieldDescriptor::TYPE_UINT32, { TestValidDataForType(FieldDescriptor::TYPE_UINT32, {
{varint(12345), "12345"}, {varint(12345), "12345"},
{longvarint(12345, 2), "12345"}, {longvarint(12345, 2), "12345"},
...@@ -835,42 +831,42 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner, ...@@ -835,42 +831,42 @@ bool ConformanceTestSuite::RunSuite(ConformanceTestRunner* runner,
{varint(1LL << 33), std::to_string(static_cast<uint32>(1LL << 33))}, {varint(1LL << 33), std::to_string(static_cast<uint32>(1LL << 33))},
{varint((1LL << 33) - 1), {varint((1LL << 33) - 1),
std::to_string(static_cast<uint32>((1LL << 33) - 1))}, std::to_string(static_cast<uint32>((1LL << 33) - 1))},
}, true); });
TestValidDataForType(FieldDescriptor::TYPE_FIXED64, { TestValidDataForType(FieldDescriptor::TYPE_FIXED64, {
{u64(12345), "12345"}, {u64(12345), "12345"},
{u64(kUint64Max), std::to_string(kUint64Max)}, {u64(kUint64Max), std::to_string(kUint64Max)},
{u64(0), "0"} {u64(0), "0"}
}, true); });
TestValidDataForType(FieldDescriptor::TYPE_FIXED32, { TestValidDataForType(FieldDescriptor::TYPE_FIXED32, {
{u32(12345), "12345"}, {u32(12345), "12345"},
{u32(kUint32Max), std::to_string(kUint32Max)}, // UINT32_MAX {u32(kUint32Max), std::to_string(kUint32Max)}, // UINT32_MAX
{u32(0), "0"} {u32(0), "0"}
}, true); });
TestValidDataForType(FieldDescriptor::TYPE_SFIXED64, { TestValidDataForType(FieldDescriptor::TYPE_SFIXED64, {
{u64(12345), "12345"}, {u64(12345), "12345"},
{u64(kInt64Max), std::to_string(kInt64Max)}, {u64(kInt64Max), std::to_string(kInt64Max)},
{u64(kInt64Min), std::to_string(kInt64Min)} {u64(kInt64Min), std::to_string(kInt64Min)}
}, true); });
TestValidDataForType(FieldDescriptor::TYPE_SFIXED32, { TestValidDataForType(FieldDescriptor::TYPE_SFIXED32, {
{u32(12345), "12345"}, {u32(12345), "12345"},
{u32(kInt32Max), std::to_string(kInt32Max)}, {u32(kInt32Max), std::to_string(kInt32Max)},
{u32(kInt32Min), std::to_string(kInt32Min)} {u32(kInt32Min), std::to_string(kInt32Min)}
}, true); });
TestValidDataForType(FieldDescriptor::TYPE_BOOL, { TestValidDataForType(FieldDescriptor::TYPE_BOOL, {
{varint(1), "true"}, {varint(1), "true"},
{varint(0), "false"}, {varint(0), "false"},
{varint(12345678), "true"} {varint(12345678), "true"}
}, true); });
TestValidDataForType(FieldDescriptor::TYPE_SINT32, { TestValidDataForType(FieldDescriptor::TYPE_SINT32, {
{zz32(12345), "12345"}, {zz32(12345), "12345"},
{zz32(kInt32Max), std::to_string(kInt32Max)}, {zz32(kInt32Max), std::to_string(kInt32Max)},
{zz32(kInt32Min), std::to_string(kInt32Min)} {zz32(kInt32Min), std::to_string(kInt32Min)}
}, true); });
TestValidDataForType(FieldDescriptor::TYPE_SINT64, { TestValidDataForType(FieldDescriptor::TYPE_SINT64, {
{zz64(12345), "12345"}, {zz64(12345), "12345"},
{zz64(kInt64Max), std::to_string(kInt64Max)}, {zz64(kInt64Max), std::to_string(kInt64Max)},
{zz64(kInt64Min), std::to_string(kInt64Min)} {zz64(kInt64Min), std::to_string(kInt64Min)}
}, true); });
// TODO(haberman): // TODO(haberman):
// TestValidDataForType(FieldDescriptor::TYPE_STRING // TestValidDataForType(FieldDescriptor::TYPE_STRING
......
...@@ -210,8 +210,7 @@ class ConformanceTestSuite { ...@@ -210,8 +210,7 @@ class ConformanceTestSuite {
void TestIllegalTags(); void TestIllegalTags();
void TestValidDataForType( void TestValidDataForType(
google::protobuf::FieldDescriptor::Type, 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, bool CheckSetEmpty(const set<string>& set_to_check,
const std::string& write_to_file, const std::string& msg); const std::string& write_to_file, const std::string& msg);
ConformanceTestRunner* runner_; ConformanceTestRunner* runner_;
......
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