1414
1515#include " google/cloud/pubsublite/internal/default_routing_policy.h"
1616#include < gmock/gmock.h>
17+ #include < array>
1718#include < unordered_map>
1819
1920namespace google {
@@ -50,9 +51,9 @@ TEST(DefaultRoutingPolicyTest, RouteWithKey) {
5051TEST (DefaultRoutingPolicyTest, RouteWithoutKey) {
5152 unsigned int num_partitions = 29 ;
5253 DefaultRoutingPolicy rp;
53- uint64_t initial_partition = rp.Route (num_partitions);
54+ std:: uint32_t initial_partition = rp.Route (num_partitions);
5455 for (unsigned int i = 0 ; i < num_partitions; ++i) {
55- uint64_t next_partition = rp.Route (num_partitions);
56+ std:: uint32_t next_partition = rp.Route (num_partitions);
5657 EXPECT_EQ ((initial_partition + 1 ) % num_partitions,
5758 next_partition % num_partitions);
5859 initial_partition = next_partition;
@@ -70,6 +71,7 @@ TEST(TestGetMod, MaxValue) {
7071 EXPECT_EQ (GetMod (arr, 100 ), 35 );
7172 EXPECT_EQ (GetMod (arr, 10023 ), 5397 );
7273 EXPECT_EQ (GetMod (arr, UINT8_MAX), 0 );
74+ EXPECT_EQ (GetMod (arr, UINT32_MAX - 1 ), 255 );
7375}
7476
7577TEST (TestGetMod, OneLessThanMaxValue) {
@@ -82,6 +84,7 @@ TEST(TestGetMod, OneLessThanMaxValue) {
8284 EXPECT_EQ (GetMod (arr, 100 ), 34 );
8385 EXPECT_EQ (GetMod (arr, 10023 ), 5396 );
8486 EXPECT_EQ (GetMod (arr, UINT8_MAX), 254 );
87+ EXPECT_EQ (GetMod (arr, UINT32_MAX - 1 ), 254 );
8588}
8689
8790TEST (TestGetMod, Zeros) {
@@ -93,6 +96,7 @@ TEST(TestGetMod, Zeros) {
9396 EXPECT_EQ (GetMod (arr, 100 ), 0 );
9497 EXPECT_EQ (GetMod (arr, 10023 ), 0 );
9598 EXPECT_EQ (GetMod (arr, UINT8_MAX), 0 );
99+ EXPECT_EQ (GetMod (arr, UINT32_MAX - 1 ), 0 );
96100}
97101
98102TEST (TestGetMod, ArbitraryValue) {
@@ -105,6 +109,7 @@ TEST(TestGetMod, ArbitraryValue) {
105109 EXPECT_EQ (GetMod (arr, 10023 ), 3346 );
106110 EXPECT_EQ (GetMod (arr, 109000 ), 60390 );
107111 EXPECT_EQ (GetMod (arr, UINT8_MAX), 100 );
112+ EXPECT_EQ (GetMod (arr, UINT32_MAX - 1 ), 1136793478 );
108113}
109114
110115TEST (TestGetMod, ArbitraryValue1) {
@@ -115,6 +120,7 @@ TEST(TestGetMod, ArbitraryValue1) {
115120 EXPECT_EQ (GetMod (arr, 102301 ), 93535 );
116121 EXPECT_EQ (GetMod (arr, 23 ), 13 );
117122 EXPECT_EQ (GetMod (arr, UINT8_MAX), 37 );
123+ EXPECT_EQ (GetMod (arr, UINT32_MAX - 1 ), 3416191692 );
118124}
119125
120126GOOGLE_CLOUD_CPP_INLINE_NAMESPACE_END
0 commit comments