forked from GeopJr/Tuba
-
Notifications
You must be signed in to change notification settings - Fork 0
/
WebApHandler.test.vala
33 lines (28 loc) · 1.09 KB
/
WebApHandler.test.vala
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
struct TestUrl {
public string original;
public string result;
}
const TestUrl[] URLS = {
{ "web+ap://www.gnome.org/", "https://www.gnome.org/" },
{ "web+ap://www.gnome.org/test", "https://www.gnome.org/test" },
{ "web+ap://www.gnome.org/test?foo=bar", "https://www.gnome.org/test?foo=bar" },
{ "web+ap://www.gnome.org/test?foo=bar&fizz=buzz", "https://www.gnome.org/test?foo=bar&fizz=buzz" },
{ "web+ap://www.gnome.org/test?foo=bar&fizz=buzz#main", "https://www.gnome.org/test?foo=bar&fizz=buzz#main" },
{ "web+ap://[email protected]/test", "https://gnome.org/test" },
{ "web+ap://www.gnome.org/test?foo=%26foo%3Dbar", "https://www.gnome.org/test?foo=%26foo%3Dbar" },
};
public void test_web_ap_handler () {
foreach (var test_url in URLS) {
try {
var uri = Uri.parse (test_url.original, UriFlags.ENCODED);
assert_cmpstr (Tuba.WebApHandler.from_uri (uri), CompareOperator.EQ, test_url.result);
} catch (Error e) {
critical (e.message);
}
}
}
public int main (string[] args) {
Test.init (ref args);
Test.add_func ("/test_web_ap_handler", test_web_ap_handler);
return Test.run ();
}