From 4fe188dee733c28b8b7d2d6b3e7d7904d1d30b65 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sun, 28 Jan 2018 00:56:14 +0300 Subject: Fix repository_url ctor to normalize path --- tests/repository-location/driver.cxx | 44 ++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'tests/repository-location/driver.cxx') 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; } } -- cgit v1.1