2
Copyright (C) 2008 Christian Dywan <christian@twotoasts.de>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Lesser General Public
6
License as published by the Free Software Foundation; either
7
version 2.1 of the License, or (at your option) any later version.
9
See the file COPYING for the full license text.
23
KatzeArray* search_engines;
28
gtk_init (&argc, &argv);
30
search_engines = katze_array_new (KATZE_TYPE_ITEM);
31
item = g_object_new (KATZE_TYPE_ITEM,
32
"uri", "http://www.searchmash.com/search/%s",
34
katze_array_add_item (search_engines, item);
36
#define test_input(input, expected) \
37
uri = sokoke_magic_uri (input, search_engines); \
38
if (g_strcmp0 (uri, expected)) \
40
g_print ("Input: %s\nExpected: %s\nResult: %s\n\n", \
41
input ? input : "NULL", \
42
expected ? expected : "NULL", \
43
uri ? uri : "NULL"); \
48
test_input ("ftp://ftp.mozilla.org", "ftp://ftp.mozilla.org");
49
test_input ("ftp://ftp.mozilla.org/pub", "ftp://ftp.mozilla.org/pub");
50
test_input ("http://www.example.com", "http://www.example.com");
51
test_input ("http://example.com", "http://example.com");
52
test_input ("example.com", "http://example.com");
53
test_input ("example.com", "http://example.com");
54
test_input ("/home/user/midori.html", "file:///home/user/midori.html");
55
a = g_get_current_dir ();
56
b = g_strconcat ("file://", a, G_DIR_SEPARATOR_S, "magic-uri.c", NULL);
58
test_input ("magic-uri.c", b);
60
test_input ("localhost", "http://localhost");
61
test_input ("localhost:8000", "http://localhost:8000");
62
test_input ("192.168.1.1", "http://192.168.1.1");
63
test_input ("192.168.1.1:8000", "http://192.168.1.1:8000");
64
test_input ("sm midori", "http://www.searchmash.com/search/midori");
65
test_input ("sm cats dogs", "http://www.searchmash.com/search/cats dogs");
66
test_input ("dict midori", NULL);
67
test_input ("cats", NULL);
68
test_input ("cats dogs", NULL);
69
test_input ("gtk 2.0", NULL);
70
test_input ("gtk2.0", NULL);
71
test_input ("midori0.1.0", NULL);
72
test_input ("midori 0.1.0", NULL);