empiredan commented on code in PR #1825:
URL: 
https://github.com/apache/incubator-pegasus/pull/1825#discussion_r1444217215


##########
src/runtime/test/host_port_test.cpp:
##########
@@ -204,21 +245,20 @@ TEST(host_port_test, dns_resolver)
     {
         host_port hp_grp;
         hp_grp.assign_group("test_group");
-        rpc_group_host_port *g = hp_grp.group_host_port();
+        auto g_hp = hp_grp.group_host_port();
 
         host_port hp1("localhost", 8080);
-        ASSERT_TRUE(g->add(hp1));
+        ASSERT_TRUE(g_hp->add(hp1));
         host_port hp2("localhost", 8081);
-        g->set_leader(hp2);
+        g_hp->set_leader(hp2);
 
         auto addr_grp = resolver.resolve_address(hp_grp);
+        auto g_addr = addr_grp.group_address();
 
-        ASSERT_EQ(addr_grp.group_address()->is_update_leader_automatically(),
-                  hp_grp.group_host_port()->is_update_leader_automatically());
-        ASSERT_EQ(strcmp(addr_grp.group_address()->name(), 
hp_grp.group_host_port()->name()), 0);
-        ASSERT_EQ(addr_grp.group_address()->count(), 
hp_grp.group_host_port()->count());
-        ASSERT_EQ(host_port(addr_grp.group_address()->leader()),
-                  hp_grp.group_host_port()->leader());
+        ASSERT_EQ(g_addr->is_update_leader_automatically(), 
g_hp->is_update_leader_automatically());
+        ASSERT_EQ(strcmp(g_addr->name(), g_hp->name()), 0);

Review Comment:
   ```suggestion
           ASSERT_STREQ(g_addr->name(), g_hp->name());
   ```



##########
src/runtime/test/host_port_test.cpp:
##########
@@ -71,6 +73,7 @@ TEST(host_port_test, host_port_build)
 TEST(host_port_test, operators)
 {
     host_port hp("localhost", 8080);
+    ASSERT_EQ(strcmp("localhost:8080", hp.get_char_str()), 0);

Review Comment:
   ```suggestion
       ASSERT_STREQ("localhost:8080", hp.to_string());
   ```



##########
src/runtime/test/host_port_test.cpp:
##########
@@ -166,6 +172,41 @@ TEST(host_port_test, rpc_group_host_port)
     ASSERT_FALSE(g->contains(hp2));
     ASSERT_EQ(0u, g->members().size());
     ASSERT_EQ(invalid_hp, g->leader());
+
+    // operator <
+    host_port hp_grp1;
+    hp_grp1.assign_group("test_group");
+    if (reinterpret_cast<uint64_t>(hp_grp.group_host_port().get()) <
+        reinterpret_cast<uint64_t>(hp_grp1.group_host_port().get())) {
+        ASSERT_TRUE(hp_grp < hp_grp1);
+    } else {
+        ASSERT_FALSE(hp_grp < hp_grp1);
+    }
+
+    // address_group -> host_port_group
+    rpc_address addr("127.0.0.1", 8080);
+    rpc_address addr2("127.0.0.1", 8081);
+
+    rpc_address addr_grp;
+    addr_grp.assign_group("test_group");
+    ASSERT_EQ(HOST_TYPE_GROUP, addr_grp.type());
+
+    auto g_addr = addr_grp.group_address();
+    ASSERT_EQ(std::string("test_group"), g_addr->name());

Review Comment:
   ```suggestion
       ASSERT_STREQ("test_group", g_addr->name());
   ```



##########
src/runtime/test/host_port_test.cpp:
##########
@@ -166,6 +172,41 @@ TEST(host_port_test, rpc_group_host_port)
     ASSERT_FALSE(g->contains(hp2));
     ASSERT_EQ(0u, g->members().size());
     ASSERT_EQ(invalid_hp, g->leader());
+
+    // operator <
+    host_port hp_grp1;
+    hp_grp1.assign_group("test_group");
+    if (reinterpret_cast<uint64_t>(hp_grp.group_host_port().get()) <
+        reinterpret_cast<uint64_t>(hp_grp1.group_host_port().get())) {
+        ASSERT_TRUE(hp_grp < hp_grp1);
+    } else {
+        ASSERT_FALSE(hp_grp < hp_grp1);
+    }
+
+    // address_group -> host_port_group
+    rpc_address addr("127.0.0.1", 8080);
+    rpc_address addr2("127.0.0.1", 8081);
+
+    rpc_address addr_grp;
+    addr_grp.assign_group("test_group");
+    ASSERT_EQ(HOST_TYPE_GROUP, addr_grp.type());
+
+    auto g_addr = addr_grp.group_address();
+    ASSERT_EQ(std::string("test_group"), g_addr->name());
+
+    ASSERT_TRUE(g_addr->add(addr));
+    g_addr->set_leader(addr2);
+    ASSERT_EQ(addr2, g_addr->leader());
+    ASSERT_EQ(2, g_addr->count());
+
+    host_port hp_grp2;
+    hp_grp2 = host_port(addr_grp);
+    ASSERT_EQ(HOST_TYPE_GROUP, hp_grp2.type());
+
+    auto g_hp = hp_grp2.group_host_port();
+    ASSERT_EQ(std::string("test_group"), g_hp->name());

Review Comment:
   ```suggestion
       ASSERT_STREQ("test_group", g_hp->name());
   ```



##########
src/runtime/test/host_port_test.cpp:
##########
@@ -166,6 +172,41 @@ TEST(host_port_test, rpc_group_host_port)
     ASSERT_FALSE(g->contains(hp2));
     ASSERT_EQ(0u, g->members().size());
     ASSERT_EQ(invalid_hp, g->leader());
+
+    // operator <
+    host_port hp_grp1;
+    hp_grp1.assign_group("test_group");
+    if (reinterpret_cast<uint64_t>(hp_grp.group_host_port().get()) <
+        reinterpret_cast<uint64_t>(hp_grp1.group_host_port().get())) {
+        ASSERT_TRUE(hp_grp < hp_grp1);
+    } else {
+        ASSERT_FALSE(hp_grp < hp_grp1);

Review Comment:
   ```suggestion
           ASSERT_LT(hp_grp, hp_grp1);
   ```



##########
src/runtime/test/host_port_test.cpp:
##########
@@ -166,6 +172,41 @@ TEST(host_port_test, rpc_group_host_port)
     ASSERT_FALSE(g->contains(hp2));
     ASSERT_EQ(0u, g->members().size());
     ASSERT_EQ(invalid_hp, g->leader());
+
+    // operator <
+    host_port hp_grp1;
+    hp_grp1.assign_group("test_group");
+    if (reinterpret_cast<uint64_t>(hp_grp.group_host_port().get()) <
+        reinterpret_cast<uint64_t>(hp_grp1.group_host_port().get())) {
+        ASSERT_TRUE(hp_grp < hp_grp1);

Review Comment:
   ```suggestion
           ASSERT_LT(hp_grp, hp_grp1);
   ```



##########
src/runtime/test/host_port_test.cpp:
##########
@@ -50,7 +52,7 @@ TEST(host_port_test, host_port_to_string)
 
     {
         host_port hp;
-        ASSERT_EQ(std::string("invalid address"), hp.to_string());
+        ASSERT_EQ(std::string("invalid host_port"), hp.to_string());

Review Comment:
   ```suggestion
           ASSERT_EQ("invalid host_port", hp.to_string());
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to