|
|
@ -459,19 +459,26 @@ TEST(ZeroCopyStreamByteSinkTest, TestAllInputOutputPatterns) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
TEST_F(JsonUtilTest, TestWrongJsonInput) { |
|
|
|
TEST_F(JsonUtilTest, TestWrongJsonInput) { |
|
|
|
|
|
|
|
using namespace google::protobuf; |
|
|
|
const char json[] = "{\"unknown_field\":\"some_value\"}"; |
|
|
|
const char json[] = "{\"unknown_field\":\"some_value\"}"; |
|
|
|
google::protobuf::io::ArrayInputStream input_stream(json, strlen(json)); |
|
|
|
io::ArrayInputStream input_stream(json, strlen(json)); |
|
|
|
char proto_buffer[10000]; |
|
|
|
char proto_buffer[10000]; |
|
|
|
google::protobuf::io::ArrayOutputStream output_stream(proto_buffer, sizeof(proto_buffer)); |
|
|
|
io::ArrayOutputStream output_stream(proto_buffer, sizeof(proto_buffer)); |
|
|
|
std::string message_type = "type.googleapis.com/proto3.TestMessage";
|
|
|
|
std::string message_type = "type.googleapis.com/proto3.TestMessage";
|
|
|
|
TypeResolver* resolver = NewTypeResolverForDescriptorPool("type.googleapis.com", DescriptorPool::generated_pool()); |
|
|
|
TypeResolver* resolver = NewTypeResolverForDescriptorPool( |
|
|
|
|
|
|
|
"type.googleapis.com",
|
|
|
|
|
|
|
|
DescriptorPool::generated_pool()); |
|
|
|
|
|
|
|
|
|
|
|
util::Status result_status = util::JsonToBinaryStream(resolver, message_type, &input_stream, &output_stream); |
|
|
|
util::Status result_status = util::JsonToBinaryStream(resolver,
|
|
|
|
|
|
|
|
message_type,
|
|
|
|
|
|
|
|
&input_stream,
|
|
|
|
|
|
|
|
&output_stream); |
|
|
|
|
|
|
|
|
|
|
|
delete resolver; |
|
|
|
delete resolver; |
|
|
|
|
|
|
|
|
|
|
|
EXPECT_FALSE(result_status.ok()); |
|
|
|
EXPECT_FALSE(result_status.ok()); |
|
|
|
EXPECT_EQ(result_status.error_code(), google::protobuf::util::error::INVALID_ARGUMENT); |
|
|
|
EXPECT_EQ(result_status.error_code(),
|
|
|
|
|
|
|
|
google::protobuf::util::error::INVALID_ARGUMENT); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
} // namespace
|
|
|
|