From 6d28b0449f27781b94a0b6633db728a323efd71e Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 22 Jul 2017 14:41:32 +0300 Subject: Fix ambiguity between std::optional and butl::optional (take 2) --- tests/package-version/driver.cxx | 614 +++++++++--------- tests/repository-location/driver.cxx | 1148 +++++++++++++++++----------------- 2 files changed, 895 insertions(+), 867 deletions(-) (limited to 'tests') diff --git a/tests/package-version/driver.cxx b/tests/package-version/driver.cxx index 0e9ef98..b39deb1 100644 --- a/tests/package-version/driver.cxx +++ b/tests/package-version/driver.cxx @@ -16,331 +16,341 @@ using namespace std; using namespace butl; -using namespace bpkg; -using butl::optional; -using butl::nullopt; - -static bool -bad_version (const string& v) +namespace bpkg { - try - { - version bv (v); - return false; - } - catch (const invalid_argument&) - { - return true; - } -} + using butl::optional; + using butl::nullopt; -static bool -bad_version (uint16_t e, - const string& u, - const optional& l, - uint16_t r) -{ - try - { - version bv (e, u, l, r); - return false; - } - catch (const invalid_argument&) + static bool + bad_version (const string& v) { - return true; - } -} - -static bool -bad_version (uint16_t e, const string& u, const char* l, uint16_t r) -{ - return bad_version (e, u, string (l), r); -} - -static bool -test_constructor (const version& v) -{ - return v == version (v.epoch, v.upstream, v.release, v.revision); -} - -int -main (int argc, char* argv[]) -{ - if (argc != 1) - { - cerr << "usage: " << argv[0] << endl; - return 1; - } - - try - { - assert (bad_version ("")); // Empty upstream. - assert (bad_version ("1~")); // Same. - assert (bad_version ("1~+3")); // Same. - assert (bad_version ("+3")); // Same. - assert (bad_version ("1~-a")); // Same. - assert (bad_version ("1~-a+3")); // Same. - assert (bad_version ("-a+3")); // Same. - assert (bad_version ("~3.5")); // Empty epoch. - assert (bad_version ("a+")); // Empty revision. - assert (bad_version ("1~2~4.1+3")); // Extra epoch. - assert (bad_version ("3.5+1+4")); // Extra revision. - assert (bad_version ("1~~2+3")); // Duplicated epoch separator. - assert (bad_version ("1~2++3")); // Duplicated revision separator. - assert (bad_version ("a.39485739122323231.3")); // Too long component. - assert (bad_version ("a.00000000000000000.3")); // Too long zero component. - assert (bad_version ("1-a.00000000000000000")); // Same. - assert (bad_version ("65536~q.3")); // Too big epoch. - assert (bad_version ("1+q+65536")); // Too big revision. - assert (bad_version ("3.5~1.4")); // Components in epoch. - assert (bad_version ("3.5+1.4")); // Components in revision. - assert (bad_version ("3 5+1")); // Non alpha-numeric in upstream. - assert (bad_version ("1~ +3")); // Same. - assert (bad_version ("1-3 5+1")); // Non alpha-numeric in release. - assert (bad_version ("1~1- +3")); // Same. - assert (bad_version ("3 5~4+1")); // Non alpha-numeric in epoch. - assert (bad_version ("2b~a")); // Same. - assert (bad_version ("1~34.1+3 5")); // Non numeric in revision. - assert (bad_version ("a+3s")); // Same. - assert (bad_version ("a.")); // Not completed upstream. - assert (bad_version ("a..b")); // Empty upstream component. - assert (bad_version ("a.b-+1")); // Revision for empty release. - assert (bad_version ("0.0-+3")); // Same. - assert (bad_version ("1.2.3-~")); // Invalid release. - assert (bad_version ("0-")); // Illegal version. - assert (bad_version ("0.0-")); // Same. - - assert (bad_version (0, "1", "", 1)); // Revision for empty release. - assert (bad_version (1, "1~1.1", "", 2)); // Epoch in upstream. - assert (bad_version (1, "1.1-1", "", 2)); // Release in upstream. - assert (bad_version (1, "1.1+1", "", 2)); // Revision in upstream. - assert (bad_version (1, "1", "1~1.1", 2)); // Epoch in release. - assert (bad_version (1, "1", "1.1-1", 2)); // Release in release. - assert (bad_version (1, "1", "1.1+1", 2)); // Revision in release. - - assert (bad_version (1, "", "", 0)); // Unexpected epoch. - assert (bad_version (0, "", "1", 0)); // Unexpected release. - assert (bad_version (0, "", "", 1)); // Unexpected revision. - - { - version v1; - assert (v1.empty ()); - assert (v1.canonical_upstream.empty ()); - assert (v1.canonical_release.empty ()); - - version v2 ("0.0.0"); - assert (!v2.empty ()); - assert (v1.canonical_upstream.empty ()); - assert (v2.canonical_release == "~"); - - assert (v1 != v2); - } - - { - version v ("1~0.0-"); - assert (!v.empty ()); - assert (v.string () == "1~0.0-"); - assert (v.canonical_upstream.empty ()); - assert (v.canonical_release.empty ()); - assert (test_constructor (v)); - } - + try { - version v ("a"); - assert (v.string () == "a"); - assert (v.canonical_upstream == "a"); - assert (test_constructor (v)); + version bv (v); + return false; } - - { - version v ("65534~ab+65535"); - assert (v.string () == "65534~ab+65535"); - assert (v.canonical_upstream == "ab"); - assert (test_constructor (v)); - } - + catch (const invalid_argument&) { - version v ("1"); - assert (v.string () == "1"); - assert (v.canonical_upstream == "0000000000000001"); - assert (test_constructor (v)); - } - - { - version v ("0"); - assert (v.string () == "0"); - assert (v.canonical_upstream.empty ()); - assert (test_constructor (v)); - } - - { - version v ("0.0.0"); - assert (v.string () == "0.0.0"); - assert (v.canonical_upstream.empty ()); - assert (test_constructor (v)); - } - - { - version v ("1.0.0"); - assert (v.string () == "1.0.0"); - assert (v.canonical_upstream == "0000000000000001"); - assert (test_constructor (v)); - } - - { - version v ("0.1.00"); - assert (v.string () == "0.1.00"); - assert (v.canonical_upstream == "0000000000000000.0000000000000001"); - assert (test_constructor (v)); - } - - { - version v ("0.0a.00"); - assert (v.string () == "0.0a.00"); - assert (v.canonical_upstream == "0000000000000000.0a"); - assert (test_constructor (v)); - } - - { - version v ("0.a00.00"); - assert (v.string () == "0.a00.00"); - assert (v.canonical_upstream == "0000000000000000.a00"); - assert (test_constructor (v)); - } - - { - version v ("1~0"); - assert (v.string () == "1~0"); - assert (v.canonical_upstream.empty ()); - assert (test_constructor (v)); - } - - { - version v ("0~A+1"); - assert (v.string () == "A+1"); - assert (v.canonical_upstream == "a"); - assert (test_constructor (v)); - } - - { - version v ("10~B+0"); - assert (v.string () == "10~B"); - assert (v.canonical_upstream == "b"); - assert (test_constructor (v)); - } - - { - version v ("3~1A.31.0.4.0+7"); - assert (v.string () == "3~1A.31.0.4.0+7"); - assert (v.canonical_upstream == - "1a.0000000000000031.0000000000000000.0000000000000004"); - assert (test_constructor (v)); + return true; } + } + static bool + bad_version (uint16_t e, + const string& u, + const optional& l, + uint16_t r) + { + try { - version v ("1.2.3"); - assert (v.string () == "1.2.3"); - assert (!v.release); - assert (v.canonical_release == "~"); - assert (test_constructor (v)); + version bv (e, u, l, r); + return false; } - + catch (const invalid_argument&) { - version v ("1.2.3+1"); - assert (v.string () == "1.2.3+1"); - assert (!v.release); - assert (v.canonical_release == "~"); - assert (test_constructor (v)); + return true; } + } - { - version v ("1.2.3-"); - assert (v.string () == "1.2.3-"); - assert (v.release && v.release->empty ()); - assert (v.canonical_release.empty ()); - assert (test_constructor (v)); - } + static bool + bad_version (uint16_t e, const string& u, const char* l, uint16_t r) + { + return bad_version (e, u, string (l), r); + } - { - version v ("1~A-1.2.3B.00+0"); - assert (v.string () == "1~A-1.2.3B.00"); - assert (v.release && *v.release == "1.2.3B.00"); - assert (v.canonical_release == "0000000000000001.0000000000000002.3b"); - assert (test_constructor (v)); - } + static bool + test_constructor (const version& v) + { + return v == version (v.epoch, v.upstream, v.release, v.revision); + } + int + main (int argc, char* argv[]) + { + if (argc != 1) { - version v ("65535~q.3+65535"); - assert (v.string () == "65535~q.3+65535"); - assert (!v.release); - assert (v.canonical_release == "~"); - assert (test_constructor (v)); + cerr << "usage: " << argv[0] << endl; + return 1; } + try { - version v (1, "1", nullopt, 2); - assert (v.string () == "1~1+2"); - assert (!v.release); - assert (v.canonical_release == "~"); - assert (test_constructor (v)); + assert (bad_version ("")); // Empty upstream. + assert (bad_version ("1~")); // Same. + assert (bad_version ("1~+3")); // Same. + assert (bad_version ("+3")); // Same. + assert (bad_version ("1~-a")); // Same. + assert (bad_version ("1~-a+3")); // Same. + assert (bad_version ("-a+3")); // Same. + assert (bad_version ("~3.5")); // Empty epoch. + assert (bad_version ("a+")); // Empty revision. + assert (bad_version ("1~2~4.1+3")); // Extra epoch. + assert (bad_version ("3.5+1+4")); // Extra revision. + assert (bad_version ("1~~2+3")); // Duplicated epoch separator. + assert (bad_version ("1~2++3")); // Duplicated revision separator. + assert (bad_version ("a.39485739122323231.3")); // Too long component. + assert (bad_version ("a.00000000000000000.3")); // Too many zeros. + assert (bad_version ("1-a.00000000000000000")); // Same. + assert (bad_version ("65536~q.3")); // Too big epoch. + assert (bad_version ("1+q+65536")); // Too big revision. + assert (bad_version ("3.5~1.4")); // Components in epoch. + assert (bad_version ("3.5+1.4")); // Components in revision. + assert (bad_version ("3 5+1")); // Non alpha-numeric in upstream. + assert (bad_version ("1~ +3")); // Same. + assert (bad_version ("1-3 5+1")); // Non alpha-numeric in release. + assert (bad_version ("1~1- +3")); // Same. + assert (bad_version ("3 5~4+1")); // Non alpha-numeric in epoch. + assert (bad_version ("2b~a")); // Same. + assert (bad_version ("1~34.1+3 5")); // Non numeric in revision. + assert (bad_version ("a+3s")); // Same. + assert (bad_version ("a.")); // Not completed upstream. + assert (bad_version ("a..b")); // Empty upstream component. + assert (bad_version ("a.b-+1")); // Revision for empty release. + assert (bad_version ("0.0-+3")); // Same. + assert (bad_version ("1.2.3-~")); // Invalid release. + assert (bad_version ("0-")); // Illegal version. + assert (bad_version ("0.0-")); // Same. + + assert (bad_version (0, "1", "", 1)); // Revision for empty release. + assert (bad_version (1, "1~1.1", "", 2)); // Epoch in upstream. + assert (bad_version (1, "1.1-1", "", 2)); // Release in upstream. + assert (bad_version (1, "1.1+1", "", 2)); // Revision in upstream. + assert (bad_version (1, "1", "1~1.1", 2)); // Epoch in release. + assert (bad_version (1, "1", "1.1-1", 2)); // Release in release. + assert (bad_version (1, "1", "1.1+1", 2)); // Revision in release. + + assert (bad_version (1, "", "", 0)); // Unexpected epoch. + assert (bad_version (0, "", "1", 0)); // Unexpected release. + assert (bad_version (0, "", "", 1)); // Unexpected revision. + + { + version v1; + assert (v1.empty ()); + assert (v1.canonical_upstream.empty ()); + assert (v1.canonical_release.empty ()); + + version v2 ("0.0.0"); + assert (!v2.empty ()); + assert (v1.canonical_upstream.empty ()); + assert (v2.canonical_release == "~"); + + assert (v1 != v2); + } + + { + version v ("1~0.0-"); + assert (!v.empty ()); + assert (v.string () == "1~0.0-"); + assert (v.canonical_upstream.empty ()); + assert (v.canonical_release.empty ()); + assert (test_constructor (v)); + } + + { + version v ("a"); + assert (v.string () == "a"); + assert (v.canonical_upstream == "a"); + assert (test_constructor (v)); + } + + { + version v ("65534~ab+65535"); + assert (v.string () == "65534~ab+65535"); + assert (v.canonical_upstream == "ab"); + assert (test_constructor (v)); + } + + { + version v ("1"); + assert (v.string () == "1"); + assert (v.canonical_upstream == "0000000000000001"); + assert (test_constructor (v)); + } + + { + version v ("0"); + assert (v.string () == "0"); + assert (v.canonical_upstream.empty ()); + assert (test_constructor (v)); + } + + { + version v ("0.0.0"); + assert (v.string () == "0.0.0"); + assert (v.canonical_upstream.empty ()); + assert (test_constructor (v)); + } + + { + version v ("1.0.0"); + assert (v.string () == "1.0.0"); + assert (v.canonical_upstream == "0000000000000001"); + assert (test_constructor (v)); + } + + { + version v ("0.1.00"); + assert (v.string () == "0.1.00"); + assert (v.canonical_upstream == "0000000000000000.0000000000000001"); + assert (test_constructor (v)); + } + + { + version v ("0.0a.00"); + assert (v.string () == "0.0a.00"); + assert (v.canonical_upstream == "0000000000000000.0a"); + assert (test_constructor (v)); + } + + { + version v ("0.a00.00"); + assert (v.string () == "0.a00.00"); + assert (v.canonical_upstream == "0000000000000000.a00"); + assert (test_constructor (v)); + } + + { + version v ("1~0"); + assert (v.string () == "1~0"); + assert (v.canonical_upstream.empty ()); + assert (test_constructor (v)); + } + + { + version v ("0~A+1"); + assert (v.string () == "A+1"); + assert (v.canonical_upstream == "a"); + assert (test_constructor (v)); + } + + { + version v ("10~B+0"); + assert (v.string () == "10~B"); + assert (v.canonical_upstream == "b"); + assert (test_constructor (v)); + } + + { + version v ("3~1A.31.0.4.0+7"); + assert (v.string () == "3~1A.31.0.4.0+7"); + assert (v.canonical_upstream == + "1a.0000000000000031.0000000000000000.0000000000000004"); + assert (test_constructor (v)); + } + + { + version v ("1.2.3"); + assert (v.string () == "1.2.3"); + assert (!v.release); + assert (v.canonical_release == "~"); + assert (test_constructor (v)); + } + + { + version v ("1.2.3+1"); + assert (v.string () == "1.2.3+1"); + assert (!v.release); + assert (v.canonical_release == "~"); + assert (test_constructor (v)); + } + + { + version v ("1.2.3-"); + assert (v.string () == "1.2.3-"); + assert (v.release && v.release->empty ()); + assert (v.canonical_release.empty ()); + assert (test_constructor (v)); + } + + { + version v ("1~A-1.2.3B.00+0"); + assert (v.string () == "1~A-1.2.3B.00"); + assert (v.release && *v.release == "1.2.3B.00"); + assert (v.canonical_release == "0000000000000001.0000000000000002.3b"); + assert (test_constructor (v)); + } + + { + version v ("65535~q.3+65535"); + assert (v.string () == "65535~q.3+65535"); + assert (!v.release); + assert (v.canonical_release == "~"); + assert (test_constructor (v)); + } + + { + version v (1, "1", nullopt, 2); + assert (v.string () == "1~1+2"); + assert (!v.release); + assert (v.canonical_release == "~"); + assert (test_constructor (v)); + } + + { + version v (1, "1", string (), 0); + assert (v.string () == "1~1-"); + assert (v.release && v.release->empty ()); + assert (v.canonical_release.empty ()); + assert (test_constructor (v)); + } + + assert (version ("a") == version ("a")); + assert (version ("a") < version ("b")); + assert (version ("a") < version ("aa")); + assert (version ("a.a") < version ("aaa")); + assert (version ("a") < version ("a.a")); + assert (version ("ab") == version ("ab")); + assert (version ("ac") < version ("bc")); + assert (version ("ab+0") == version ("ab")); + assert (version ("a.1+1") > version ("a.1")); + assert (version ("0~ab") == version ("ab")); + assert (version ("1.2") > version ("1.1")); + assert (version ("1~1.0") > version ("2.0")); + assert (version ("0~ab+1") == version ("ab+1")); + assert (version ("0~ab+1").compare (version ("0~ab+2"), true) == 0); + assert (version ("12") > version ("2")); + assert (version ("2") < version ("12")); + assert (version ("1") == version ("01")); + assert (version ("1") == version ("1.0")); + assert (version ("1.3") == version ("1.3.0")); + assert (version ("1.3") == version ("1.3.0.0")); + assert (version ("1.3.1") > version ("1.3")); + assert (version ("1.30") > version ("1.5")); + assert (version ("1.alpha.1") < version ("1.Beta.1")); + assert (version ("1.Alpha.1") < version ("1.beta.1")); + assert (version ("1.Alpha.1") == version ("1.ALPHA.1")); + assert (version ("a.1") < version ("ab1")); + assert (version ("a.2") < version ("a.1b")); + assert (version ("0.0.0") == version ("0")); + assert (version ("1.0.0") == version ("01")); + assert (version ("0.1.00") == version ("00.1")); + assert (version ("0.0a.00") == version ("00.0a")); + assert (version ("1.0-alpha") < version ("1.0")); + assert (version ("1.0-") < version ("1.0")); + assert (version ("1.0-") < version ("1.0-alpha")); + assert (version ("1.0-alpha") < version ("1.1")); + assert (version ("1.0-alpha+1") < version ("1.0")); + assert (version ("1.0-alpha+1") < version ("1.1")); + assert (version ("1.0-alpha") > version ("1.0-1")); + assert (version ("1.0-alpha") == version ("1.0-alpha.0")); + + assert (version (1, "2.0", nullopt, 3) == version ("1~2+3")); + assert (version (1, "2.0", string (), 0) == version ("1~2-")); + assert (version (0, "", string (), 0) == version ()); } - + catch (const exception& e) { - version v (1, "1", string (), 0); - assert (v.string () == "1~1-"); - assert (v.release && v.release->empty ()); - assert (v.canonical_release.empty ()); - assert (test_constructor (v)); + cerr << e << endl; + return 1; } - assert (version ("a") == version ("a")); - assert (version ("a") < version ("b")); - assert (version ("a") < version ("aa")); - assert (version ("a.a") < version ("aaa")); - assert (version ("a") < version ("a.a")); - assert (version ("ab") == version ("ab")); - assert (version ("ac") < version ("bc")); - assert (version ("ab+0") == version ("ab")); - assert (version ("a.1+1") > version ("a.1")); - assert (version ("0~ab") == version ("ab")); - assert (version ("1.2") > version ("1.1")); - assert (version ("1~1.0") > version ("2.0")); - assert (version ("0~ab+1") == version ("ab+1")); - assert (version ("0~ab+1").compare (version ("0~ab+2"), true) == 0); - assert (version ("12") > version ("2")); - assert (version ("2") < version ("12")); - assert (version ("1") == version ("01")); - assert (version ("1") == version ("1.0")); - assert (version ("1.3") == version ("1.3.0")); - assert (version ("1.3") == version ("1.3.0.0")); - assert (version ("1.3.1") > version ("1.3")); - assert (version ("1.30") > version ("1.5")); - assert (version ("1.alpha.1") < version ("1.Beta.1")); - assert (version ("1.Alpha.1") < version ("1.beta.1")); - assert (version ("1.Alpha.1") == version ("1.ALPHA.1")); - assert (version ("a.1") < version ("ab1")); - assert (version ("a.2") < version ("a.1b")); - assert (version ("0.0.0") == version ("0")); - assert (version ("1.0.0") == version ("01")); - assert (version ("0.1.00") == version ("00.1")); - assert (version ("0.0a.00") == version ("00.0a")); - assert (version ("1.0-alpha") < version ("1.0")); - assert (version ("1.0-") < version ("1.0")); - assert (version ("1.0-") < version ("1.0-alpha")); - assert (version ("1.0-alpha") < version ("1.1")); - assert (version ("1.0-alpha+1") < version ("1.0")); - assert (version ("1.0-alpha+1") < version ("1.1")); - assert (version ("1.0-alpha") > version ("1.0-1")); - assert (version ("1.0-alpha") == version ("1.0-alpha.0")); - - assert (version (1, "2.0", nullopt, 3) == version ("1~2+3")); - assert (version (1, "2.0", string (), 0) == version ("1~2-")); - assert (version (0, "", string (), 0) == version ()); - } - catch (const exception& e) - { - cerr << e << endl; - return 1; + return 0; } } + +int +main (int argc, char* argv[]) +{ + return bpkg::main (argc, argv); +} diff --git a/tests/repository-location/driver.cxx b/tests/repository-location/driver.cxx index a62cad3..e459cab 100644 --- a/tests/repository-location/driver.cxx +++ b/tests/repository-location/driver.cxx @@ -17,615 +17,633 @@ using namespace std; using namespace butl; -using namespace bpkg; -using butl::optional; - -static bool -bad_location (const string& l) +namespace bpkg { - try + using butl::optional; + + static bool + bad_location (const string& l) { - repository_location bl (l); - return false; + try + { + repository_location bl (l); + return false; + } + catch (const invalid_argument&) + { + return true; + } } - catch (const invalid_argument&) + + static bool + bad_location (const string& l, const repository_location& b) { - return true; + try + { + repository_location bl (l, b); + return false; + } + catch (const invalid_argument&) + { + return true; + } } -} -static bool -bad_location (const string& l, const repository_location& b) -{ - try + static string + effective_url (const string& l, const repository_location& r) { - repository_location bl (l, b); - return false; + istringstream is (":1\nurl: " + l); + manifest_parser mp (is, ""); + repository_manifest m (mp); + + optional u (m.effective_url (r)); + assert (u); + return *u; } - catch (const invalid_argument&) + + static bool + bad_url (const string& l, const repository_location& r) { + try + { + effective_url (l, r); + return false; + } + catch (const invalid_argument&) + { + } + catch (const logic_error&) + { + } return true; } -} - -static string -effective_url (const string& l, const repository_location& r) -{ - istringstream is (":1\nurl: " + l); - manifest_parser mp (is, ""); - repository_manifest m (mp); - - optional u (m.effective_url (r)); - assert (u); - return *u; -} -static bool -bad_url (const string& l, const repository_location& r) -{ - try - { - effective_url (l, r); - return false; - } - catch (const invalid_argument&) + int + main (int argc, char* argv[]) { - } - catch (const logic_error&) - { - } - return true; -} - -int -main (int argc, char* argv[]) -{ - using protocol = repository_location::protocol; + using protocol = repository_location::protocol; - if (argc != 1) - { - cerr << "usage: " << argv[0] << endl; - return 1; - } + if (argc != 1) + { + cerr << "usage: " << argv[0] << endl; + return 1; + } - try - { - // Test invalid locations. - // - // Invalid host. - // - assert (bad_location ("http:///aa/bb")); - assert (bad_location ("http://1/aa/bb")); - assert (bad_location ("http:///1/aa/bb")); - assert (bad_location ("http://1a/aa/bb")); - assert (bad_location ("http://a..a/aa/bb")); - assert (bad_location ("http://.a.a/aa/bb")); - assert (bad_location ("http://a.a./aa/bb")); - assert (bad_location ("http://a.1a/aa/bb")); - assert (bad_location ("http://a.1a.a/aa/bb")); - assert (bad_location ("http://a.-ab/aa/bb")); - assert (bad_location ("http://a.-ab.a/aa/bb")); - assert (bad_location ("http://a.ab-/aa/bb")); - assert (bad_location ("http://a.ab-.a/aa/bb")); - assert (bad_location ("http://a.ab-:80/aa/bb")); - assert (bad_location ("http://a.ab.:80/aa/bb")); - assert (bad_location ("http://1.1.1.1.r/1/b")); - assert (bad_location ("http://www./aa/1/bb")); - - assert (bad_location ("http://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" - "aaaaaaaaaaaaaaaaaaaa.org/1/b/")); - - // Invalid port. - // - assert (bad_location ("http://a:/aa/bb")); - assert (bad_location ("http://a:1b/aa/bb")); - assert (bad_location ("http://c.ru:8a80/1/b")); - assert (bad_location ("http://c.ru:8:80/1/b")); - assert (bad_location ("http://a:0/aa/bb")); - assert (bad_location ("http://c.ru:65536/1/b")); - - // Invalid path. - // - assert ( - bad_location ("", - repository_location ("http://stable.cppget.org/1/misc"))); - - assert (bad_location ("1")); - assert (bad_location ("1/")); - assert (bad_location ("1/..")); - assert (bad_location ("bbb")); - assert (bad_location ("aaa/bbb")); - assert (bad_location ("http://aa")); - assert (bad_location ("https://aa")); - assert (bad_location ("http://aa/")); - assert (bad_location ("http://aa/b/..")); - assert (bad_location ("http://aa/.")); - assert (bad_location ("http://aa/bb")); - assert (bad_location ("http://a.com/../c/1/aa")); - assert (bad_location ("http://a.com/a/b/../../../c/1/aa")); + try + { + // Test invalid locations. + // + // Invalid host. + // + assert (bad_location ("http:///aa/bb")); + assert (bad_location ("http://1/aa/bb")); + assert (bad_location ("http:///1/aa/bb")); + assert (bad_location ("http://1a/aa/bb")); + assert (bad_location ("http://a..a/aa/bb")); + assert (bad_location ("http://.a.a/aa/bb")); + assert (bad_location ("http://a.a./aa/bb")); + assert (bad_location ("http://a.1a/aa/bb")); + assert (bad_location ("http://a.1a.a/aa/bb")); + assert (bad_location ("http://a.-ab/aa/bb")); + assert (bad_location ("http://a.-ab.a/aa/bb")); + assert (bad_location ("http://a.ab-/aa/bb")); + assert (bad_location ("http://a.ab-.a/aa/bb")); + assert (bad_location ("http://a.ab-:80/aa/bb")); + assert (bad_location ("http://a.ab.:80/aa/bb")); + assert (bad_location ("http://1.1.1.1.r/1/b")); + assert (bad_location ("http://www./aa/1/bb")); + + assert ( + bad_location ("http://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" + "aaaaaaaaaaaaaaaaaaaa.org/1/b/")); + + // Invalid port. + // + assert (bad_location ("http://a:/aa/bb")); + assert (bad_location ("http://a:1b/aa/bb")); + assert (bad_location ("http://c.ru:8a80/1/b")); + assert (bad_location ("http://c.ru:8:80/1/b")); + assert (bad_location ("http://a:0/aa/bb")); + assert (bad_location ("http://c.ru:65536/1/b")); + + // Invalid path. + // + assert ( + bad_location ("", + repository_location ( + "http://stable.cppget.org/1/misc"))); + + assert (bad_location ("1")); + assert (bad_location ("1/")); + assert (bad_location ("1/..")); + assert (bad_location ("bbb")); + assert (bad_location ("aaa/bbb")); + assert (bad_location ("http://aa")); + assert (bad_location ("https://aa")); + assert (bad_location ("http://aa/")); + assert (bad_location ("http://aa/b/..")); + assert (bad_location ("http://aa/.")); + assert (bad_location ("http://aa/bb")); + assert (bad_location ("http://a.com/../c/1/aa")); + assert (bad_location ("http://a.com/a/b/../../../c/1/aa")); #ifndef _WIN32 - assert (bad_location ("/aaa/bbb")); + assert (bad_location ("/aaa/bbb")); #else - assert (bad_location ("c:\\aaa\\bbb")); + assert (bad_location ("c:\\aaa\\bbb")); #endif - // Invalid version. - // - assert (bad_location ("3/aaa/bbb")); + // Invalid version. + // + assert (bad_location ("3/aaa/bbb")); - // Invalid prerequisite repository location. - // - assert (bad_location ("a/c/1/bb")); + // Invalid prerequisite repository location. + // + assert (bad_location ("a/c/1/bb")); - assert (bad_location ("a/c/1/bb", - repository_location ("./var/1/stable", - repository_location ()))); + assert (bad_location ("a/c/1/bb", + repository_location ("./var/1/stable", + repository_location ()))); - assert (bad_location ("../../../1/math", - repository_location ( - "http://stable.cppget.org/1/misc"))); + assert (bad_location ("../../../1/math", + repository_location ( + "http://stable.cppget.org/1/misc"))); - assert (bad_location ("../..", - repository_location ( - "http://stable.cppget.org/1/misc"))); + assert (bad_location ("../..", + repository_location ( + "http://stable.cppget.org/1/misc"))); - // Invalid web interface URL. - // - assert (bad_url (".a/..", - repository_location ( - "http://stable.cppget.org/1/misc"))); + // Invalid web interface URL. + // + assert (bad_url (".a/..", + repository_location ( + "http://stable.cppget.org/1/misc"))); - assert (bad_url ("../a/..", - repository_location ( - "http://stable.cppget.org/1/misc"))); + assert (bad_url ("../a/..", + repository_location ( + "http://stable.cppget.org/1/misc"))); - assert (bad_url ("../.a", - repository_location ( - "http://stable.cppget.org/1/misc"))); + assert (bad_url ("../.a", + repository_location ( + "http://stable.cppget.org/1/misc"))); #ifndef _WIN32 - assert (bad_url ("../../..", - repository_location ( - "/var/1/misc"))); + assert (bad_url ("../../..", + repository_location ( + "/var/1/misc"))); - assert (bad_url ("../../..", - repository_location ( - "/var/pkg/1/misc"))); + assert (bad_url ("../../..", + repository_location ( + "/var/pkg/1/misc"))); #else - assert (bad_url ("..\\..\\..", - repository_location ( - "c:\\var\\1\\misc"))); + assert (bad_url ("..\\..\\..", + repository_location ( + "c:\\var\\1\\misc"))); - assert (bad_url ("..\\..\\..", - repository_location ( - "c:\\var\\pkg\\1\\misc"))); + assert (bad_url ("..\\..\\..", + repository_location ( + "c:\\var\\pkg\\1\\misc"))); #endif - assert (bad_url ("../../..", repository_location ())); + assert (bad_url ("../../..", repository_location ())); - assert (bad_url ("../../../../..", - repository_location ( - "http://pkg.stable.cppget.org/foo/pkg/1/misc"))); + assert (bad_url ("../../../../..", + repository_location ( + "http://pkg.stable.cppget.org/foo/pkg/1/misc"))); - assert (bad_url ("../../../../../abc", - repository_location ( - "http://stable.cppget.org/foo/1/misc"))); + assert (bad_url ("../../../../../abc", + repository_location ( + "http://stable.cppget.org/foo/1/misc"))); - // Test valid locations. - // - { - repository_location l (""); - assert (l.string ().empty ()); - assert (l.canonical_name ().empty ()); - } - { - repository_location l ("1/aa/bb", repository_location ()); - assert (l.string () == "1/aa/bb"); - - // Relative locations have no canonical name. + // Test valid locations. // - assert (l.canonical_name ().empty ()); - } - { - repository_location l ("bpkg/1/aa/bb", repository_location ()); - assert (l.string () == "bpkg/1/aa/bb"); - assert (l.canonical_name ().empty ()); - } - { - repository_location l ("b/pkg/1/aa/bb", repository_location ()); - assert (l.string () == "b/pkg/1/aa/bb"); - assert (l.canonical_name ().empty ()); - } - { - repository_location l ("aa/..", repository_location ()); - assert (l.string () == "."); - assert (l.canonical_name ().empty ()); - } + { + repository_location l (""); + assert (l.string ().empty ()); + assert (l.canonical_name ().empty ()); + } + { + repository_location l ("1/aa/bb", repository_location ()); + assert (l.string () == "1/aa/bb"); + + // Relative locations have no canonical name. + // + assert (l.canonical_name ().empty ()); + } + { + repository_location l ("bpkg/1/aa/bb", repository_location ()); + assert (l.string () == "bpkg/1/aa/bb"); + assert (l.canonical_name ().empty ()); + } + { + repository_location l ("b/pkg/1/aa/bb", repository_location ()); + assert (l.string () == "b/pkg/1/aa/bb"); + assert (l.canonical_name ().empty ()); + } + { + repository_location l ("aa/..", repository_location ()); + assert (l.string () == "."); + assert (l.canonical_name ().empty ()); + } #ifndef _WIN32 - { - repository_location l ("/1/aa/bb", repository_location ()); - assert (l.string () == "/1/aa/bb"); - assert (l.canonical_name () == "/aa/bb"); - } - { - repository_location l ("/pkg/1/aa/bb", repository_location ()); - assert (l.string () == "/pkg/1/aa/bb"); - assert (l.canonical_name () == "aa/bb"); - } - { - repository_location l ("/var/bpkg/1", repository_location ()); - assert (l.string () == "/var/bpkg/1"); - assert (l.canonical_name () == "/var/bpkg"); - } - { - repository_location l ("/1", repository_location ()); - assert (l.string () == "/1"); - assert (l.canonical_name () == "/"); - } - { - repository_location l ("/var/pkg/1/example.org/math/testing", - repository_location ()); - assert (l.string () == "/var/pkg/1/example.org/math/testing"); - assert (l.canonical_name () == "example.org/math/testing"); - } - { - repository_location l ("/var/pkg/example.org/1/math/testing", - repository_location ()); - assert (l.string () == "/var/pkg/example.org/1/math/testing"); - assert (l.canonical_name () == "/var/pkg/example.org/math/testing"); - } - { - repository_location l ("/a/b/../c/1/aa/../bb", repository_location ()); - assert (l.string () == "/a/c/1/bb"); - assert (l.canonical_name () == "/a/c/bb"); - } - { - repository_location l ("/a/b/../c/pkg/1/aa/../bb", - repository_location ()); - assert (l.string () == "/a/c/pkg/1/bb"); - assert (l.canonical_name () == "bb"); - } + { + repository_location l ("/1/aa/bb", repository_location ()); + assert (l.string () == "/1/aa/bb"); + assert (l.canonical_name () == "/aa/bb"); + } + { + repository_location l ("/pkg/1/aa/bb", repository_location ()); + assert (l.string () == "/pkg/1/aa/bb"); + assert (l.canonical_name () == "aa/bb"); + } + { + repository_location l ("/var/bpkg/1", repository_location ()); + assert (l.string () == "/var/bpkg/1"); + assert (l.canonical_name () == "/var/bpkg"); + } + { + repository_location l ("/1", repository_location ()); + assert (l.string () == "/1"); + assert (l.canonical_name () == "/"); + } + { + repository_location l ("/var/pkg/1/example.org/math/testing", + repository_location ()); + assert (l.string () == "/var/pkg/1/example.org/math/testing"); + assert (l.canonical_name () == "example.org/math/testing"); + } + { + repository_location l ("/var/pkg/example.org/1/math/testing", + repository_location ()); + assert (l.string () == "/var/pkg/example.org/1/math/testing"); + assert (l.canonical_name () == "/var/pkg/example.org/math/testing"); + } + { + repository_location l ("/a/b/../c/1/aa/../bb", repository_location ()); + assert (l.string () == "/a/c/1/bb"); + assert (l.canonical_name () == "/a/c/bb"); + } + { + repository_location l ("/a/b/../c/pkg/1/aa/../bb", + repository_location ()); + assert (l.string () == "/a/c/pkg/1/bb"); + assert (l.canonical_name () == "bb"); + } #else - { - repository_location l ("c:\\1\\aa\\bb", repository_location ()); - assert (l.string () == "c:\\1\\aa\\bb"); - assert (l.canonical_name () == "c:\\aa\\bb"); - } - { - repository_location l ("c:/1/aa/bb", repository_location ()); - assert (l.string () == "c:\\1\\aa\\bb"); - assert (l.canonical_name () == "c:\\aa\\bb"); - } - { - repository_location l ("c:\\pkg\\1\\aa\\bb", repository_location ()); - assert (l.string () == "c:\\pkg\\1\\aa\\bb"); - assert (l.canonical_name () == "aa/bb"); - } - { - repository_location l ("c:\\var\\pkg\\1\\example.org\\math\\testing", - repository_location ()); - assert (l.string () == "c:\\var\\pkg\\1\\example.org\\math\\testing"); - assert (l.canonical_name () == "example.org/math/testing"); - } - { - repository_location l ("c:\\var\\pkg\\example.org\\1\\math\\testing", - repository_location ()); - assert (l.string () == "c:\\var\\pkg\\example.org\\1\\math\\testing"); - - assert (l.canonical_name () == - "c:\\var\\pkg\\example.org\\math\\testing"); - } - { - repository_location l ("c:/a/b/../c/1/aa/../bb", repository_location ()); - assert (l.string () == "c:\\a\\c\\1\\bb"); - assert (l.canonical_name () == "c:\\a\\c\\bb"); - } - { - repository_location l ("c:/a/b/../c/pkg/1/aa/../bb", - repository_location ()); - assert (l.string () == "c:\\a\\c\\pkg\\1\\bb"); - assert (l.canonical_name () == "bb"); - } + { + repository_location l ("c:\\1\\aa\\bb", repository_location ()); + assert (l.string () == "c:\\1\\aa\\bb"); + assert (l.canonical_name () == "c:\\aa\\bb"); + } + { + repository_location l ("c:/1/aa/bb", repository_location ()); + assert (l.string () == "c:\\1\\aa\\bb"); + assert (l.canonical_name () == "c:\\aa\\bb"); + } + { + repository_location l ("c:\\pkg\\1\\aa\\bb", repository_location ()); + assert (l.string () == "c:\\pkg\\1\\aa\\bb"); + assert (l.canonical_name () == "aa/bb"); + } + { + repository_location l ("c:\\var\\pkg\\1\\example.org\\math\\testing", + repository_location ()); + assert (l.string () == "c:\\var\\pkg\\1\\example.org\\math\\testing"); + assert (l.canonical_name () == "example.org/math/testing"); + } + { + repository_location l ("c:\\var\\pkg\\example.org\\1\\math\\testing", + repository_location ()); + assert (l.string () == "c:\\var\\pkg\\example.org\\1\\math\\testing"); + + assert (l.canonical_name () == + "c:\\var\\pkg\\example.org\\math\\testing"); + } + { + repository_location l ("c:/a/b/../c/1/aa/../bb", + repository_location ()); + + assert (l.string () == "c:\\a\\c\\1\\bb"); + assert (l.canonical_name () == "c:\\a\\c\\bb"); + } + { + repository_location l ("c:/a/b/../c/pkg/1/aa/../bb", + repository_location ()); + assert (l.string () == "c:\\a\\c\\pkg\\1\\bb"); + assert (l.canonical_name () == "bb"); + } #endif - { - repository_location l ("../c/../c/./1/aa/../bb", - repository_location ()); - assert (l.string () == "../c/1/bb"); - assert (l.canonical_name ().empty ()); - } - { - repository_location l ("http://www.a.com:80/1/aa/bb"); - assert (l.string () == "http://www.a.com:80/1/aa/bb"); - assert (l.canonical_name () == "a.com/aa/bb"); - assert (l.proto () == protocol::http); - } - { - repository_location l ("https://www.a.com:443/1/aa/bb"); - assert (l.string () == "https://www.a.com:443/1/aa/bb"); - assert (l.canonical_name () == "a.com/aa/bb"); - assert (l.proto () == protocol::https); - } - { - repository_location l ("http://www.a.com:8080/dd/1/aa/bb"); - assert (l.string () == "http://www.a.com:8080/dd/1/aa/bb"); - assert (l.canonical_name () == "a.com:8080/dd/aa/bb"); - assert (l.proto () == protocol::http); - } - { - repository_location l ("http://www.a.com:8080/dd/pkg/1/aa/bb"); - assert (l.string () == "http://www.a.com:8080/dd/pkg/1/aa/bb"); - assert (l.canonical_name () == "a.com:8080/dd/aa/bb"); - assert (l.proto () == protocol::http); - } - { - repository_location l ("http://www.a.com:8080/bpkg/dd/1/aa/bb"); - assert (l.string () == "http://www.a.com:8080/bpkg/dd/1/aa/bb"); - assert (l.canonical_name () == "a.com:8080/bpkg/dd/aa/bb"); - assert (l.proto () == protocol::http); - } - { - repository_location l ("https://www.a.com:444/dd/1/aa/bb"); - assert (l.string () == "https://www.a.com:444/dd/1/aa/bb"); - assert (l.canonical_name () == "a.com:444/dd/aa/bb"); - assert (l.proto () == protocol::https); - } - { - repository_location l ("http://a.com/a/b/../c/1/aa/../bb"); - assert (l.string () == "http://a.com/a/c/1/bb"); - assert (l.canonical_name () == "a.com/a/c/bb"); - } - { - repository_location l ("https://a.com/a/b/../c/1/aa/../bb"); - assert (l.string () == "https://a.com/a/c/1/bb"); - assert (l.canonical_name () == "a.com/a/c/bb"); - } - { - repository_location l ("http://www.CPPget.org/qw/1/a/b/"); - assert (l.string () == "http://www.cppget.org/qw/1/a/b"); - assert (l.canonical_name () == "cppget.org/qw/a/b"); - } - { - repository_location l ("http://pkg.CPPget.org/qw/1/a/b/"); - assert (l.string () == "http://pkg.cppget.org/qw/1/a/b"); - assert (l.canonical_name () == "cppget.org/qw/a/b"); - } - { - repository_location l ("http://bpkg.CPPget.org/qw/1/a/b/"); - assert (l.string () == "http://bpkg.cppget.org/qw/1/a/b"); - assert (l.canonical_name () == "cppget.org/qw/a/b"); - } - { - repository_location l ("http://abc.cppget.org/qw/1/a/b/"); - assert (l.string () == "http://abc.cppget.org/qw/1/a/b"); - assert (l.canonical_name () == "abc.cppget.org/qw/a/b"); - } - { - repository_location l ("http://pkg.www.cppget.org/qw/1/a/b/"); - assert (l.string () == "http://pkg.www.cppget.org/qw/1/a/b"); - assert (l.canonical_name () == "www.cppget.org/qw/a/b"); - } - { - repository_location l ("http://bpkg.www.cppget.org/qw/1/a/b/"); - assert (l.string () == "http://bpkg.www.cppget.org/qw/1/a/b"); - assert (l.canonical_name () == "www.cppget.org/qw/a/b"); - } - { - repository_location l ("http://cppget.org/qw//1/a//b/"); - assert (l.string () == "http://cppget.org/qw/1/a/b"); - assert (l.canonical_name () == "cppget.org/qw/a/b"); - } - { - repository_location l ("http://stable.cppget.org/1/"); - assert (l.canonical_name () == "stable.cppget.org"); - } - { - repository_location l1 ("http://stable.cppget.org/1/misc"); - repository_location l2 ("../../1/math", l1); - assert (l2.string () == "http://stable.cppget.org/1/math"); - assert (l2.canonical_name () == "stable.cppget.org/math"); - } - { - repository_location l1 ("http://stable.cppget.org/1/misc"); - repository_location l2 ("../../pkg/1/math", l1); - assert (l2.string () == "http://stable.cppget.org/pkg/1/math"); - assert (l2.canonical_name () == "stable.cppget.org/math"); - } - { - repository_location l1 ("https://stable.cppget.org/1/misc"); - repository_location l2 ("../../1/math", l1); - assert (l2.string () == "https://stable.cppget.org/1/math"); - assert (l2.canonical_name () == "stable.cppget.org/math"); - } - { - repository_location l1 ("http://stable.cppget.org/1/misc"); - repository_location l2 ("../math", l1); - assert (l2.string () == "http://stable.cppget.org/1/math"); - assert (l2.canonical_name () == "stable.cppget.org/math"); - } - { - repository_location l1 ("http://stable.cppget.org/1/misc"); - repository_location l2 ("math/..", l1); - assert (l2.string () == "http://stable.cppget.org/1/misc"); - assert (l2.canonical_name () == "stable.cppget.org/misc"); - } - { - repository_location l1 ("http://stable.cppget.org/1/misc"); - repository_location l2 (".", l1); - assert (l2.string () == "http://stable.cppget.org/1/misc"); - assert (l2.canonical_name () == "stable.cppget.org/misc"); - } - { - repository_location l1 ("http://www.stable.cppget.org:8080/1"); - repository_location l2 ("../1/math", l1); - assert (l2.string () == "http://www.stable.cppget.org:8080/1/math"); - assert (l2.canonical_name () == "stable.cppget.org:8080/math"); - assert (l2.proto () == protocol::http); - } - { - repository_location l1 ("https://www.stable.cppget.org:444/1"); - repository_location l2 ("../1/math", l1); - assert (l2.string () == "https://www.stable.cppget.org:444/1/math"); - assert (l2.canonical_name () == "stable.cppget.org:444/math"); - assert (l2.proto () == protocol::https); - } + { + repository_location l ("../c/../c/./1/aa/../bb", + repository_location ()); + assert (l.string () == "../c/1/bb"); + assert (l.canonical_name ().empty ()); + } + { + repository_location l ("http://www.a.com:80/1/aa/bb"); + assert (l.string () == "http://www.a.com:80/1/aa/bb"); + assert (l.canonical_name () == "a.com/aa/bb"); + assert (l.proto () == protocol::http); + } + { + repository_location l ("https://www.a.com:443/1/aa/bb"); + assert (l.string () == "https://www.a.com:443/1/aa/bb"); + assert (l.canonical_name () == "a.com/aa/bb"); + assert (l.proto () == protocol::https); + } + { + repository_location l ("http://www.a.com:8080/dd/1/aa/bb"); + assert (l.string () == "http://www.a.com:8080/dd/1/aa/bb"); + assert (l.canonical_name () == "a.com:8080/dd/aa/bb"); + assert (l.proto () == protocol::http); + } + { + repository_location l ("http://www.a.com:8080/dd/pkg/1/aa/bb"); + assert (l.string () == "http://www.a.com:8080/dd/pkg/1/aa/bb"); + assert (l.canonical_name () == "a.com:8080/dd/aa/bb"); + assert (l.proto () == protocol::http); + } + { + repository_location l ("http://www.a.com:8080/bpkg/dd/1/aa/bb"); + assert (l.string () == "http://www.a.com:8080/bpkg/dd/1/aa/bb"); + assert (l.canonical_name () == "a.com:8080/bpkg/dd/aa/bb"); + assert (l.proto () == protocol::http); + } + { + repository_location l ("https://www.a.com:444/dd/1/aa/bb"); + assert (l.string () == "https://www.a.com:444/dd/1/aa/bb"); + assert (l.canonical_name () == "a.com:444/dd/aa/bb"); + assert (l.proto () == protocol::https); + } + { + repository_location l ("http://a.com/a/b/../c/1/aa/../bb"); + assert (l.string () == "http://a.com/a/c/1/bb"); + assert (l.canonical_name () == "a.com/a/c/bb"); + } + { + repository_location l ("https://a.com/a/b/../c/1/aa/../bb"); + assert (l.string () == "https://a.com/a/c/1/bb"); + assert (l.canonical_name () == "a.com/a/c/bb"); + } + { + repository_location l ("http://www.CPPget.org/qw/1/a/b/"); + assert (l.string () == "http://www.cppget.org/qw/1/a/b"); + assert (l.canonical_name () == "cppget.org/qw/a/b"); + } + { + repository_location l ("http://pkg.CPPget.org/qw/1/a/b/"); + assert (l.string () == "http://pkg.cppget.org/qw/1/a/b"); + assert (l.canonical_name () == "cppget.org/qw/a/b"); + } + { + repository_location l ("http://bpkg.CPPget.org/qw/1/a/b/"); + assert (l.string () == "http://bpkg.cppget.org/qw/1/a/b"); + assert (l.canonical_name () == "cppget.org/qw/a/b"); + } + { + repository_location l ("http://abc.cppget.org/qw/1/a/b/"); + assert (l.string () == "http://abc.cppget.org/qw/1/a/b"); + assert (l.canonical_name () == "abc.cppget.org/qw/a/b"); + } + { + repository_location l ("http://pkg.www.cppget.org/qw/1/a/b/"); + assert (l.string () == "http://pkg.www.cppget.org/qw/1/a/b"); + assert (l.canonical_name () == "www.cppget.org/qw/a/b"); + } + { + repository_location l ("http://bpkg.www.cppget.org/qw/1/a/b/"); + assert (l.string () == "http://bpkg.www.cppget.org/qw/1/a/b"); + assert (l.canonical_name () == "www.cppget.org/qw/a/b"); + } + { + repository_location l ("http://cppget.org/qw//1/a//b/"); + assert (l.string () == "http://cppget.org/qw/1/a/b"); + assert (l.canonical_name () == "cppget.org/qw/a/b"); + } + { + repository_location l ("http://stable.cppget.org/1/"); + assert (l.canonical_name () == "stable.cppget.org"); + } + { + repository_location l1 ("http://stable.cppget.org/1/misc"); + repository_location l2 ("../../1/math", l1); + assert (l2.string () == "http://stable.cppget.org/1/math"); + assert (l2.canonical_name () == "stable.cppget.org/math"); + } + { + repository_location l1 ("http://stable.cppget.org/1/misc"); + repository_location l2 ("../../pkg/1/math", l1); + assert (l2.string () == "http://stable.cppget.org/pkg/1/math"); + assert (l2.canonical_name () == "stable.cppget.org/math"); + } + { + repository_location l1 ("https://stable.cppget.org/1/misc"); + repository_location l2 ("../../1/math", l1); + assert (l2.string () == "https://stable.cppget.org/1/math"); + assert (l2.canonical_name () == "stable.cppget.org/math"); + } + { + repository_location l1 ("http://stable.cppget.org/1/misc"); + repository_location l2 ("../math", l1); + assert (l2.string () == "http://stable.cppget.org/1/math"); + assert (l2.canonical_name () == "stable.cppget.org/math"); + } + { + repository_location l1 ("http://stable.cppget.org/1/misc"); + repository_location l2 ("math/..", l1); + assert (l2.string () == "http://stable.cppget.org/1/misc"); + assert (l2.canonical_name () == "stable.cppget.org/misc"); + } + { + repository_location l1 ("http://stable.cppget.org/1/misc"); + repository_location l2 (".", l1); + assert (l2.string () == "http://stable.cppget.org/1/misc"); + assert (l2.canonical_name () == "stable.cppget.org/misc"); + } + { + repository_location l1 ("http://www.stable.cppget.org:8080/1"); + repository_location l2 ("../1/math", l1); + assert (l2.string () == "http://www.stable.cppget.org:8080/1/math"); + assert (l2.canonical_name () == "stable.cppget.org:8080/math"); + assert (l2.proto () == protocol::http); + } + { + repository_location l1 ("https://www.stable.cppget.org:444/1"); + repository_location l2 ("../1/math", l1); + assert (l2.string () == "https://www.stable.cppget.org:444/1/math"); + assert (l2.canonical_name () == "stable.cppget.org:444/math"); + assert (l2.proto () == protocol::https); + } #ifndef _WIN32 - { - repository_location l1 ("/var/r1/1/misc"); - repository_location l2 ("../../../r2/1/math", l1); - assert (l2.string () == "/var/r2/1/math"); - assert (l2.canonical_name () == "/var/r2/math"); - } - { - repository_location l1 ("/var/1/misc"); - repository_location l2 ("../math", l1); - assert (l2.string () == "/var/1/math"); - assert (l2.canonical_name () == "/var/math"); - } - { - repository_location l1 ("/var/1/stable"); - repository_location l2 ("/var/1/test", l1); - assert (l2.string () == "/var/1/test"); - assert (l2.canonical_name () == "/var/test"); - } - { - repository_location l1 ("http://stable.cppget.org/1/misc"); - repository_location l2 ("/var/1/test", l1); - assert (l2.string () == "/var/1/test"); - assert (l2.canonical_name () == "/var/test"); - } - { - repository_location l1 ("/var/1/stable"); - repository_location l2 ("/var/1/stable", repository_location ()); - assert (l1.string () == l2.string ()); - assert (l1.canonical_name () == l2.canonical_name ()); - } + { + repository_location l1 ("/var/r1/1/misc"); + repository_location l2 ("../../../r2/1/math", l1); + assert (l2.string () == "/var/r2/1/math"); + assert (l2.canonical_name () == "/var/r2/math"); + } + { + repository_location l1 ("/var/1/misc"); + repository_location l2 ("../math", l1); + assert (l2.string () == "/var/1/math"); + assert (l2.canonical_name () == "/var/math"); + } + { + repository_location l1 ("/var/1/stable"); + repository_location l2 ("/var/1/test", l1); + assert (l2.string () == "/var/1/test"); + assert (l2.canonical_name () == "/var/test"); + } + { + repository_location l1 ("http://stable.cppget.org/1/misc"); + repository_location l2 ("/var/1/test", l1); + assert (l2.string () == "/var/1/test"); + assert (l2.canonical_name () == "/var/test"); + } + { + repository_location l1 ("/var/1/stable"); + repository_location l2 ("/var/1/stable", repository_location ()); + assert (l1.string () == l2.string ()); + assert (l1.canonical_name () == l2.canonical_name ()); + } #else - { - repository_location l1 ("c:/var/r1/1/misc"); - repository_location l2 ("../../../r2/1/math", l1); - assert (l2.string () == "c:\\var\\r2\\1\\math"); - assert (l2.canonical_name () == "c:\\var\\r2\\math"); - } - { - repository_location l1 ("c:/var/1/misc"); - repository_location l2 ("../math", l1); - assert (l2.string () == "c:\\var\\1\\math"); - assert (l2.canonical_name () == "c:\\var\\math"); - } - { - repository_location l1 ("c:/var/1/stable"); - repository_location l2 ("c:\\var\\1\\test", l1); - assert (l2.string () == "c:\\var\\1\\test"); - assert (l2.canonical_name () == "c:\\var\\test"); - } - { - repository_location l1 ("http://stable.cppget.org/1/misc"); - repository_location l2 ("c:/var/1/test", l1); - assert (l2.string () == "c:\\var\\1\\test"); - assert (l2.canonical_name () == "c:\\var\\test"); - } - { - repository_location l1 ("c:/var/1/stable"); - repository_location l2 ("c:/var/1/stable", repository_location ()); - assert (l1.string () == l2.string ()); - assert (l1.canonical_name () == l2.canonical_name ()); - } + { + repository_location l1 ("c:/var/r1/1/misc"); + repository_location l2 ("../../../r2/1/math", l1); + assert (l2.string () == "c:\\var\\r2\\1\\math"); + assert (l2.canonical_name () == "c:\\var\\r2\\math"); + } + { + repository_location l1 ("c:/var/1/misc"); + repository_location l2 ("../math", l1); + assert (l2.string () == "c:\\var\\1\\math"); + assert (l2.canonical_name () == "c:\\var\\math"); + } + { + repository_location l1 ("c:/var/1/stable"); + repository_location l2 ("c:\\var\\1\\test", l1); + assert (l2.string () == "c:\\var\\1\\test"); + assert (l2.canonical_name () == "c:\\var\\test"); + } + { + repository_location l1 ("http://stable.cppget.org/1/misc"); + repository_location l2 ("c:/var/1/test", l1); + assert (l2.string () == "c:\\var\\1\\test"); + assert (l2.canonical_name () == "c:\\var\\test"); + } + { + repository_location l1 ("c:/var/1/stable"); + repository_location l2 ("c:/var/1/stable", repository_location ()); + assert (l1.string () == l2.string ()); + assert (l1.canonical_name () == l2.canonical_name ()); + } #endif - { - repository_location l1 ("http://www.cppget.org/1/stable"); - repository_location l2 ("http://abc.com/1/test", l1); - assert (l2.string () == "http://abc.com/1/test"); - assert (l2.canonical_name () == "abc.com/test"); - } - { - repository_location l1 ("http://stable.cppget.org/1/"); - repository_location l2 ("http://stable.cppget.org/1/", - repository_location ()); - assert (l1.string () == l2.string ()); - assert (l1.canonical_name () == l2.canonical_name ()); - } - - // Test valid web interface locations. - // - { - repository_location l ("http://cppget.org/1/misc"); - assert (effective_url ("http://cppget.org/pkg", l) == - "http://cppget.org/pkg"); - } - { - repository_location l ("http://cppget.org/1/misc"); - assert (effective_url ("https://cppget.org/pkg", l) == - "https://cppget.org/pkg"); - } - { - repository_location l ("http://pkg.cppget.org/foo/pkg/1/misc/stable"); - assert (effective_url ("./.", l) == - "http://pkg.cppget.org/foo/pkg/misc/stable"); - } - { - repository_location l ("http://cppget.org/foo/1/misc/stable"); - assert (effective_url ("./.", l) == - "http://cppget.org/foo/misc/stable"); - } - { - repository_location l ("http://pkg.cppget.org/foo/pkg/1/misc/stable"); - assert (effective_url ("././..", l) == - "http://pkg.cppget.org/foo/pkg/misc"); - } - { - repository_location l ("http://pkg.cppget.org/foo/pkg/1/misc"); - assert (effective_url ("././../../..", l) == "http://pkg.cppget.org"); - } - { - repository_location l ("https://pkg.cppget.org/foo/pkg/1/misc/stable"); - assert (effective_url ("../.", l) == - "https://cppget.org/foo/pkg/misc/stable"); - } - { - repository_location l ("https://pkg.cppget.org/foo/pkg/1/misc/stable"); - assert (effective_url (".././..", l) == - "https://cppget.org/foo/pkg/misc"); - } - { - repository_location l ("https://bpkg.cppget.org/foo/bpkg/1/misc/stable"); - assert (effective_url ("./..", l) == - "https://bpkg.cppget.org/foo/misc/stable"); - } - { - repository_location l ("https://bpkg.cppget.org/foo/bpkg/1/misc/stable"); - assert (effective_url ("./../..", l) == - "https://bpkg.cppget.org/foo/misc"); - } - { - repository_location l ("http://www.cppget.org/foo/bpkg/1/misc/stable"); - assert (effective_url ("../..", l) == - "http://cppget.org/foo/misc/stable"); - } - { - repository_location l ("http://cppget.org/pkg/foo/1/misc/stable"); - assert (effective_url ("../..", l) == - "http://cppget.org/pkg/foo/misc/stable"); - } - { - repository_location l ("http://www.cppget.org/foo/bpkg/1/misc/stable"); - assert (effective_url ("../../..", l) == - "http://cppget.org/foo/misc"); - } - { - repository_location l ("http://pkg.cppget.org/foo/pkg/1/misc"); - assert (effective_url ("../../../..", l) == "http://cppget.org"); - } - { - repository_location l ("http://www.cppget.org/foo/bpkg/1/misc/stable"); - assert (effective_url ("../../../abc", l) == - "http://cppget.org/foo/misc/abc"); - } - } - catch (const exception& e) - { - cerr << e << endl; - return 1; + { + repository_location l1 ("http://www.cppget.org/1/stable"); + repository_location l2 ("http://abc.com/1/test", l1); + assert (l2.string () == "http://abc.com/1/test"); + assert (l2.canonical_name () == "abc.com/test"); + } + { + repository_location l1 ("http://stable.cppget.org/1/"); + repository_location l2 ("http://stable.cppget.org/1/", + repository_location ()); + assert (l1.string () == l2.string ()); + assert (l1.canonical_name () == l2.canonical_name ()); + } + + // Test valid web interface locations. + // + { + repository_location l ("http://cppget.org/1/misc"); + assert (effective_url ("http://cppget.org/pkg", l) == + "http://cppget.org/pkg"); + } + { + repository_location l ("http://cppget.org/1/misc"); + assert (effective_url ("https://cppget.org/pkg", l) == + "https://cppget.org/pkg"); + } + { + repository_location l ("http://pkg.cppget.org/foo/pkg/1/misc/stable"); + assert (effective_url ("./.", l) == + "http://pkg.cppget.org/foo/pkg/misc/stable"); + } + { + repository_location l ("http://cppget.org/foo/1/misc/stable"); + assert (effective_url ("./.", l) == + "http://cppget.org/foo/misc/stable"); + } + { + repository_location l ("http://pkg.cppget.org/foo/pkg/1/misc/stable"); + assert (effective_url ("././..", l) == + "http://pkg.cppget.org/foo/pkg/misc"); + } + { + repository_location l ("http://pkg.cppget.org/foo/pkg/1/misc"); + assert (effective_url ("././../../..", l) == "http://pkg.cppget.org"); + } + { + repository_location l ("https://pkg.cppget.org/foo/pkg/1/misc/stable"); + assert (effective_url ("../.", l) == + "https://cppget.org/foo/pkg/misc/stable"); + } + { + repository_location l ("https://pkg.cppget.org/foo/pkg/1/misc/stable"); + assert (effective_url (".././..", l) == + "https://cppget.org/foo/pkg/misc"); + } + { + repository_location l ( + "https://bpkg.cppget.org/foo/bpkg/1/misc/stable"); + + assert (effective_url ("./..", l) == + "https://bpkg.cppget.org/foo/misc/stable"); + } + { + repository_location l ( + "https://bpkg.cppget.org/foo/bpkg/1/misc/stable"); + + assert (effective_url ("./../..", l) == + "https://bpkg.cppget.org/foo/misc"); + } + { + repository_location l ("http://www.cppget.org/foo/bpkg/1/misc/stable"); + assert (effective_url ("../..", l) == + "http://cppget.org/foo/misc/stable"); + } + { + repository_location l ("http://cppget.org/pkg/foo/1/misc/stable"); + assert (effective_url ("../..", l) == + "http://cppget.org/pkg/foo/misc/stable"); + } + { + repository_location l ("http://www.cppget.org/foo/bpkg/1/misc/stable"); + assert (effective_url ("../../..", l) == + "http://cppget.org/foo/misc"); + } + { + repository_location l ("http://pkg.cppget.org/foo/pkg/1/misc"); + assert (effective_url ("../../../..", l) == "http://cppget.org"); + } + { + repository_location l ("http://www.cppget.org/foo/bpkg/1/misc/stable"); + assert (effective_url ("../../../abc", l) == + "http://cppget.org/foo/misc/abc"); + } + } + catch (const exception& e) + { + cerr << e << endl; + return 1; + } + + return 0; } } + +int +main (int argc, char* argv[]) +{ + return bpkg::main (argc, argv); +} -- cgit v1.1