30 #include "test-stuff.h"
36 gboolean want_password;
44 gchar *normalized_uri;
45 gboolean is_file_protocol;
55 "/test/path/file.gnucash", FALSE,
56 "file", NULL, NULL, NULL,
"/test/path/file.gnucash", 0,
57 "file:///test/path/file.gnucash",
58 "file:///test/path/file.gnucash", TRUE
61 "file:///test/path/file.gnucash", FALSE,
62 "file", NULL, NULL, NULL,
"/test/path/file.gnucash", 0,
63 "file:///test/path/file.gnucash",
64 "file:///test/path/file.gnucash", TRUE
67 "xml:///test/path/file.gnucash", FALSE,
68 "xml", NULL, NULL, NULL,
"/test/path/file.gnucash", 0,
69 "xml:///test/path/file.gnucash",
70 "xml:///test/path/file.gnucash", TRUE
73 "sqlite3:///test/path/file.gnucash", FALSE,
74 "sqlite3", NULL, NULL, NULL,
"/test/path/file.gnucash", 0,
75 "sqlite3:///test/path/file.gnucash",
76 "sqlite3:///test/path/file.gnucash", TRUE
81 "c:\\test\\path\\file.gnucash", FALSE,
82 "file", NULL, NULL, NULL,
"c:\\test\\path\\file.gnucash", 0,
83 "file://c:\\test\\path\\file.gnucash",
84 "file://c:\\test\\path\\file.gnucash", TRUE
87 "file://c:\\test\\path\\file.gnucash", FALSE,
88 "file", NULL, NULL, NULL,
"c:\\test\\path\\file.gnucash", 0,
89 "file://c:\\test\\path\\file.gnucash",
90 "file://c:\\test\\path\\file.gnucash", TRUE
93 "xml://c:\\test\\path\\file.gnucash", FALSE,
94 "xml", NULL, NULL, NULL,
"c:\\test\\path\\file.gnucash", 0,
95 "xml://c:\\test\\path\\file.gnucash",
96 "xml://c:\\test\\path\\file.gnucash", TRUE
99 "sqlite3://c:\\test\\path\\file.gnucash", FALSE,
100 "sqlite3", NULL, NULL, NULL,
"c:\\test\\path\\file.gnucash", 0,
101 "sqlite3://c:\\test\\path\\file.gnucash",
102 "sqlite3://c:\\test\\path\\file.gnucash", TRUE
107 "mysql://www.gnucash.org/gnucash", FALSE,
108 "mysql",
"www.gnucash.org", NULL, NULL,
"gnucash", 0,
109 "mysql://www.gnucash.org/gnucash",
110 "mysql://www.gnucash.org/gnucash", FALSE
113 "mysql://www.gnucash.org/gnucash", TRUE,
114 "mysql",
"www.gnucash.org", NULL, NULL,
"gnucash", 0,
115 "mysql://www.gnucash.org/gnucash",
116 "mysql://www.gnucash.org/gnucash", FALSE
120 "mysql",
"www.gnucash.org",
"dbuser", NULL,
"gnucash", 0,
126 "mysql",
"www.gnucash.org",
"dbuser", NULL,
"gnucash", 0,
132 "mysql",
"www.gnucash.org",
"dbuser",
"dbpass",
"gnucash", 0,
138 "mysql",
"www.gnucash.org",
"dbuser",
"dbpass",
"gnucash", 0,
143 "postgres://www.gnucash.org/gnucash", FALSE,
144 "postgres",
"www.gnucash.org", NULL, NULL,
"gnucash", 0,
145 "postgres://www.gnucash.org/gnucash",
146 "postgres://www.gnucash.org/gnucash", FALSE
149 "postgres://www.gnucash.org/gnucash", TRUE,
150 "postgres",
"www.gnucash.org", NULL, NULL,
"gnucash", 0,
151 "postgres://www.gnucash.org/gnucash",
152 "postgres://www.gnucash.org/gnucash", FALSE
156 "postgres",
"www.gnucash.org",
"dbuser", NULL,
"gnucash", 0,
162 "postgres",
"www.gnucash.org",
"dbuser", NULL,
"gnucash", 0,
168 "postgres",
"www.gnucash.org",
"dbuser",
"dbpass",
"gnucash", 0,
174 "postgres",
"www.gnucash.org",
"dbuser",
"dbpass",
"gnucash", 0,
181 "postgres",
"www.gnucash.org",
"dbuser",
"*#bad35:@xx",
"gnucash", 0,
188 "postgres",
"www.gnucash.org",
"dbuser",
"dbpass",
"gnucash", 744,
194 { NULL, FALSE, NULL, NULL, NULL, NULL, NULL, 0, NULL, FALSE },
198 main(
int argc,
char **argv)
205 for (i = 0; strs[i].uri != NULL; i++)
207 gchar *tprotocol = NULL;
208 gchar *thostname = NULL;
209 gchar *tusername = NULL;
210 gchar *tpassword = NULL;
216 &tport, &tusername, &tpassword, &tpath );
217 testresult = ( g_strcmp0 ( tprotocol, strs[i].protocol ) == 0 ) &
218 ( g_strcmp0 ( thostname, strs[i].hostname ) == 0 ) &
219 ( g_strcmp0 ( tusername, strs[i].username ) == 0 ) &
220 ( g_strcmp0 ( tpassword, strs[i].password ) == 0 ) &
221 ( g_strcmp0 ( tpath, strs[i].path ) == 0 ) &
222 ( tport == strs[i].port );
223 do_test_args(testresult,
224 "gnc_uri_get_components",
227 " Expected: %s, %s, %s, %s, %s, %d\n"
228 " Got : %s, %s, %s, %s, %s, %d\n",
229 strs[i].uri, strs[i].protocol, strs[i].hostname,
230 strs[i].username, strs[i].password, strs[i].path, strs[i].port,
231 tprotocol, thostname, tusername, tpassword, tpath, tport);
240 for (i = 0; strs[i].uri != NULL; i++)
242 gchar *tprotocol = NULL;
246 testresult = ( g_strcmp0 ( tprotocol, strs[i].protocol ) == 0 );
247 do_test_args(testresult,
248 "gnc_uri_get_protocol",
253 strs[i].uri, strs[i].protocol, tprotocol );
258 for (i = 0; strs[i].uri != NULL; i++)
264 testresult = ( g_strcmp0 ( tpath, strs[i].path ) == 0 );
265 do_test_args(testresult,
271 strs[i].uri, strs[i].path, tpath );
276 for (i = 0; strs[i].uri != NULL; i++)
282 strs[i].username, strs[i].password, strs[i].path );
283 testresult = ( g_strcmp0 ( turi, strs[i].created_uri ) == 0 );
284 do_test_args(testresult,
285 "gnc_uri_create_uri",
287 "\n %s, %s, %s, %s, %s, %d:\n"
290 strs[i].protocol, strs[i].hostname,
291 strs[i].username, strs[i].password, strs[i].path, strs[i].port,
292 strs[i].created_uri, turi);
297 for (i = 0; strs[i].uri != NULL; i++)
303 testresult = ( g_strcmp0 ( turi, strs[i].normalized_uri ) == 0 );
304 do_test_args(testresult,
305 "gnc_uri_normalize_uri",
310 strs[i].uri, strs[i].normalized_uri, turi );
315 for (i = 0; strs[i].uri != NULL; i++)
317 gboolean tis_file_protocol;
321 testresult = ( tis_file_protocol == strs[i].is_file_protocol );
322 do_test_args(testresult,
323 "gnc_uri_is_file_protocol",
328 strs[i].uri, strs[i].is_file_protocol, tis_file_protocol );
332 for (i = 0; strs[i].uri != NULL; i++)
334 gboolean tis_file_uri;
338 testresult = ( tis_file_uri == strs[i].is_file_protocol );
339 do_test_args(testresult,
340 "gnc_uri_is_file_uri",
345 strs[i].uri, strs[i].is_file_protocol, tis_file_uri );
348 print_test_results();
gboolean gnc_uri_is_file_protocol(const gchar *protocol)
gboolean gnc_uri_is_file_uri(const gchar *uri)
gchar * gnc_uri_get_path(const gchar *uri)
gchar * gnc_uri_normalize_uri(const gchar *uri, gboolean allow_password)
void gnc_uri_get_components(const gchar *uri, gchar **protocol, gchar **hostname, gint32 *port, gchar **username, gchar **password, gchar **path)
gchar * gnc_uri_create_uri(const gchar *protocol, const gchar *hostname, gint32 port, const gchar *username, const gchar *password, const gchar *path)
Utility functions for convert uri in separate components and back.
void qof_init(void)
Initialise the Query Object Framework.
gchar * gnc_uri_get_protocol(const gchar *uri)