From 891cf34004e19f0071964b964f65eb3d156575ac Mon Sep 17 00:00:00 2001 From: ncteisen Date: Wed, 18 Jul 2018 08:59:28 -0700 Subject: [PATCH] Use intptr_ts for channel registry test --- test/core/channel/channelz_registry_test.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/test/core/channel/channelz_registry_test.cc b/test/core/channel/channelz_registry_test.cc index 990cd3d205e..581e867584c 100644 --- a/test/core/channel/channelz_registry_test.cc +++ b/test/core/channel/channelz_registry_test.cc @@ -67,14 +67,16 @@ TEST(ChannelzRegistryTest, UuidsAreIncreasing) { } TEST(ChannelzRegistryTest, RegisterGetTest) { - ChannelNode* channelz_channel = nullptr; + // we hackily jam an intptr_t into this pointer to check for equality later + ChannelNode* channelz_channel = (ChannelNode*)42; intptr_t uuid = ChannelzRegistry::RegisterChannelNode(channelz_channel); ChannelNode* retrieved = ChannelzRegistry::GetChannelNode(uuid); EXPECT_EQ(channelz_channel, retrieved); } TEST(ChannelzRegistryTest, RegisterManyItems) { - ChannelNode* channelz_channel = nullptr; + // we hackily jam an intptr_t into this pointer to check for equality later + ChannelNode* channelz_channel = (ChannelNode*)42; for (int i = 0; i < 100; i++) { intptr_t uuid = ChannelzRegistry::RegisterChannelNode(channelz_channel); ChannelNode* retrieved = ChannelzRegistry::GetChannelNode(uuid); @@ -83,7 +85,8 @@ TEST(ChannelzRegistryTest, RegisterManyItems) { } TEST(ChannelzRegistryTest, NullIfNotPresentTest) { - ChannelNode* channelz_channel = nullptr; + // we hackily jam an intptr_t into this pointer to check for equality later + ChannelNode* channelz_channel = (ChannelNode*)42; intptr_t uuid = ChannelzRegistry::RegisterChannelNode(channelz_channel); // try to pull out a uuid that does not exist. ChannelNode* nonexistant = ChannelzRegistry::GetChannelNode(uuid + 1);