diff options
author | stone4774 <25053818+stone4774@users.noreply.github.com> | 2018-03-22 11:16:34 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-22 11:16:34 +0800 |
commit | c99f5278eb8dad6f42def88ce8b5a3453f6df4a8 (patch) | |
tree | c3cd284ec9d2981f61da266d040935b73275b5c4 /src/google/protobuf/util/json_util_test.cc | |
parent | d053271deebe0efcd41729991b1f3d618b638ad5 (diff) | |
parent | ed4321d1cb33199984118d801956822842771e7e (diff) | |
download | protobuf-c99f5278eb8dad6f42def88ce8b5a3453f6df4a8.tar.gz protobuf-c99f5278eb8dad6f42def88ce8b5a3453f6df4a8.tar.bz2 protobuf-c99f5278eb8dad6f42def88ce8b5a3453f6df4a8.zip |
Merge branch 'master' into fixbug_enum2json2
Diffstat (limited to 'src/google/protobuf/util/json_util_test.cc')
-rw-r--r-- | src/google/protobuf/util/json_util_test.cc | 28 |
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 c3f820a2..ed9092df 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; using proto3::TestEnumValue; static const char kTypeUrlPrefix[] = "type.googleapis.com"; @@ -83,7 +83,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) { @@ -337,7 +337,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())); @@ -541,26 +541,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 |