@@ -458,37 +458,6 @@ TEST(RepeatedPtrField, ReserveDoesntLoseAllocated) {
458458 EXPECT_EQ (first, field.Add ());
459459}
460460
461- // Clearing elements is tricky with RepeatedPtrFields since the memory for
462- // the elements is retained and reused.
463- TEST (RepeatedPtrField, ClearedElements) {
464- PROTOBUF_IGNORE_DEPRECATION_START
465- RepeatedPtrField<std::string> field;
466-
467- std::string* original = field.Add ();
468- *original = " foo" ;
469-
470- EXPECT_EQ (field.ClearedCount (), 0 );
471-
472- field.RemoveLast ();
473- EXPECT_TRUE (original->empty ());
474- EXPECT_EQ (field.ClearedCount (), 1 );
475-
476- EXPECT_EQ (field.Add (),
477- original); // Should return same string for reuse.
478- EXPECT_EQ (field.UnsafeArenaReleaseLast (), original); // We take ownership.
479- EXPECT_EQ (field.ClearedCount (), 0 );
480-
481- EXPECT_NE (field.Add (), original); // Should NOT return the same string.
482- EXPECT_EQ (field.ClearedCount (), 0 );
483-
484- field.UnsafeArenaAddAllocated (original); // Give ownership back.
485- EXPECT_EQ (field.ClearedCount (), 0 );
486- EXPECT_EQ (field.Mutable (1 ), original);
487-
488- field.Clear ();
489- EXPECT_EQ (field.ClearedCount (), 2 );
490- PROTOBUF_IGNORE_DEPRECATION_STOP
491- }
492461
493462// Test all code paths in AddAllocated().
494463TEST (RepeatedPtrField, AddAllocated) {
@@ -512,7 +481,6 @@ TEST(RepeatedPtrField, AddAllocated) {
512481 std::string* foo = new std::string (" foo" );
513482 field.AddAllocated (foo);
514483 EXPECT_EQ (index + 1 , field.size ());
515- EXPECT_EQ (0 , field.ClearedCount ());
516484 EXPECT_EQ (foo, &field.Get (index));
517485
518486 // Last branch: Field is not at capacity and there are no cleared objects.
@@ -521,7 +489,6 @@ TEST(RepeatedPtrField, AddAllocated) {
521489 field.AddAllocated (bar);
522490 ++index;
523491 EXPECT_EQ (index + 1 , field.size ());
524- EXPECT_EQ (0 , field.ClearedCount ());
525492 EXPECT_EQ (bar, &field.Get (index));
526493
527494 // Third branch: Field is not at capacity and there are no cleared objects.
@@ -530,7 +497,6 @@ TEST(RepeatedPtrField, AddAllocated) {
530497 std::string* baz = new std::string (" baz" );
531498 field.AddAllocated (baz);
532499 EXPECT_EQ (index + 1 , field.size ());
533- EXPECT_EQ (1 , field.ClearedCount ());
534500 EXPECT_EQ (baz, &field.Get (index));
535501
536502 // Second branch: Field is at capacity but has some cleared objects.
@@ -541,7 +507,6 @@ TEST(RepeatedPtrField, AddAllocated) {
541507 field.AddAllocated (moo);
542508 EXPECT_EQ (index + 1 , field.size ());
543509 // We should have discarded the cleared object.
544- EXPECT_EQ (0 , field.ClearedCount ());
545510 EXPECT_EQ (moo, &field.Get (index));
546511}
547512
@@ -937,7 +902,6 @@ TEST(RepeatedPtrField, ExtractSubrange) {
937902 EXPECT_EQ (field.size (), sz + extra);
938903 for (int i = 0 ; i < extra; ++i) field.RemoveLast ();
939904 EXPECT_EQ (field.size (), sz);
940- EXPECT_EQ (field.ClearedCount (), extra);
941905
942906 // Create a catcher array and call ExtractSubrange.
943907 std::string* catcher[10 ];
@@ -959,9 +923,7 @@ TEST(RepeatedPtrField, ExtractSubrange) {
959923 EXPECT_EQ (field.Mutable (i), subject[i + num]);
960924
961925 // Reinstate the cleared elements.
962- EXPECT_EQ (field.ClearedCount (), extra);
963926 for (int i = 0 ; i < extra; ++i) field.Add ();
964- EXPECT_EQ (field.ClearedCount (), 0 );
965927 EXPECT_EQ (field.size (), sz - num + extra);
966928
967929 // Make sure the extra elements are all there (in some order).
0 commit comments