blob: b182e46d6b74460e396285d34434021daeb3f957 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
#include <catch2/catch.hpp>
#include <vcpkg/base/downloads.h>
using namespace vcpkg;
TEST_CASE ("Downloads::details::split_uri_view", "[downloads]")
{
{
auto x = Downloads::details::split_uri_view("https://github.com/Microsoft/vcpkg");
REQUIRE(x.has_value());
REQUIRE(x.get()->scheme == "https");
REQUIRE(x.get()->authority.value_or("") == "//github.com");
REQUIRE(x.get()->path_query_fragment == "/Microsoft/vcpkg");
}
{
auto x = Downloads::details::split_uri_view("");
REQUIRE(!x.has_value());
}
{
auto x = Downloads::details::split_uri_view("hello");
REQUIRE(!x.has_value());
}
{
auto x = Downloads::details::split_uri_view("file:");
REQUIRE(x.has_value());
REQUIRE(x.get()->scheme == "file");
REQUIRE(!x.get()->authority.has_value());
REQUIRE(x.get()->path_query_fragment == "");
}
{
auto x = Downloads::details::split_uri_view("file:path");
REQUIRE(x.has_value());
REQUIRE(x.get()->scheme == "file");
REQUIRE(!x.get()->authority.has_value());
REQUIRE(x.get()->path_query_fragment == "path");
}
{
auto x = Downloads::details::split_uri_view("file:/path");
REQUIRE(x.has_value());
REQUIRE(x.get()->scheme == "file");
REQUIRE(!x.get()->authority.has_value());
REQUIRE(x.get()->path_query_fragment == "/path");
}
{
auto x = Downloads::details::split_uri_view("file://user:pw@host");
REQUIRE(x.has_value());
REQUIRE(x.get()->scheme == "file");
REQUIRE(x.get()->authority.value_or({}) == "//user:pw@host");
REQUIRE(x.get()->path_query_fragment == "");
}
{
auto x = Downloads::details::split_uri_view("ftp://host:port/");
REQUIRE(x.has_value());
REQUIRE(x.get()->scheme == "ftp");
REQUIRE(x.get()->authority.value_or({}) == "//host:port");
REQUIRE(x.get()->path_query_fragment == "/");
}
}
|