aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/google/protobuf/util/json_util_test.cc
diff options
context:
space:
mode:
authorGravatar Adam Cozzette <acozzette@google.com>2018-03-13 16:37:29 -0700
committerGravatar Adam Cozzette <acozzette@google.com>2018-03-13 16:37:29 -0700
commit0400cca3236de1ca303af38bf81eab332d042b7c (patch)
treea8a9b19853f64567c96750a1c7d253926471daa5 /src/google/protobuf/util/json_util_test.cc
parent96b535cc2f4f7b7e22a1b8622149f7c26a5a3f63 (diff)
Integrated internal changes from Google
Diffstat (limited to 'src/google/protobuf/util/json_util_test.cc')
-rw-r--r--src/google/protobuf/util/json_util_test.cc28
1 files changed, 12 insertions, 16 deletions
diff --git a/src/google/protobuf/util/json_util_test.cc b/src/google/protobuf/util/json_util_test.cc
index 5b714bb1..8c8380dc 100644
--- a/src/google/protobuf/util/json_util_test.cc
+++ b/src/google/protobuf/util/json_util_test.cc
@@ -34,13 +34,13 @@
#include <string>
#include <google/protobuf/io/zero_copy_stream.h>
+#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <google/protobuf/descriptor_database.h>
#include <google/protobuf/dynamic_message.h>
#include <google/protobuf/util/internal/testdata/maps.pb.h>
#include <google/protobuf/util/json_format_proto3.pb.h>
#include <google/protobuf/util/type_resolver.h>
#include <google/protobuf/util/type_resolver_util.h>
-#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <gtest/gtest.h>
namespace google {
@@ -48,12 +48,12 @@ namespace protobuf {
namespace util {
namespace {
+using google::protobuf::testing::MapIn;
using proto3::FOO;
using proto3::BAR;
using proto3::TestMessage;
using proto3::TestMap;
using proto3::TestOneof;
-using google::protobuf::testing::MapIn;
static const char kTypeUrlPrefix[] = "type.googleapis.com";
@@ -82,7 +82,7 @@ class JsonUtilTest : public ::testing::Test {
return FromJson(json, message, JsonParseOptions());
}
- google::protobuf::scoped_ptr<TypeResolver> resolver_;
+ std::unique_ptr<TypeResolver> resolver_;
};
TEST_F(JsonUtilTest, TestWhitespaces) {
@@ -313,7 +313,7 @@ TEST_F(JsonUtilTest, TestDynamicMessage) {
DescriptorPool pool(&database);
// A dynamic version of the test proto.
DynamicMessageFactory factory;
- google::protobuf::scoped_ptr<Message> message(factory.GetPrototype(
+ std::unique_ptr<Message> message(factory.GetPrototype(
pool.FindMessageTypeByName("proto3.TestMessage"))->New());
EXPECT_TRUE(FromJson(input, message.get()));
@@ -459,26 +459,22 @@ TEST(ZeroCopyStreamByteSinkTest, TestAllInputOutputPatterns) {
}
TEST_F(JsonUtilTest, TestWrongJsonInput) {
- using namespace google::protobuf;
const char json[] = "{\"unknown_field\":\"some_value\"}";
io::ArrayInputStream input_stream(json, strlen(json));
char proto_buffer[10000];
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());
-
- util::Status result_status = util::JsonToBinaryStream(resolver,
- message_type,
- &input_stream,
- &output_stream);
-
+ "type.googleapis.com", DescriptorPool::generated_pool());
+
+ auto result_status = util::JsonToBinaryStream(
+ resolver, message_type, &input_stream, &output_stream);
+
delete resolver;
EXPECT_FALSE(result_status.ok());
- EXPECT_EQ(result_status.error_code(),
- google::protobuf::util::error::INVALID_ARGUMENT);
+ EXPECT_EQ(result_status.error_code(),
+ util::error::INVALID_ARGUMENT);
}
} // namespace