|
|
|
@ -1514,6 +1514,7 @@ TEST(RepeatedPtrField, ReserveDoesntLoseAllocated) { |
|
|
|
|
// Clearing elements is tricky with RepeatedPtrFields since the memory for
|
|
|
|
|
// the elements is retained and reused.
|
|
|
|
|
TEST(RepeatedPtrField, ClearedElements) { |
|
|
|
|
PROTOBUF_IGNORE_DEPRECATION_START |
|
|
|
|
RepeatedPtrField<std::string> field; |
|
|
|
|
|
|
|
|
|
std::string* original = field.Add(); |
|
|
|
@ -1540,7 +1541,6 @@ TEST(RepeatedPtrField, ClearedElements) { |
|
|
|
|
field.Clear(); |
|
|
|
|
EXPECT_EQ(field.ClearedCount(), 2); |
|
|
|
|
#ifndef PROTOBUF_FUTURE_REMOVE_CLEARED_API |
|
|
|
|
PROTOBUF_IGNORE_DEPRECATION_START |
|
|
|
|
EXPECT_EQ(field.ReleaseCleared(), original); // Take ownership again.
|
|
|
|
|
EXPECT_EQ(field.ClearedCount(), 1); |
|
|
|
|
EXPECT_NE(field.Add(), original); |
|
|
|
@ -1552,8 +1552,8 @@ TEST(RepeatedPtrField, ClearedElements) { |
|
|
|
|
EXPECT_EQ(field.ClearedCount(), 1); |
|
|
|
|
EXPECT_EQ(field.Add(), original); |
|
|
|
|
EXPECT_EQ(field.ClearedCount(), 0); |
|
|
|
|
PROTOBUF_IGNORE_DEPRECATION_STOP |
|
|
|
|
#endif // !PROTOBUF_FUTURE_REMOVE_CLEARED_API
|
|
|
|
|
PROTOBUF_IGNORE_DEPRECATION_STOP |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Test all code paths in AddAllocated().
|
|
|
|
|