@@ -897,12 +897,15 @@ TEST(RepeatedPtrFieldTest, SmallOptimization) {
897897 EXPECT_EQ (array->SpaceUsedExcludingSelf (), 0 );
898898 std::string str;
899899 auto usage_before = arena.SpaceUsed ();
900+
901+ using H = internal::GenericTypeHandler<std::string>;
902+
900903 // We use UnsafeArenaAddAllocated just to grow the array without creating
901904 // objects or causing extra cleanup costs in the arena to make the
902905 // measurements simpler.
903906 array->UnsafeArenaAddAllocated (&str);
904907 // No backing array, just the string.
905- EXPECT_EQ (array->SpaceUsedExcludingSelf (), sizeof (str));
908+ EXPECT_EQ (array->SpaceUsedExcludingSelf (), H::SpaceUsedLong (str));
906909 // We have not used any arena space.
907910 EXPECT_EQ (usage_before, arena.SpaceUsed ());
908911 // Verify the string is where we think it is.
@@ -923,9 +926,9 @@ TEST(RepeatedPtrFieldTest, SmallOptimization) {
923926 // Backing array and the strings. sizeof(Rep) = 2 * sizeof(int) for capacity
924927 // and allocated_size. Each element of the Rep contributes sizeof(void*),
925928 // and each string contributes sizeof(str) to arena memory.
926- EXPECT_EQ (
927- array->SpaceUsedExcludingSelf (),
928- 2 * sizeof ( int ) + array-> Capacity () * sizeof ( void *) + 2 * sizeof (str));
929+ EXPECT_EQ (array-> SpaceUsedExcludingSelf (),
930+ 2 * sizeof ( int ) + array->Capacity () * sizeof ( void *) +
931+ H::SpaceUsedLong (str) + H::SpaceUsedLong (str2 ));
929932 // We used some arena space now.
930933 EXPECT_LT (usage_before, arena.SpaceUsed ());
931934 // And the pointer_begin is not in the sso anymore.
0 commit comments