6
const gchar *expected_scheme;
7
const gchar *expected_user;
8
const gchar *expected_host;
9
const gchar *expected_path;
11
const gchar *canonical;
15
test_sample_uris (void)
17
static const UriTest sample_uris[] = {
18
{ "ssh://user@host.xz:22/path/to/repo.git/", "ssh", "user", "host.xz", "/path/to/repo.git/", 22, "ssh://user@host.xz:22/path/to/repo.git/" },
19
{ "ssh://user@host.xz/path/to/repo.git/", "ssh", "user", "host.xz", "/path/to/repo.git/", 0, "ssh://user@host.xz/path/to/repo.git/" },
20
{ "ssh://host.xz:1234/path/to/repo.git/", "ssh", NULL,"host.xz", "/path/to/repo.git/", 1234, "ssh://host.xz:1234/path/to/repo.git/" },
21
{ "ssh://host.xz/path/to/repo.git/", "ssh", NULL,"host.xz", "/path/to/repo.git/", 0, "ssh://host.xz/path/to/repo.git/" },
22
{ "ssh://user@host.xz/path/to/repo.git/", "ssh", "user","host.xz", "/path/to/repo.git/", 0, "ssh://user@host.xz/path/to/repo.git/" },
23
{ "ssh://host.xz/path/to/repo.git/", "ssh", NULL,"host.xz", "/path/to/repo.git/", 0, "ssh://host.xz/path/to/repo.git/" },
24
{ "ssh://user@host.xz/~user/path/to/repo.git/", "ssh", "user", "host.xz", "~user/path/to/repo.git/", 0, "ssh://user@host.xz/~user/path/to/repo.git/" },
25
{ "ssh://host.xz/~user/path/to/repo.git/", "ssh", NULL,"host.xz", "~user/path/to/repo.git/", 0, "ssh://host.xz/~user/path/to/repo.git/" },
26
{ "ssh://user@host.xz/~/path/to/repo.git", "ssh", "user", "host.xz", "~/path/to/repo.git",0, "ssh://user@host.xz/~/path/to/repo.git" },
27
{ "ssh://host.xz/~/path/to/repo.git", "ssh", NULL, "host.xz", "~/path/to/repo.git", 0, "ssh://host.xz/~/path/to/repo.git" },
28
{ "user@host.xz:/path/to/repo.git/", "ssh", "user", "host.xz", "/path/to/repo.git/", 0, "ssh://user@host.xz/path/to/repo.git/" },
29
{ "host.xz:/path/to/repo.git/", "ssh", NULL, "host.xz", "/path/to/repo.git/", 0, "ssh://host.xz/path/to/repo.git/" },
30
{ "user@host.xz:~user/path/to/repo.git/", "ssh", "user", "host.xz", "~user/path/to/repo.git/", 0, "ssh://user@host.xz/~user/path/to/repo.git/" },
31
{ "host.xz:~user/path/to/repo.git/", "ssh", NULL, "host.xz", "~user/path/to/repo.git/", 0, "ssh://host.xz/~user/path/to/repo.git/" },
32
{ "user@host.xz:path/to/repo.git", "ssh", "user", "host.xz", "path/to/repo.git", 0, "ssh://user@host.xz/path/to/repo.git" },
33
{ "host.xz:path/to/repo.git", "ssh", NULL, "host.xz", "path/to/repo.git", 0, "ssh://host.xz/path/to/repo.git" },
34
{ "rsync://host.xz/path/to/repo.git/", "rsync", NULL, "host.xz", "/path/to/repo.git/", 0, "rsync://host.xz/path/to/repo.git/" },
35
{ "git://host.xz/path/to/repo.git/", "git", NULL, "host.xz", "/path/to/repo.git/", 0, "git://host.xz/path/to/repo.git/" },
36
{ "git://host.xz/~user/path/to/repo.git/", "git", NULL, "host.xz", "~user/path/to/repo.git/", 0, "git://host.xz/~user/path/to/repo.git/" },
37
{ "http://host.xz/path/to/repo.git/", "http", NULL, "host.xz", "/path/to/repo.git/", 0, "http://host.xz/path/to/repo.git/" },
38
{ "https://host.xz/path/to/repo.git/", "https", NULL, "host.xz", "/path/to/repo.git/", 0, "https://host.xz/path/to/repo.git/" },
39
{ "/path/to/repo.git/", "file", NULL, NULL, "/path/to/repo.git/", 0, "file:///path/to/repo.git/" },
40
{ "path/to/repo.git/", "file", NULL, NULL, "path/to/repo.git/", 0, "file://path/to/repo.git/" },
41
{ "~/path/to/repo.git", "file", NULL, NULL, "~/path/to/repo.git", 0, "file://~/path/to/repo.git" },
42
{ "file:///path/to/repo.git/", "file", NULL, NULL, "/path/to/repo.git/", 0, "file:///path/to/repo.git/" },
43
{ "file://~/path/to/repo.git/", "file", NULL, NULL, "~/path/to/repo.git/", 0, "file://~/path/to/repo.git/" },
48
for (i = 0; sample_uris [i].uri; i++)
50
g_autoptr(IdeVcsUri) uri = NULL;
51
g_autofree gchar *to_string = NULL;
53
uri = ide_vcs_uri_new (sample_uris [i].uri);
56
g_error ("Failed to parse %s\n", sample_uris [i].uri);
59
g_print ("\n%s (%u)\n"
65
sample_uris [i].uri, i,
66
ide_vcs_uri_get_scheme (uri),
67
ide_vcs_uri_get_user (uri),
68
ide_vcs_uri_get_host (uri),
69
ide_vcs_uri_get_port (uri),
70
ide_vcs_uri_get_path (uri));
73
g_assert (uri != NULL);
74
g_assert_cmpstr (sample_uris [i].expected_scheme, ==, ide_vcs_uri_get_scheme (uri));
75
g_assert_cmpstr (sample_uris [i].expected_user, ==, ide_vcs_uri_get_user (uri));
76
g_assert_cmpstr (sample_uris [i].expected_host, ==, ide_vcs_uri_get_host (uri));
77
g_assert_cmpstr (sample_uris [i].expected_path, ==, ide_vcs_uri_get_path (uri));
78
g_assert_cmpint (sample_uris [i].expected_port, ==, ide_vcs_uri_get_port (uri));
80
to_string = ide_vcs_uri_to_string (uri);
81
g_assert_cmpstr (sample_uris [i].canonical, ==, to_string);
89
g_test_init (&argc, &argv, NULL);
90
g_test_add_func ("/Ide/VcsUri/sample_uris", test_sample_uris);