OLD | NEW |
1 // Protocol Buffers - Google's data interchange format | 1 // Protocol Buffers - Google's data interchange format |
2 // Copyright 2008 Google Inc. All rights reserved. | 2 // Copyright 2008 Google Inc. All rights reserved. |
3 // https://developers.google.com/protocol-buffers/ | 3 // https://developers.google.com/protocol-buffers/ |
4 // | 4 // |
5 // Redistribution and use in source and binary forms, with or without | 5 // Redistribution and use in source and binary forms, with or without |
6 // modification, are permitted provided that the following conditions are | 6 // modification, are permitted provided that the following conditions are |
7 // met: | 7 // met: |
8 // | 8 // |
9 // * Redistributions of source code must retain the above copyright | 9 // * Redistributions of source code must retain the above copyright |
10 // notice, this list of conditions and the following disclaimer. | 10 // notice, this list of conditions and the following disclaimer. |
(...skipping 24 matching lines...) Expand all Loading... |
35 #include <memory> | 35 #include <memory> |
36 #ifndef _SHARED_PTR_H | 36 #ifndef _SHARED_PTR_H |
37 #include <google/protobuf/stubs/shared_ptr.h> | 37 #include <google/protobuf/stubs/shared_ptr.h> |
38 #endif | 38 #endif |
39 #include <string> | 39 #include <string> |
40 #include <typeinfo> | 40 #include <typeinfo> |
41 #include <vector> | 41 #include <vector> |
42 | 42 |
43 #include <google/protobuf/stubs/logging.h> | 43 #include <google/protobuf/stubs/logging.h> |
44 #include <google/protobuf/stubs/common.h> | 44 #include <google/protobuf/stubs/common.h> |
| 45 #include <google/protobuf/stubs/scoped_ptr.h> |
45 #include <google/protobuf/arena_test_util.h> | 46 #include <google/protobuf/arena_test_util.h> |
46 #include <google/protobuf/test_util.h> | 47 #include <google/protobuf/test_util.h> |
47 #include <google/protobuf/unittest.pb.h> | 48 #include <google/protobuf/unittest.pb.h> |
48 #include <google/protobuf/unittest_arena.pb.h> | 49 #include <google/protobuf/unittest_arena.pb.h> |
49 #include <google/protobuf/unittest_no_arena.pb.h> | 50 #include <google/protobuf/unittest_no_arena.pb.h> |
50 #include <google/protobuf/io/coded_stream.h> | 51 #include <google/protobuf/io/coded_stream.h> |
51 #include <google/protobuf/io/zero_copy_stream_impl_lite.h> | 52 #include <google/protobuf/io/zero_copy_stream_impl_lite.h> |
52 #include <google/protobuf/descriptor.h> | 53 #include <google/protobuf/descriptor.h> |
53 #include <google/protobuf/extension_set.h> | 54 #include <google/protobuf/extension_set.h> |
54 #include <google/protobuf/message.h> | 55 #include <google/protobuf/message.h> |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 const PleaseDontCopyMe* four_; | 145 const PleaseDontCopyMe* four_; |
145 int five_; | 146 int five_; |
146 const char* const six_; | 147 const char* const six_; |
147 string seven_; | 148 string seven_; |
148 string eight_; | 149 string eight_; |
149 | 150 |
150 private: | 151 private: |
151 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MustBeConstructedWithOneThroughEight); | 152 GOOGLE_DISALLOW_EVIL_CONSTRUCTORS(MustBeConstructedWithOneThroughEight); |
152 }; | 153 }; |
153 | 154 |
| 155 } // namespace |
| 156 |
154 TEST(ArenaTest, ArenaConstructable) { | 157 TEST(ArenaTest, ArenaConstructable) { |
155 EXPECT_TRUE(Arena::is_arena_constructable<TestAllTypes>::type::value); | 158 EXPECT_TRUE(Arena::is_arena_constructable<TestAllTypes>::type::value); |
156 EXPECT_TRUE(Arena::is_arena_constructable<const TestAllTypes>::type::value); | 159 EXPECT_TRUE(Arena::is_arena_constructable<const TestAllTypes>::type::value); |
157 EXPECT_FALSE(Arena::is_arena_constructable<Arena>::type::value); | 160 EXPECT_FALSE(Arena::is_arena_constructable<Arena>::type::value); |
158 } | 161 } |
159 | 162 |
160 TEST(ArenaTest, BasicCreate) { | 163 TEST(ArenaTest, BasicCreate) { |
161 Arena arena; | 164 Arena arena; |
162 EXPECT_TRUE(Arena::Create<int32>(&arena) != NULL); | 165 EXPECT_TRUE(Arena::Create<int32>(&arena) != NULL); |
163 EXPECT_TRUE(Arena::Create<int64>(&arena) != NULL); | 166 EXPECT_TRUE(Arena::Create<int64>(&arena) != NULL); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 TEST(ArenaTest, Parsing) { | 245 TEST(ArenaTest, Parsing) { |
243 TestAllTypes original; | 246 TestAllTypes original; |
244 TestUtil::SetAllFields(&original); | 247 TestUtil::SetAllFields(&original); |
245 | 248 |
246 // Test memory leak. | 249 // Test memory leak. |
247 Arena arena; | 250 Arena arena; |
248 TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena); | 251 TestAllTypes* arena_message = Arena::CreateMessage<TestAllTypes>(&arena); |
249 arena_message->ParseFromString(original.SerializeAsString()); | 252 arena_message->ParseFromString(original.SerializeAsString()); |
250 TestUtil::ExpectAllFieldsSet(*arena_message); | 253 TestUtil::ExpectAllFieldsSet(*arena_message); |
251 | 254 |
252 // Test that string fields have nul terminator bytes (earlier bug). | 255 // Test that string fields have null terminator bytes (earlier bug). |
253 EXPECT_EQ(strlen(original.optional_string().c_str()), | 256 EXPECT_EQ(strlen(original.optional_string().c_str()), |
254 strlen(arena_message->optional_string().c_str())); | 257 strlen(arena_message->optional_string().c_str())); |
255 } | 258 } |
256 | 259 |
257 TEST(ArenaTest, UnknownFields) { | 260 TEST(ArenaTest, UnknownFields) { |
258 TestAllTypes original; | 261 TestAllTypes original; |
259 TestUtil::SetAllFields(&original); | 262 TestUtil::SetAllFields(&original); |
260 | 263 |
261 // Test basic parsing into (populating) and reading out of unknown fields on | 264 // Test basic parsing into (populating) and reading out of unknown fields on |
262 // an arena. | 265 // an arena. |
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
884 | 887 |
885 s = new string("test string"); | 888 s = new string("test string"); |
886 message->unsafe_arena_set_allocated_oneof_string(s); | 889 message->unsafe_arena_set_allocated_oneof_string(s); |
887 EXPECT_TRUE(message->has_oneof_string()); | 890 EXPECT_TRUE(message->has_oneof_string()); |
888 EXPECT_EQ("test string", message->oneof_string()); | 891 EXPECT_EQ("test string", message->oneof_string()); |
889 s = message->unsafe_arena_release_oneof_string(); | 892 s = message->unsafe_arena_release_oneof_string(); |
890 EXPECT_FALSE(message->has_oneof_string()); | 893 EXPECT_FALSE(message->has_oneof_string()); |
891 delete s; | 894 delete s; |
892 } | 895 } |
893 | 896 |
894 TEST(ArenaTest, OneofMerge) { | |
895 Arena arena; | |
896 TestAllTypes* message0 = Arena::CreateMessage<TestAllTypes>(&arena); | |
897 TestAllTypes* message1 = Arena::CreateMessage<TestAllTypes>(&arena); | |
898 | |
899 message0->unsafe_arena_set_allocated_oneof_string(new string("x")); | |
900 ASSERT_TRUE(message0->has_oneof_string()); | |
901 message1->unsafe_arena_set_allocated_oneof_string(new string("y")); | |
902 ASSERT_TRUE(message1->has_oneof_string()); | |
903 EXPECT_EQ("x", message0->oneof_string()); | |
904 EXPECT_EQ("y", message1->oneof_string()); | |
905 message0->MergeFrom(*message1); | |
906 EXPECT_EQ("y", message0->oneof_string()); | |
907 EXPECT_EQ("y", message1->oneof_string()); | |
908 delete message0->unsafe_arena_release_oneof_string(); | |
909 delete message1->unsafe_arena_release_oneof_string(); | |
910 } | |
911 | |
912 TEST(ArenaTest, ArenaOneofReflection) { | 897 TEST(ArenaTest, ArenaOneofReflection) { |
913 Arena arena; | 898 Arena arena; |
914 TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena); | 899 TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena); |
915 const Descriptor* desc = message->GetDescriptor(); | 900 const Descriptor* desc = message->GetDescriptor(); |
916 const Reflection* refl = message->GetReflection(); | 901 const Reflection* refl = message->GetReflection(); |
917 | 902 |
918 const FieldDescriptor* string_field = desc->FindFieldByName( | 903 const FieldDescriptor* string_field = desc->FindFieldByName( |
919 "oneof_string"); | 904 "oneof_string"); |
920 const FieldDescriptor* msg_field = desc->FindFieldByName( | 905 const FieldDescriptor* msg_field = desc->FindFieldByName( |
921 "oneof_nested_message"); | 906 "oneof_nested_message"); |
(...skipping 10 matching lines...) Expand all Loading... |
932 refl->ClearOneof(message, oneof); | 917 refl->ClearOneof(message, oneof); |
933 EXPECT_FALSE(refl->HasOneof(*message, oneof)); | 918 EXPECT_FALSE(refl->HasOneof(*message, oneof)); |
934 refl->MutableMessage(message, msg_field); | 919 refl->MutableMessage(message, msg_field); |
935 EXPECT_TRUE(refl->HasOneof(*message, oneof)); | 920 EXPECT_TRUE(refl->HasOneof(*message, oneof)); |
936 submsg = refl->ReleaseMessage(message, msg_field); | 921 submsg = refl->ReleaseMessage(message, msg_field); |
937 EXPECT_FALSE(refl->HasOneof(*message, oneof)); | 922 EXPECT_FALSE(refl->HasOneof(*message, oneof)); |
938 EXPECT_TRUE(submsg->GetArena() == NULL); | 923 EXPECT_TRUE(submsg->GetArena() == NULL); |
939 delete submsg; | 924 delete submsg; |
940 } | 925 } |
941 | 926 |
| 927 namespace { |
942 void TestSwapRepeatedField(Arena* arena1, Arena* arena2) { | 928 void TestSwapRepeatedField(Arena* arena1, Arena* arena2) { |
943 // Test "safe" (copying) semantics for direct Swap() on RepeatedPtrField | 929 // Test "safe" (copying) semantics for direct Swap() on RepeatedPtrField |
944 // between arenas. | 930 // between arenas. |
945 RepeatedPtrField<TestAllTypes> field1(arena1); | 931 RepeatedPtrField<TestAllTypes> field1(arena1); |
946 RepeatedPtrField<TestAllTypes> field2(arena2); | 932 RepeatedPtrField<TestAllTypes> field2(arena2); |
947 for (int i = 0; i < 10; i++) { | 933 for (int i = 0; i < 10; i++) { |
948 TestAllTypes* t = Arena::CreateMessage<TestAllTypes>(arena1); | 934 TestAllTypes* t = Arena::CreateMessage<TestAllTypes>(arena1); |
949 t->set_optional_string("field1"); | 935 t->set_optional_string("field1"); |
950 t->set_optional_int32(i); | 936 t->set_optional_int32(i); |
951 if (arena1 != NULL) { | 937 if (arena1 != NULL) { |
(...skipping 18 matching lines...) Expand all Loading... |
970 EXPECT_TRUE(string("field1") == field2.Get(0).optional_string()); | 956 EXPECT_TRUE(string("field1") == field2.Get(0).optional_string()); |
971 EXPECT_TRUE(string("field2") == field1.Get(0).optional_string()); | 957 EXPECT_TRUE(string("field2") == field1.Get(0).optional_string()); |
972 // Ensure that fields retained their original order: | 958 // Ensure that fields retained their original order: |
973 for (int i = 0; i < field1.size(); i++) { | 959 for (int i = 0; i < field1.size(); i++) { |
974 EXPECT_EQ(i, field1.Get(i).optional_int32()); | 960 EXPECT_EQ(i, field1.Get(i).optional_int32()); |
975 } | 961 } |
976 for (int i = 0; i < field2.size(); i++) { | 962 for (int i = 0; i < field2.size(); i++) { |
977 EXPECT_EQ(i, field2.Get(i).optional_int32()); | 963 EXPECT_EQ(i, field2.Get(i).optional_int32()); |
978 } | 964 } |
979 } | 965 } |
| 966 } // namespace |
980 | 967 |
981 TEST(ArenaTest, SwapRepeatedField) { | 968 TEST(ArenaTest, SwapRepeatedField) { |
982 Arena arena; | 969 Arena arena; |
983 TestSwapRepeatedField(&arena, &arena); | 970 TestSwapRepeatedField(&arena, &arena); |
984 } | 971 } |
985 | 972 |
986 TEST(ArenaTest, SwapRepeatedFieldWithDifferentArenas) { | 973 TEST(ArenaTest, SwapRepeatedFieldWithDifferentArenas) { |
987 Arena arena1; | 974 Arena arena1; |
988 Arena arena2; | 975 Arena arena2; |
989 TestSwapRepeatedField(&arena1, &arena2); | 976 TestSwapRepeatedField(&arena1, &arena2); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 submessage = static_cast<TestAllTypes::NestedMessage*>( | 1098 submessage = static_cast<TestAllTypes::NestedMessage*>( |
1112 r->MutableMessage(message, oneof_field)); | 1099 r->MutableMessage(message, oneof_field)); |
1113 submessage_expected = message->mutable_oneof_nested_message(); | 1100 submessage_expected = message->mutable_oneof_nested_message(); |
1114 | 1101 |
1115 EXPECT_EQ(submessage_expected, submessage); | 1102 EXPECT_EQ(submessage_expected, submessage); |
1116 EXPECT_EQ(&arena, submessage->GetArena()); | 1103 EXPECT_EQ(&arena, submessage->GetArena()); |
1117 } | 1104 } |
1118 #endif // !GOOGLE_PROTOBUF_NO_RTTI | 1105 #endif // !GOOGLE_PROTOBUF_NO_RTTI |
1119 | 1106 |
1120 | 1107 |
| 1108 namespace { |
| 1109 |
1121 void FillArenaAwareFields(TestAllTypes* message) { | 1110 void FillArenaAwareFields(TestAllTypes* message) { |
1122 string test_string = "hello world"; | 1111 string test_string = "hello world"; |
1123 message->set_optional_int32(42); | 1112 message->set_optional_int32(42); |
1124 message->set_optional_string(test_string); | 1113 message->set_optional_string(test_string); |
1125 message->set_optional_bytes(test_string); | 1114 message->set_optional_bytes(test_string); |
1126 message->mutable_optional_nested_message()->set_bb(42); | 1115 message->mutable_optional_nested_message()->set_bb(42); |
1127 | 1116 |
1128 message->set_oneof_uint32(42); | 1117 message->set_oneof_uint32(42); |
1129 message->mutable_oneof_nested_message()->set_bb(42); | 1118 message->mutable_oneof_nested_message()->set_bb(42); |
1130 message->set_oneof_string(test_string); | 1119 message->set_oneof_string(test_string); |
1131 message->set_oneof_bytes(test_string); | 1120 message->set_oneof_bytes(test_string); |
1132 | 1121 |
1133 message->add_repeated_int32(42); | 1122 message->add_repeated_int32(42); |
1134 // No repeated string: not yet arena-aware. | 1123 // No repeated string: not yet arena-aware. |
1135 message->add_repeated_nested_message()->set_bb(42); | 1124 message->add_repeated_nested_message()->set_bb(42); |
1136 message->mutable_optional_lazy_message()->set_bb(42); | 1125 message->mutable_optional_lazy_message()->set_bb(42); |
1137 } | 1126 } |
1138 | 1127 |
| 1128 } |
| 1129 |
1139 // Test: no allocations occur on heap while touching all supported field types. | 1130 // Test: no allocations occur on heap while touching all supported field types. |
1140 TEST(ArenaTest, NoHeapAllocationsTest) { | 1131 TEST(ArenaTest, NoHeapAllocationsTest) { |
1141 // Allocate a large initial block to avoid mallocs during hooked test. | 1132 // Allocate a large initial block to avoid mallocs during hooked test. |
1142 std::vector<char> arena_block(128 * 1024); | 1133 std::vector<char> arena_block(128 * 1024); |
1143 ArenaOptions options; | 1134 ArenaOptions options; |
1144 options.initial_block = &arena_block[0]; | 1135 options.initial_block = &arena_block[0]; |
1145 options.initial_block_size = arena_block.size(); | 1136 options.initial_block_size = arena_block.size(); |
1146 Arena arena(options); | 1137 Arena arena(options); |
1147 | 1138 |
1148 { | 1139 { |
1149 | 1140 |
1150 TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena); | 1141 TestAllTypes* message = Arena::CreateMessage<TestAllTypes>(&arena); |
1151 FillArenaAwareFields(message); | 1142 FillArenaAwareFields(message); |
1152 } | 1143 } |
1153 | 1144 |
1154 arena.Reset(); | 1145 arena.Reset(); |
1155 } | 1146 } |
1156 | 1147 |
1157 TEST(ArenaTest, ParseCorruptedString) { | |
1158 TestAllTypes message; | |
1159 TestUtil::SetAllFields(&message); | |
1160 TestParseCorruptedString<TestAllTypes, true>(message); | |
1161 TestParseCorruptedString<TestAllTypes, false>(message); | |
1162 } | |
1163 | |
1164 #ifndef GOOGLE_PROTOBUF_NO_RTTI | 1148 #ifndef GOOGLE_PROTOBUF_NO_RTTI |
1165 // Test construction on an arena via generic MessageLite interface. We should be | 1149 // Test construction on an arena via generic MessageLite interface. We should be |
1166 // able to successfully deserialize on the arena without incurring heap | 1150 // able to successfully deserialize on the arena without incurring heap |
1167 // allocations, i.e., everything should still be arena-allocation-aware. | 1151 // allocations, i.e., everything should still be arena-allocation-aware. |
1168 TEST(ArenaTest, MessageLiteOnArena) { | 1152 TEST(ArenaTest, MessageLiteOnArena) { |
1169 std::vector<char> arena_block(128 * 1024); | 1153 std::vector<char> arena_block(128 * 1024); |
1170 ArenaOptions options; | 1154 ArenaOptions options; |
1171 options.initial_block = &arena_block[0]; | 1155 options.initial_block = &arena_block[0]; |
1172 options.initial_block_size = arena_block.size(); | 1156 options.initial_block_size = arena_block.size(); |
1173 Arena arena(options); | 1157 Arena arena(options); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1206 { | 1190 { |
1207 Arena arena; | 1191 Arena arena; |
1208 RepeatedField<string> field_on_arena(&arena); | 1192 RepeatedField<string> field_on_arena(&arena); |
1209 for (int i = 0; i < 100; i++) { | 1193 for (int i = 0; i < 100; i++) { |
1210 *field_on_arena.Add() = "test string long enough to exceed inline buffer"; | 1194 *field_on_arena.Add() = "test string long enough to exceed inline buffer"; |
1211 } | 1195 } |
1212 } | 1196 } |
1213 } | 1197 } |
1214 | 1198 |
1215 // Align n to next multiple of 8 | 1199 // Align n to next multiple of 8 |
| 1200 namespace { |
1216 uint64 Align8(uint64 n) { return (n + 7) & -8; } | 1201 uint64 Align8(uint64 n) { return (n + 7) & -8; } |
| 1202 } // namespace |
1217 | 1203 |
1218 TEST(ArenaTest, SpaceAllocated_and_Used) { | 1204 TEST(ArenaTest, SpaceAllocated_and_Used) { |
1219 ArenaOptions options; | 1205 ArenaOptions options; |
1220 options.start_block_size = 256; | 1206 options.start_block_size = 256; |
1221 options.max_block_size = 8192; | 1207 options.max_block_size = 8192; |
1222 Arena arena_1(options); | 1208 Arena arena_1(options); |
1223 EXPECT_EQ(0, arena_1.SpaceAllocated()); | 1209 EXPECT_EQ(0, arena_1.SpaceAllocated()); |
1224 EXPECT_EQ(0, arena_1.SpaceUsed()); | 1210 EXPECT_EQ(0, arena_1.SpaceUsed()); |
1225 EXPECT_EQ(0, arena_1.Reset()); | 1211 EXPECT_EQ(0, arena_1.Reset()); |
1226 ::google::protobuf::Arena::CreateArray<char>(&arena_1, 320); | 1212 ::google::protobuf::Arena::CreateArray<char>(&arena_1, 320); |
(...skipping 30 matching lines...) Expand all Loading... |
1257 } | 1243 } |
1258 | 1244 |
1259 TEST(ArenaTest, Alignment) { | 1245 TEST(ArenaTest, Alignment) { |
1260 ::google::protobuf::Arena arena; | 1246 ::google::protobuf::Arena arena; |
1261 for (int i = 0; i < 200; i++) { | 1247 for (int i = 0; i < 200; i++) { |
1262 void* p = ::google::protobuf::Arena::CreateArray<char>(&arena, i); | 1248 void* p = ::google::protobuf::Arena::CreateArray<char>(&arena, i); |
1263 GOOGLE_CHECK_EQ(reinterpret_cast<uintptr_t>(p) % 8, 0) << i << ": " << p; | 1249 GOOGLE_CHECK_EQ(reinterpret_cast<uintptr_t>(p) % 8, 0) << i << ": " << p; |
1264 } | 1250 } |
1265 } | 1251 } |
1266 | 1252 |
1267 TEST(ArenaTest, BlockSizeSmallerThanAllocation) { | |
1268 for (size_t i = 0; i <= 8; ++i) { | |
1269 ::google::protobuf::ArenaOptions opt; | |
1270 opt.start_block_size = opt.max_block_size = i; | |
1271 ::google::protobuf::Arena arena(opt); | |
1272 | |
1273 *::google::protobuf::Arena::Create<int64>(&arena) = 42; | |
1274 EXPECT_GE(arena.SpaceAllocated(), 8); | |
1275 EXPECT_EQ(8, arena.SpaceUsed()); | |
1276 | |
1277 *::google::protobuf::Arena::Create<int64>(&arena) = 42; | |
1278 EXPECT_GE(arena.SpaceAllocated(), 16); | |
1279 EXPECT_EQ(16, arena.SpaceUsed()); | |
1280 } | |
1281 } | |
1282 | |
1283 TEST(ArenaTest, GetArenaShouldReturnTheArenaForArenaAllocatedMessages) { | 1253 TEST(ArenaTest, GetArenaShouldReturnTheArenaForArenaAllocatedMessages) { |
1284 ::google::protobuf::Arena arena; | 1254 ::google::protobuf::Arena arena; |
1285 ArenaMessage* message = Arena::CreateMessage<ArenaMessage>(&arena); | 1255 ArenaMessage* message = Arena::CreateMessage<ArenaMessage>(&arena); |
1286 const ArenaMessage* const_pointer_to_message = message; | 1256 const ArenaMessage* const_pointer_to_message = message; |
1287 EXPECT_EQ(&arena, Arena::GetArena(message)); | 1257 EXPECT_EQ(&arena, Arena::GetArena(message)); |
1288 EXPECT_EQ(&arena, Arena::GetArena(const_pointer_to_message)); | 1258 EXPECT_EQ(&arena, Arena::GetArena(const_pointer_to_message)); |
1289 } | 1259 } |
1290 | 1260 |
1291 TEST(ArenaTest, GetArenaShouldReturnNullForNonArenaAllocatedMessages) { | 1261 TEST(ArenaTest, GetArenaShouldReturnNullForNonArenaAllocatedMessages) { |
1292 ArenaMessage message; | 1262 ArenaMessage message; |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1373 EXPECT_EQ(2, ArenaHooksTestUtil::num_allocations); | 1343 EXPECT_EQ(2, ArenaHooksTestUtil::num_allocations); |
1374 } | 1344 } |
1375 arena.Reset(); | 1345 arena.Reset(); |
1376 arena.Reset(); | 1346 arena.Reset(); |
1377 EXPECT_EQ(2, ArenaHooksTestUtil::num_reset); | 1347 EXPECT_EQ(2, ArenaHooksTestUtil::num_reset); |
1378 } | 1348 } |
1379 EXPECT_EQ(3, ArenaHooksTestUtil::num_reset); | 1349 EXPECT_EQ(3, ArenaHooksTestUtil::num_reset); |
1380 EXPECT_EQ(1, ArenaHooksTestUtil::num_destruct); | 1350 EXPECT_EQ(1, ArenaHooksTestUtil::num_destruct); |
1381 } | 1351 } |
1382 | 1352 |
1383 | |
1384 } // namespace | |
1385 } // namespace protobuf | 1353 } // namespace protobuf |
1386 } // namespace google | 1354 } // namespace google |
OLD | NEW |