ssorj commented on a change in pull request #303:
URL: https://github.com/apache/qpid-proton/pull/303#discussion_r605897055



##########
File path: cpp/src/url_test.cpp
##########
@@ -111,6 +116,54 @@ TEST_CASE("parse URL","[url]") {
                   "amqp", "user", "pass", "::1", "1234", "path",
                   "amqp://user:pass@[::1]:1234/path");
     }
+    SECTION("port") {
+        CHECK("host:1234" == url("amqp://host:1234/path").host_port());
+        CHECK(5672 == url("amqp://foo/path").port_int());
+        CHECK(5671 == url("amqps://foo/path").port_int());
+        CHECK(1234 == url("amqps://foo:1234/path").port_int());
+
+        url u("amqps://foo:xyz/path");
+        url_error caught_error("");
+        try{
+          u.port_int();
+        }
+        catch(url_error& err){
+          caught_error=err;

Review comment:
       As a style and readability matter, put spaces around assignment operators

##########
File path: cpp/src/url_test.cpp
##########
@@ -111,6 +116,54 @@ TEST_CASE("parse URL","[url]") {
                   "amqp", "user", "pass", "::1", "1234", "path",
                   "amqp://user:pass@[::1]:1234/path");
     }
+    SECTION("port") {
+        CHECK("host:1234" == url("amqp://host:1234/path").host_port());
+        CHECK(5672 == url("amqp://foo/path").port_int());
+        CHECK(5671 == url("amqps://foo/path").port_int());
+        CHECK(1234 == url("amqps://foo:1234/path").port_int());
+
+        url u("amqps://foo:xyz/path");
+        url_error caught_error("");
+        try{
+          u.port_int();
+        }
+        catch(url_error& err){
+          caught_error=err;
+        }
+        CHECK(std::string("invalid port 'xyz'") == 
std::string(caught_error.what()));
+    }
+    SECTION("misc") {

Review comment:
       "Misc" is too generic here.  I think "constructors" for the copy 
constructor case and "operators" for the  remaining tests currently under misc 
would be more helpful to future developers.

##########
File path: cpp/src/url_test.cpp
##########
@@ -111,6 +116,54 @@ TEST_CASE("parse URL","[url]") {
                   "amqp", "user", "pass", "::1", "1234", "path",
                   "amqp://user:pass@[::1]:1234/path");
     }
+    SECTION("port") {
+        CHECK("host:1234" == url("amqp://host:1234/path").host_port());
+        CHECK(5672 == url("amqp://foo/path").port_int());
+        CHECK(5671 == url("amqps://foo/path").port_int());
+        CHECK(1234 == url("amqps://foo:1234/path").port_int());
+
+        url u("amqps://foo:xyz/path");
+        url_error caught_error("");
+        try{
+          u.port_int();
+        }
+        catch(url_error& err){
+          caught_error=err;
+        }
+        CHECK(std::string("invalid port 'xyz'") == 
std::string(caught_error.what()));
+    }
+    SECTION("misc") {
+        {
+          // url copy constructor
+          url u1("amqp://foo:xyz/path");
+          url u2=u1;
+          CHECK(std::string("amqp://foo:xyz/path") == std::string(u2));
+
+          // url assignment operator
+          url u3("amqp://foo:xyz/pathdontcare");
+          u3=u1;
+          CHECK(std::string("amqp://foo:xyz/path") == std::string(u3));
+        }
+        {
+          url u("amqp://foo:1234/path");
+          CHECK(true == u.empty());
+          CHECK(std::string("amqp://foo:1234/path") == std::string(u));
+          CHECK(false == u.empty());
+        }
+        {
+          url u("amqp://foo:xyz/path");
+          std::ostringstream o;
+          o<<u;

Review comment:
       Spaces around these too




-- 
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org
For additional commands, e-mail: dev-h...@qpid.apache.org

Reply via email to