|
|
@ -51,7 +51,6 @@ |
|
|
|
#include "google/protobuf/testing/file.h" |
|
|
|
#include "google/protobuf/testing/file.h" |
|
|
|
#include "google/protobuf/testing/file.h" |
|
|
|
#include "google/protobuf/testing/file.h" |
|
|
|
#include "google/protobuf/any.pb.h" |
|
|
|
#include "google/protobuf/any.pb.h" |
|
|
|
#include "google/protobuf/unittest.pb.h" |
|
|
|
|
|
|
|
#include "google/protobuf/descriptor.pb.h" |
|
|
|
#include "google/protobuf/descriptor.pb.h" |
|
|
|
#include "google/protobuf/testing/googletest.h" |
|
|
|
#include "google/protobuf/testing/googletest.h" |
|
|
|
#include <gtest/gtest.h> |
|
|
|
#include <gtest/gtest.h> |
|
|
@ -69,6 +68,7 @@ |
|
|
|
#include "google/protobuf/io/printer.h" |
|
|
|
#include "google/protobuf/io/printer.h" |
|
|
|
#include "google/protobuf/io/zero_copy_stream.h" |
|
|
|
#include "google/protobuf/io/zero_copy_stream.h" |
|
|
|
#include "google/protobuf/test_util2.h" |
|
|
|
#include "google/protobuf/test_util2.h" |
|
|
|
|
|
|
|
#include "google/protobuf/unittest.pb.h" |
|
|
|
#include "google/protobuf/unittest_custom_options.pb.h" |
|
|
|
#include "google/protobuf/unittest_custom_options.pb.h" |
|
|
|
|
|
|
|
|
|
|
|
// Must be included last.
|
|
|
|
// Must be included last.
|
|
|
@ -2691,7 +2691,7 @@ TEST_P(EncodeDecodeTest, Encode) { |
|
|
|
std::string args; |
|
|
|
std::string args; |
|
|
|
if (GetParam() != DESCRIPTOR_SET_IN) { |
|
|
|
if (GetParam() != DESCRIPTOR_SET_IN) { |
|
|
|
args.append( |
|
|
|
args.append( |
|
|
|
TestUtil::MaybeTranslatePath("net/proto2/internal/unittest.proto")); |
|
|
|
TestUtil::MaybeTranslatePath("third_party/protobuf/unittest.proto")); |
|
|
|
} |
|
|
|
} |
|
|
|
EXPECT_TRUE(Run(args + " --encode=protobuf_unittest.TestAllTypes")); |
|
|
|
EXPECT_TRUE(Run(args + " --encode=protobuf_unittest.TestAllTypes")); |
|
|
|
ExpectStdoutMatchesBinaryFile(TestUtil::GetTestDataPath( |
|
|
|
ExpectStdoutMatchesBinaryFile(TestUtil::GetTestDataPath( |
|
|
@ -2703,7 +2703,7 @@ TEST_P(EncodeDecodeTest, Decode) { |
|
|
|
RedirectStdinFromFile(TestUtil::GetTestDataPath( |
|
|
|
RedirectStdinFromFile(TestUtil::GetTestDataPath( |
|
|
|
"third_party/protobuf/testdata/golden_message_oneof_implemented")); |
|
|
|
"third_party/protobuf/testdata/golden_message_oneof_implemented")); |
|
|
|
EXPECT_TRUE( |
|
|
|
EXPECT_TRUE( |
|
|
|
Run(TestUtil::MaybeTranslatePath("net/proto2/internal/unittest.proto") + |
|
|
|
Run(TestUtil::MaybeTranslatePath("third_party/protobuf/unittest.proto") + |
|
|
|
" --decode=protobuf_unittest.TestAllTypes")); |
|
|
|
" --decode=protobuf_unittest.TestAllTypes")); |
|
|
|
ExpectStdoutMatchesTextFile(TestUtil::GetTestDataPath( |
|
|
|
ExpectStdoutMatchesTextFile(TestUtil::GetTestDataPath( |
|
|
|
"third_party/protobuf/" |
|
|
|
"third_party/protobuf/" |
|
|
@ -2714,7 +2714,7 @@ TEST_P(EncodeDecodeTest, Decode) { |
|
|
|
TEST_P(EncodeDecodeTest, Partial) { |
|
|
|
TEST_P(EncodeDecodeTest, Partial) { |
|
|
|
RedirectStdinFromText(""); |
|
|
|
RedirectStdinFromText(""); |
|
|
|
EXPECT_TRUE( |
|
|
|
EXPECT_TRUE( |
|
|
|
Run(TestUtil::MaybeTranslatePath("net/proto2/internal/unittest.proto") + |
|
|
|
Run(TestUtil::MaybeTranslatePath("third_party/protobuf/unittest.proto") + |
|
|
|
" --encode=protobuf_unittest.TestRequired")); |
|
|
|
" --encode=protobuf_unittest.TestRequired")); |
|
|
|
ExpectStdoutMatchesText(""); |
|
|
|
ExpectStdoutMatchesText(""); |
|
|
|
ExpectStderrMatchesText( |
|
|
|
ExpectStderrMatchesText( |
|
|
@ -2738,7 +2738,7 @@ TEST_P(EncodeDecodeTest, DecodeRaw) { |
|
|
|
|
|
|
|
|
|
|
|
TEST_P(EncodeDecodeTest, UnknownType) { |
|
|
|
TEST_P(EncodeDecodeTest, UnknownType) { |
|
|
|
EXPECT_FALSE( |
|
|
|
EXPECT_FALSE( |
|
|
|
Run(TestUtil::MaybeTranslatePath("net/proto2/internal/unittest.proto") + |
|
|
|
Run(TestUtil::MaybeTranslatePath("third_party/protobuf/unittest.proto") + |
|
|
|
" --encode=NoSuchType")); |
|
|
|
" --encode=NoSuchType")); |
|
|
|
ExpectStdoutMatchesText(""); |
|
|
|
ExpectStdoutMatchesText(""); |
|
|
|
ExpectStderrMatchesText("Type not defined: NoSuchType\n"); |
|
|
|
ExpectStderrMatchesText("Type not defined: NoSuchType\n"); |
|
|
@ -2760,7 +2760,7 @@ TEST_P(EncodeDecodeTest, EncodeDeterministicOutput) { |
|
|
|
std::string args; |
|
|
|
std::string args; |
|
|
|
if (GetParam() != DESCRIPTOR_SET_IN) { |
|
|
|
if (GetParam() != DESCRIPTOR_SET_IN) { |
|
|
|
args.append( |
|
|
|
args.append( |
|
|
|
TestUtil::MaybeTranslatePath("net/proto2/internal/unittest.proto")); |
|
|
|
TestUtil::MaybeTranslatePath("third_party/protobuf/unittest.proto")); |
|
|
|
} |
|
|
|
} |
|
|
|
EXPECT_TRUE(Run( |
|
|
|
EXPECT_TRUE(Run( |
|
|
|
args + " --encode=protobuf_unittest.TestAllTypes --deterministic_output")); |
|
|
|
args + " --encode=protobuf_unittest.TestAllTypes --deterministic_output")); |
|
|
@ -2773,7 +2773,7 @@ TEST_P(EncodeDecodeTest, DecodeDeterministicOutput) { |
|
|
|
RedirectStdinFromFile(TestUtil::GetTestDataPath( |
|
|
|
RedirectStdinFromFile(TestUtil::GetTestDataPath( |
|
|
|
"third_party/protobuf/testdata/golden_message_oneof_implemented")); |
|
|
|
"third_party/protobuf/testdata/golden_message_oneof_implemented")); |
|
|
|
EXPECT_FALSE( |
|
|
|
EXPECT_FALSE( |
|
|
|
Run(TestUtil::MaybeTranslatePath("net/proto2/internal/unittest.proto") + |
|
|
|
Run(TestUtil::MaybeTranslatePath("third_party/protobuf/unittest.proto") + |
|
|
|
" --decode=protobuf_unittest.TestAllTypes --deterministic_output")); |
|
|
|
" --decode=protobuf_unittest.TestAllTypes --deterministic_output")); |
|
|
|
ExpectStderrMatchesText( |
|
|
|
ExpectStderrMatchesText( |
|
|
|
"Can only use --deterministic_output with --encode.\n"); |
|
|
|
"Can only use --deterministic_output with --encode.\n"); |
|
|
|