Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc

Issue 2600753002: Reverts third_party/protobuf: Update to HEAD (f52e188fe4) (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc
diff --git a/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc b/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc
index 31574d5be35b3ca6c81fc25ceff30b9ffbddddbe..a8108e4572bc5111648e12e8b9d2fe1cfe4d2fba 100644
--- a/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc
+++ b/third_party/protobuf/src/google/protobuf/io/coded_stream_unittest.cc
@@ -58,7 +58,6 @@
#define ULL(x) GOOGLE_ULONGLONG(x)
namespace google {
-
namespace protobuf {
namespace io {
namespace {
@@ -135,7 +134,7 @@ class CodedStreamTest : public testing::Test {
// for further information.
static void SetupTotalBytesLimitWarningTest(
int total_bytes_limit, int warning_threshold,
- std::vector<string>* out_errors, std::vector<string>* out_warnings);
+ vector<string>* out_errors, vector<string>* out_warnings);
// Buffer used during most of the tests. This assumes tests run sequentially.
static const int kBufferSize = 1024 * 64;
@@ -245,7 +244,7 @@ TEST_F(CodedStreamTest, EmptyInputBeforeEos) {
int count_;
} in;
CodedInputStream input(&in);
- input.ReadTagNoLastTag();
+ input.ReadTag();
EXPECT_TRUE(input.ConsumedEntireMessage());
}
@@ -446,21 +445,6 @@ TEST_2D(CodedStreamTest, ReadVarint32Error, kVarintErrorCases, kBlockSizes) {
EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint32(&value));
}
-TEST_2D(CodedStreamTest, ReadVarint32Error_LeavesValueInInitializedState,
- kVarintErrorCases, kBlockSizes) {
- memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size);
- ArrayInputStream input(buffer_, kVarintErrorCases_case.size,
- kBlockSizes_case);
- CodedInputStream coded_input(&input);
-
- uint32 value = 0;
- EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint32(&value));
- // While the specific value following a failure is not critical, we do want to
- // ensure that it doesn't get set to an uninitialized value. (This check fails
- // in MSAN mode if value has been set to an uninitialized value.)
- EXPECT_EQ(value, value);
-}
-
TEST_2D(CodedStreamTest, ReadVarint64Error, kVarintErrorCases, kBlockSizes) {
memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size);
ArrayInputStream input(buffer_, kVarintErrorCases_case.size,
@@ -471,21 +455,6 @@ TEST_2D(CodedStreamTest, ReadVarint64Error, kVarintErrorCases, kBlockSizes) {
EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint64(&value));
}
-TEST_2D(CodedStreamTest, ReadVarint64Error_LeavesValueInInitializedState,
- kVarintErrorCases, kBlockSizes) {
- memcpy(buffer_, kVarintErrorCases_case.bytes, kVarintErrorCases_case.size);
- ArrayInputStream input(buffer_, kVarintErrorCases_case.size,
- kBlockSizes_case);
- CodedInputStream coded_input(&input);
-
- uint64 value = 0;
- EXPECT_EQ(kVarintErrorCases_case.can_parse, coded_input.ReadVarint64(&value));
- // While the specific value following a failure is not critical, we do want to
- // ensure that it doesn't get set to an uninitialized value. (This check fails
- // in MSAN mode if value has been set to an uninitialized value.)
- EXPECT_EQ(value, value);
-}
-
// -------------------------------------------------------------------
// VarintSize
@@ -525,28 +494,6 @@ TEST_1D(CodedStreamTest, VarintSize64, kVarintSizeCases) {
CodedOutputStream::VarintSize64(kVarintSizeCases_case.value));
}
-TEST_F(CodedStreamTest, VarintSize32PowersOfTwo) {
- int expected = 1;
- for (int i = 1; i < 32; i++) {
- if (i % 7 == 0) {
- expected += 1;
- }
- EXPECT_EQ(expected,
- CodedOutputStream::VarintSize32(static_cast<uint32>(0x1u << i)));
- }
-}
-
-TEST_F(CodedStreamTest, VarintSize64PowersOfTwo) {
- int expected = 1;
- for (int i = 1; i < 64; i++) {
- if (i % 7 == 0) {
- expected += 1;
- }
- EXPECT_EQ(expected, CodedOutputStream::VarintSize64(
- static_cast<uint64>(0x1ull << i)));
- }
-}
-
// -------------------------------------------------------------------
// Fixed-size int tests
@@ -1229,7 +1176,7 @@ TEST_F(CodedStreamTest, TotalBytesLimit) {
EXPECT_TRUE(coded_input.ReadString(&str, 16));
EXPECT_EQ(0, coded_input.BytesUntilTotalBytesLimit());
- std::vector<string> errors;
+ vector<string> errors;
{
ScopedMemoryLog error_log;
@@ -1263,7 +1210,7 @@ TEST_F(CodedStreamTest, TotalBytesLimitNotValidMessageEnd) {
// Read a tag. Should fail, but report being a valid endpoint since it's
// a regular limit.
- EXPECT_EQ(0, coded_input.ReadTagNoLastTag());
+ EXPECT_EQ(0, coded_input.ReadTag());
EXPECT_TRUE(coded_input.ConsumedEntireMessage());
// Pop the limit.
@@ -1271,7 +1218,7 @@ TEST_F(CodedStreamTest, TotalBytesLimitNotValidMessageEnd) {
// Read a tag. Should fail, and report *not* being a valid endpoint, since
// this time we're hitting the total bytes limit.
- EXPECT_EQ(0, coded_input.ReadTagNoLastTag());
+ EXPECT_EQ(0, coded_input.ReadTag());
EXPECT_FALSE(coded_input.ConsumedEntireMessage());
}
@@ -1281,7 +1228,7 @@ TEST_F(CodedStreamTest, TotalBytesLimitNotValidMessageEnd) {
// vectors.
void CodedStreamTest::SetupTotalBytesLimitWarningTest(
int total_bytes_limit, int warning_threshold,
- std::vector<string>* out_errors, std::vector<string>* out_warnings) {
+ vector<string>* out_errors, vector<string>* out_warnings) {
ArrayInputStream raw_input(buffer_, sizeof(buffer_), 128);
ScopedMemoryLog scoped_log;
@@ -1297,21 +1244,25 @@ void CodedStreamTest::SetupTotalBytesLimitWarningTest(
}
TEST_F(CodedStreamTest, TotalBytesLimitWarning) {
- std::vector<string> errors;
- std::vector<string> warnings;
+ vector<string> errors;
+ vector<string> warnings;
SetupTotalBytesLimitWarningTest(10240, 1024, &errors, &warnings);
EXPECT_EQ(0, errors.size());
- EXPECT_EQ(1, warnings.size());
+ ASSERT_EQ(2, warnings.size());
EXPECT_PRED_FORMAT2(testing::IsSubstring,
- "The total number of bytes read was 2048",
+ "Reading dangerously large protocol message. If the message turns out to "
+ "be larger than 10240 bytes, parsing will be halted for security reasons.",
warnings[0]);
+ EXPECT_PRED_FORMAT2(testing::IsSubstring,
+ "The total number of bytes read was 2048",
+ warnings[1]);
}
TEST_F(CodedStreamTest, TotalBytesLimitWarningDisabled) {
- std::vector<string> errors;
- std::vector<string> warnings;
+ vector<string> errors;
+ vector<string> warnings;
// Test with -1
SetupTotalBytesLimitWarningTest(10240, -1, &errors, &warnings);
@@ -1410,7 +1361,7 @@ TEST_F(CodedStreamTest, InputOver2G) {
// input.BackUp() with the correct number of bytes on destruction.
ReallyBigInputStream input;
- std::vector<string> errors;
+ vector<string> errors;
{
ScopedMemoryLog error_log;

Powered by Google App Engine
This is Rietveld 408576698