@@ -309,6 +309,32 @@ TEST(MapTest, SizeTypeIsSizeT) {
309309 (void )x;
310310}
311311
312+ using KeyTypes = void (*)(bool , int32_t , uint32_t , int64_t , uint64_t ,
313+ std::string);
314+ // Some arbitrary proto enum.
315+ using SomeEnum = proto2_unittest::TestAllTypes::NestedEnum;
316+ using ValueTypes = void (*)(bool , int32_t , uint32_t , int64_t , uint64_t , float ,
317+ double , std::string, SomeEnum,
318+ proto2_unittest::TestEmptyMessage,
319+ proto2_unittest::TestAllTypes);
320+
321+ TEST (MapTest, StaticTypeKindWorks) {
322+ using UMB = UntypedMapBase;
323+ EXPECT_EQ (UMB::TypeKind::kBool , UMB::StaticTypeKind<bool >());
324+ EXPECT_EQ (UMB::TypeKind::kU32 , UMB::StaticTypeKind<int32_t >());
325+ EXPECT_EQ (UMB::TypeKind::kU32 , UMB::StaticTypeKind<uint32_t >());
326+ EXPECT_EQ (UMB::TypeKind::kU32 , UMB::StaticTypeKind<SomeEnum>());
327+ EXPECT_EQ (UMB::TypeKind::kU64 , UMB::StaticTypeKind<int64_t >());
328+ EXPECT_EQ (UMB::TypeKind::kU64 , UMB::StaticTypeKind<uint64_t >());
329+ EXPECT_EQ (UMB::TypeKind::kString , UMB::StaticTypeKind<std::string>());
330+ EXPECT_EQ (UMB::TypeKind::kMessage ,
331+ UMB::StaticTypeKind<proto2_unittest::TestAllTypes>());
332+ }
333+
334+ #if !defined(__GNUC__) || defined(__clang__) || PROTOBUF_GNUC_MIN(9, 4)
335+ // Parameter pack expansion bug before GCC 8.2:
336+ // https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85305
337+
312338template <typename F, typename ... Key, typename ... Value>
313339void TestAllKeyValueTypes (void (*)(Key...), void (*)(Value...), F f) {
314340 (
@@ -319,15 +345,6 @@ void TestAllKeyValueTypes(void (*)(Key...), void (*)(Value...), F f) {
319345 ...);
320346}
321347
322- using KeyTypes = void (*)(bool , int32_t , uint32_t , int64_t , uint64_t ,
323- std::string);
324- // Some arbitrary proto enum.
325- using SomeEnum = proto2_unittest::TestAllTypes::NestedEnum;
326- using ValueTypes = void (*)(bool , int32_t , uint32_t , int64_t , uint64_t , float ,
327- double , std::string, SomeEnum,
328- proto2_unittest::TestEmptyMessage,
329- proto2_unittest::TestAllTypes);
330-
331348TEST (MapTest, StaticTypeInfoMatchesDynamicOne) {
332349 TestAllKeyValueTypes (KeyTypes (), ValueTypes (), [](auto key, auto value) {
333350 using Key = decltype (key);
@@ -338,27 +355,15 @@ TEST(MapTest, StaticTypeInfoMatchesDynamicOne) {
338355 }
339356 const auto type_info = MapTestPeer::GetTypeInfo<Map<Key, Value>>();
340357 const auto dyn_type_info = internal::UntypedMapBase::GetTypeInfoDynamic (
341- type_info.key_type , type_info.value_type , value_prototype);
358+ type_info.key_type_kind (), type_info.value_type_kind (),
359+ value_prototype);
342360 EXPECT_EQ (dyn_type_info.node_size , type_info.node_size );
343361 EXPECT_EQ (dyn_type_info.value_offset , type_info.value_offset );
344362 EXPECT_EQ (dyn_type_info.key_type , type_info.key_type );
345363 EXPECT_EQ (dyn_type_info.value_type , type_info.value_type );
346364 });
347365}
348366
349- TEST (MapTest, StaticTypeKindWorks) {
350- using UMB = UntypedMapBase;
351- EXPECT_EQ (UMB::TypeKind::kBool , UMB::StaticTypeKind<bool >());
352- EXPECT_EQ (UMB::TypeKind::kU32 , UMB::StaticTypeKind<int32_t >());
353- EXPECT_EQ (UMB::TypeKind::kU32 , UMB::StaticTypeKind<uint32_t >());
354- EXPECT_EQ (UMB::TypeKind::kU32 , UMB::StaticTypeKind<SomeEnum>());
355- EXPECT_EQ (UMB::TypeKind::kU64 , UMB::StaticTypeKind<int64_t >());
356- EXPECT_EQ (UMB::TypeKind::kU64 , UMB::StaticTypeKind<uint64_t >());
357- EXPECT_EQ (UMB::TypeKind::kString , UMB::StaticTypeKind<std::string>());
358- EXPECT_EQ (UMB::TypeKind::kMessage ,
359- UMB::StaticTypeKind<proto2_unittest::TestAllTypes>());
360- }
361-
362367template <typename LHS, typename RHS>
363368void TestEqPtr (LHS* lhs, RHS* rhs) {
364369 // To silence some false positive compiler errors in gcc 9.5
@@ -428,6 +433,8 @@ TEST(MapTest, VisitAllNodesUsesTheRightTypesOnAllNodes) {
428433 });
429434}
430435
436+ #endif
437+
431438TEST (MapTest, IteratorNodeFieldIsNullPtrAtEnd) {
432439 Map<int , int > map;
433440 EXPECT_EQ (internal::UntypedMapIterator::FromTyped (map.cbegin ()).node_ ,
0 commit comments