@@ -309,6 +309,32 @@ TEST(MapTest, SizeTypeIsSizeT) {
309
309
(void )x;
310
310
}
311
311
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
+
312
338
template <typename F, typename ... Key, typename ... Value>
313
339
void TestAllKeyValueTypes (void (*)(Key...), void (*)(Value...), F f) {
314
340
(
@@ -319,15 +345,6 @@ void TestAllKeyValueTypes(void (*)(Key...), void (*)(Value...), F f) {
319
345
...);
320
346
}
321
347
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
-
331
348
TEST (MapTest, StaticTypeInfoMatchesDynamicOne) {
332
349
TestAllKeyValueTypes (KeyTypes (), ValueTypes (), [](auto key, auto value) {
333
350
using Key = decltype (key);
@@ -338,27 +355,15 @@ TEST(MapTest, StaticTypeInfoMatchesDynamicOne) {
338
355
}
339
356
const auto type_info = MapTestPeer::GetTypeInfo<Map<Key, Value>>();
340
357
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);
342
360
EXPECT_EQ (dyn_type_info.node_size , type_info.node_size );
343
361
EXPECT_EQ (dyn_type_info.value_offset , type_info.value_offset );
344
362
EXPECT_EQ (dyn_type_info.key_type , type_info.key_type );
345
363
EXPECT_EQ (dyn_type_info.value_type , type_info.value_type );
346
364
});
347
365
}
348
366
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
-
362
367
template <typename LHS, typename RHS>
363
368
void TestEqPtr (LHS* lhs, RHS* rhs) {
364
369
// To silence some false positive compiler errors in gcc 9.5
@@ -428,6 +433,8 @@ TEST(MapTest, VisitAllNodesUsesTheRightTypesOnAllNodes) {
428
433
});
429
434
}
430
435
436
+ #endif
437
+
431
438
TEST (MapTest, IteratorNodeFieldIsNullPtrAtEnd) {
432
439
Map<int , int > map;
433
440
EXPECT_EQ (internal::UntypedMapIterator::FromTyped (map.cbegin ()).node_ ,
0 commit comments