aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2018-01-12 10:55:44 -0800
committerGarrett D'Amore <garrett@damore.org>2018-01-16 08:45:11 -0800
commit18229bbb69423d64d0a1b98bcf4bf3e24fba3aa4 (patch)
tree7fa71622a83c5429d4e4e09a9f051f0c79d9e6a5 /tests
parent7e52d0b37a0b1c87071f3bc5d528caef8e400156 (diff)
downloadnng-18229bbb69423d64d0a1b98bcf4bf3e24fba3aa4.tar.gz
nng-18229bbb69423d64d0a1b98bcf4bf3e24fba3aa4.tar.bz2
nng-18229bbb69423d64d0a1b98bcf4bf3e24fba3aa4.zip
Supply default ports for some well-known schemes.
Diffstat (limited to 'tests')
-rw-r--r--tests/url.c42
1 files changed, 35 insertions, 7 deletions
diff --git a/tests/url.c b/tests/url.c
index 6fb35596..5348d470 100644
--- a/tests/url.c
+++ b/tests/url.c
@@ -27,7 +27,7 @@ TestMain("URLs", {
So(strcmp(url->u_scheme, "http") == 0);
So(strcmp(url->u_host, "www.google.com") == 0);
So(strcmp(url->u_hostname, "www.google.com") == 0);
- So(strcmp(url->u_port, "") == 0);
+ So(strcmp(url->u_port, "80") == 0);
So(strcmp(url->u_path, "") == 0);
So(strcmp(url->u_rawpath, "") == 0);
So(url->u_query == NULL);
@@ -88,7 +88,7 @@ TestMain("URLs", {
So(strcmp(url->u_scheme, "http") == 0);
So(strcmp(url->u_host, "www.google.com") == 0);
So(strcmp(url->u_hostname, "www.google.com") == 0);
- So(strcmp(url->u_port, "") == 0);
+ So(strcmp(url->u_port, "80") == 0);
So(strcmp(url->u_path, "/somewhere") == 0);
So(strcmp(url->u_query, "result=yes") == 0);
So(strcmp(url->u_rawpath, "/somewhere?result=yes") == 0);
@@ -104,7 +104,7 @@ TestMain("URLs", {
So(strcmp(url->u_scheme, "http") == 0);
So(strcmp(url->u_host, "www.google.com") == 0);
So(strcmp(url->u_hostname, "www.google.com") == 0);
- So(strcmp(url->u_port, "") == 0);
+ So(strcmp(url->u_port, "80") == 0);
So(strcmp(url->u_path, "/somewhere") == 0);
So(strcmp(url->u_query, "result=yes") == 0);
So(strcmp(url->u_fragment, "chapter1") == 0);
@@ -120,7 +120,7 @@ TestMain("URLs", {
So(strcmp(url->u_scheme, "http") == 0);
So(strcmp(url->u_host, "www.google.com") == 0);
So(strcmp(url->u_hostname, "www.google.com") == 0);
- So(strcmp(url->u_port, "") == 0);
+ So(strcmp(url->u_port, "80") == 0);
So(strcmp(url->u_path, "/somewhere") == 0);
So(strcmp(url->u_fragment, "chapter2") == 0);
So(strcmp(url->u_rawpath, "/somewhere#chapter2") == 0);
@@ -135,7 +135,7 @@ TestMain("URLs", {
So(strcmp(url->u_host, "www.google.com") == 0);
So(strcmp(url->u_hostname, "www.google.com") == 0);
So(strcmp(url->u_path, "") == 0);
- So(strcmp(url->u_port, "") == 0);
+ So(strcmp(url->u_port, "80") == 0);
So(strcmp(url->u_fragment, "chapter3") == 0);
So(strcmp(url->u_rawpath, "#chapter3") == 0);
So(url->u_query == NULL);
@@ -150,7 +150,7 @@ TestMain("URLs", {
So(strcmp(url->u_host, "www.google.com") == 0);
So(strcmp(url->u_hostname, "www.google.com") == 0);
So(strcmp(url->u_path, "") == 0);
- So(strcmp(url->u_port, "") == 0);
+ So(strcmp(url->u_port, "80") == 0);
So(strcmp(url->u_query, "color=red") == 0);
So(strcmp(url->u_rawpath, "?color=red") == 0);
So(url->u_fragment == NULL);
@@ -165,7 +165,7 @@ TestMain("URLs", {
So(strcmp(url->u_host, "[::1]") == 0);
So(strcmp(url->u_hostname, "::1") == 0);
So(strcmp(url->u_path, "") == 0);
- So(strcmp(url->u_port, "") == 0);
+ So(strcmp(url->u_port, "80") == 0);
So(url->u_query == NULL);
So(url->u_fragment == NULL);
So(url->u_userinfo == NULL);
@@ -213,6 +213,34 @@ TestMain("URLs", {
nni_url_free(url);
});
+ Convey("ws://", {
+ So(nni_url_parse(&url, "ws://") == 0);
+ So(url != NULL);
+ So(strcmp(url->u_scheme, "ws") == 0);
+ So(strcmp(url->u_host, "") == 0);
+ So(strcmp(url->u_hostname, "") == 0);
+ So(strcmp(url->u_path, "") == 0);
+ So(strcmp(url->u_port, "80") == 0);
+ So(url->u_query == NULL);
+ So(url->u_fragment == NULL);
+ So(url->u_userinfo == NULL);
+ nni_url_free(url);
+ });
+
+ Convey("ssh://user@host.example.com", {
+ So(nni_url_parse(&url, "ssh://user@host.example.com") == 0);
+ So(url != NULL);
+ So(strcmp(url->u_scheme, "ssh") == 0);
+ So(strcmp(url->u_host, "host.example.com") == 0);
+ So(strcmp(url->u_hostname, "host.example.com") == 0);
+ So(strcmp(url->u_path, "") == 0);
+ So(strcmp(url->u_port, "22") == 0);
+ So(url->u_query == NULL);
+ So(url->u_fragment == NULL);
+ So(strcmp(url->u_userinfo, "user") == 0);
+ nni_url_free(url);
+ });
+
Convey("Negative www.google.com", {
url = NULL;
So(nni_url_parse(&url, "www.google.com") == NNG_EINVAL);