aboutsummaryrefslogtreecommitdiff
path: root/tests/repository-location/driver.cxx
diff options
context:
space:
mode:
authorKaren Arutyunov <karen@codesynthesis.com>2018-01-28 00:56:14 +0300
committerKaren Arutyunov <karen@codesynthesis.com>2018-02-08 18:43:02 +0300
commit4fe188dee733c28b8b7d2d6b3e7d7904d1d30b65 (patch)
treec089ad2ddf72478b579697f6571cefd8761938cf /tests/repository-location/driver.cxx
parentaef171cd9a6948deb379be3515b972a0e9dcce13 (diff)
Fix repository_url ctor to normalize path
Diffstat (limited to 'tests/repository-location/driver.cxx')
-rw-r--r--tests/repository-location/driver.cxx44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/repository-location/driver.cxx b/tests/repository-location/driver.cxx
index 18ccd2a..098ecab 100644
--- a/tests/repository-location/driver.cxx
+++ b/tests/repository-location/driver.cxx
@@ -439,6 +439,14 @@ namespace bpkg
assert (l.canonical_name () == "git:example.com");
}
{
+ repository_url u ("http://git.example.com/a/#master");
+ *u.path /= path ("..");
+
+ repository_location l (u, repository_type::git);
+ assert (l.string () == "http://git.example.com/#master");
+ assert (l.canonical_name () == "git:example.com");
+ }
+ {
repository_location l (loc ("http://a.com/a/b/../c/1/aa/../bb"));
assert (l.string () == "http://a.com/a/c/1/bb");
assert (l.canonical_name () == "bpkg:a.com/a/c/bb");
@@ -740,6 +748,42 @@ namespace bpkg
repository_url::host_type ("example.com"),
dir_path ("test.git")));
+ // For an empty URL object all components are absent.
+ //
+ {
+ repository_url u;
+ assert (u.empty () &&
+ !u.authority && !u.path && !u.query && !u.fragment);
+ }
+
+ // Absent path.
+ //
+ assert (repository_url ("git://example.com").string () ==
+ "git://example.com/");
+
+ // Empty path.
+ //
+ assert (repository_url ("git://example.com/").string () ==
+ "git://example.com/");
+
+ // Normalized path.
+ //
+ assert (repository_url ("git://example.com/a/..").string () ==
+ "git://example.com/");
+
+ // No trailing slash.
+ //
+ assert (repository_url ("git://example.com/a/").string () ==
+ "git://example.com/a");
+
+ assert (repository_url ("a/").string () == "a");
+
+#ifndef _WIN32
+ assert (repository_url ("/a/").string () == "/a");
+#else
+ assert (repository_url ("c:/a/").string () == "c:\\a");
+#endif
+
return 0;
}
}