1 /* GStreamer unit tests for GstURI
3 * Copyright (C) 2007 Tim-Philipp Müller <tim centricular net>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #include <gst/check/gstcheck.h>
23 GST_START_TEST (test_protocol_case)
28 element = gst_element_make_from_uri (GST_URI_SRC, "file:///foo/bar", NULL,
31 /* no element? probably no registry, bail out */
32 if (element == NULL && err->code == GST_URI_ERROR_UNSUPPORTED_PROTOCOL) {
37 gst_object_unref (element);
38 element = gst_element_make_from_uri (GST_URI_SRC, "FILE:///foo/bar", NULL,
40 fail_unless (element != NULL,
41 "Got source for 'file://' URI but not for 'FILE://' URI");
42 gst_object_unref (element);
47 GST_START_TEST (test_uri_get_location)
51 /* URI with no location should return empty string */
52 l = gst_uri_get_location ("dvd://");
53 fail_unless (l != NULL);
54 fail_unless_equals_string (l, "");
57 /* URI with hostname */
58 l = gst_uri_get_location ("smb://supercomputer/path/to/file");
59 fail_unless (l != NULL);
60 fail_unless_equals_string (l, "supercomputer/path/to/file");
64 l = gst_uri_get_location ("file:///path/to/file");
65 fail_unless (l != NULL);
66 fail_unless_equals_string (l, "/path/to/file");
70 l = gst_uri_get_location ("file:///path/to/some%20file");
71 fail_unless (l != NULL);
72 fail_unless_equals_string (l, "/path/to/some file");
80 GST_START_TEST (test_win32_uri)
84 uri = g_strdup ("file:///c:/my%20music/foo.ogg");
85 l = gst_uri_get_location (uri);
86 fail_unless (l != NULL);
87 /* fail_unless_equals_string will screw up here in the failure case
88 * because the string constant will be appended to the printf format
89 * message string and contains a '%', that's why we use fail_unless here */
90 fail_unless (g_str_equal (l, "c:/my music/foo.ogg"),
91 "wrong location '%s' returned for URI '%s'", l, uri);
95 /* make sure the other variant with two slashes before the C: (which was
96 * needed before because of a bug in _get_location()) still works */
97 uri = g_strdup ("file://c:/my%20music/foo.ogg");
98 l = gst_uri_get_location (uri);
99 fail_unless (l != NULL);
100 /* fail_unless_equals_string will screw up here in the failure case
101 * because the string constant will be appended to the printf format
102 * message string and contains a '%', that's why we use fail_unless here */
103 fail_unless (g_str_equal (l, "c:/my music/foo.ogg"),
104 "wrong location '%s' returned for URI '%s'", l, uri);
111 #endif /* G_OS_WIN32 */
113 GST_START_TEST (test_uri_misc)
115 /* require at least two characters for the protocol */
116 fail_if (gst_uri_is_valid ("B:\\foo.txt"));
117 fail_if (gst_uri_is_valid ("B:/foo.txt"));
118 fail_if (gst_uri_is_valid ("B://foo.txt"));
119 fail_if (gst_uri_is_valid ("B:foo.txt"));
121 fail_unless (gst_uri_is_valid ("fd://0"));
122 fail_unless (gst_uri_is_valid ("AB:\\foo.txt"));
123 fail_unless (gst_uri_is_valid ("AB:/foo.txt"));
124 fail_unless (gst_uri_is_valid ("AB://foo.txt"));
125 fail_unless (gst_uri_is_valid ("AB:foo.txt"));
127 fail_unless (gst_uri_is_valid ("ABC:/foo.txt"));
128 fail_unless (gst_uri_is_valid ("ABC://foo.txt"));
129 fail_unless (gst_uri_is_valid ("ABC:foo.txt"));
131 fail_unless (gst_uri_is_valid ("ABCD:/foo.txt"));
132 fail_unless (gst_uri_is_valid ("ABCD://foo.txt"));
133 fail_unless (gst_uri_is_valid ("ABCD:foo.txt"));
138 GST_START_TEST (test_element_make_from_uri)
143 element = gst_element_make_from_uri (GST_URI_SRC, "foo://", NULL, NULL);
144 fail_unless (element == NULL);
146 element = gst_element_make_from_uri (GST_URI_SRC, "foo://", NULL, &err);
147 fail_unless (element == NULL);
148 fail_unless (err != NULL);
149 fail_unless (err->code == GST_URI_ERROR_UNSUPPORTED_PROTOCOL);
153 if (gst_registry_check_feature_version (gst_registry_get (), "filesrc",
154 GST_VERSION_MAJOR, GST_VERSION_MINOR, GST_VERSION_MICRO)) {
155 element = gst_element_make_from_uri (GST_URI_SRC, "file://host/foo", NULL,
157 fail_unless (element == NULL);
158 fail_unless (err != NULL);
159 fail_unless (err->code == GST_URI_ERROR_BAD_URI);
167 GST_START_TEST (test_url_parsing)
175 ("scheme://user:pass@host.com:1234/path/to/item-obj?query=something#fragment");
177 fail_unless_equals_string (gst_uri_get_scheme (url), "scheme");
178 fail_unless_equals_string (gst_uri_get_userinfo (url), "user:pass");
179 fail_unless_equals_string (gst_uri_get_host (url), "host.com");
180 fail_unless (gst_uri_get_port (url) == 1234);
181 tmp_str = gst_uri_get_path (url);
182 fail_unless_equals_string (tmp_str, "/path/to/item-obj");
184 list = gst_uri_get_query_keys (url);
185 fail_unless (g_list_length (list) == 1);
187 fail_unless (gst_uri_query_has_key (url, "query"));
188 fail_unless_equals_string (gst_uri_get_query_value (url, "query"),
190 fail_unless_equals_string (gst_uri_get_fragment (url), "fragment");
193 url = gst_uri_from_string ("scheme://host/path/to/dir/");
194 fail_unless_equals_string (gst_uri_get_scheme (url), "scheme");
195 fail_unless (gst_uri_get_userinfo (url) == NULL);
196 fail_unless_equals_string (gst_uri_get_host (url), "host");
197 fail_unless (gst_uri_get_port (url) == GST_URI_NO_PORT);
198 tmp_str = gst_uri_get_path (url);
199 fail_unless_equals_string (tmp_str, "/path/to/dir/");
201 fail_unless (gst_uri_get_query_table (url) == NULL);
202 fail_unless (gst_uri_get_fragment (url) == NULL);
205 url = gst_uri_from_string ("urn:name:path");
206 fail_unless_equals_string (gst_uri_get_scheme (url), "urn");
207 fail_unless (gst_uri_get_userinfo (url) == NULL);
208 fail_unless (gst_uri_get_host (url) == NULL);
209 fail_unless (gst_uri_get_port (url) == GST_URI_NO_PORT);
210 tmp_str = gst_uri_get_path (url);
211 fail_unless_equals_string (tmp_str, "name:path");
213 list = gst_uri_get_query_keys (url);
214 fail_unless (g_list_length (list) == 0);
216 fail_unless (gst_uri_get_fragment (url) == NULL);
222 GST_START_TEST (test_url_normalization)
229 ("ScHeMe://User:P%61ss@HOST.%63om:1234/path/./from/../to%7d/item%2dobj?qu%65ry=something#fr%61gment");
230 fail_unless (gst_uri_normalize (url));
231 fail_unless_equals_string (gst_uri_get_scheme (url), "scheme");
232 fail_unless_equals_string (gst_uri_get_userinfo (url), "User:Pass");
233 fail_unless_equals_string (gst_uri_get_host (url), "host.com");
234 tmp_str = gst_uri_get_path (url);
235 fail_unless_equals_string (tmp_str, "/path/to}/item-obj");
237 fail_unless (gst_uri_query_has_key (url, "query"));
238 fail_unless_equals_string (gst_uri_get_query_value (url, "query"),
240 fail_unless_equals_string (gst_uri_get_fragment (url), "fragment");
246 GST_START_TEST (test_url_joining)
248 GstUri *base, *rel, *joined;
253 ("http://example.com/path/to/dir/filename.html#fragment");
255 /* test change of fragment only */
256 rel = gst_uri_from_string ("#new_frag");
257 joined = gst_uri_join (base, rel);
258 l = gst_uri_to_string (joined);
259 fail_unless_equals_string (l,
260 "http://example.com/path/to/dir/filename.html#new_frag");
262 gst_uri_unref (joined);
265 /* test addition of new query string */
266 rel = gst_uri_from_string ("?key=val");
267 joined = gst_uri_join (base, rel);
268 l = gst_uri_to_string (joined);
269 fail_unless_equals_string (l,
270 "http://example.com/path/to/dir/filename.html?key=val");
272 gst_uri_unref (joined);
275 /* test new base filename */
276 rel = gst_uri_from_string ("new_filename.xml");
277 joined = gst_uri_join (base, rel);
278 l = gst_uri_to_string (joined);
279 fail_unless_equals_string (l,
280 "http://example.com/path/to/dir/new_filename.xml");
282 gst_uri_unref (joined);
285 /* test relative file same directory */
286 rel = gst_uri_from_string ("./new_filename.xml");
287 joined = gst_uri_join (base, rel);
288 l = gst_uri_to_string (joined);
289 fail_unless_equals_string (l,
290 "http://example.com/path/to/dir/new_filename.xml");
292 gst_uri_unref (joined);
295 /* test relative file parent directory */
296 rel = gst_uri_from_string ("../new_filename.xml");
297 joined = gst_uri_join (base, rel);
298 l = gst_uri_to_string (joined);
299 fail_unless_equals_string (l, "http://example.com/path/to/new_filename.xml");
301 gst_uri_unref (joined);
304 /* test relative file grandparent directory */
305 rel = gst_uri_from_string ("../../new_filename.xml");
306 joined = gst_uri_join (base, rel);
307 l = gst_uri_to_string (joined);
308 fail_unless_equals_string (l, "http://example.com/path/new_filename.xml");
310 gst_uri_unref (joined);
313 /* test relative file root directory */
314 rel = gst_uri_from_string ("../../../new_filename.xml");
315 joined = gst_uri_join (base, rel);
316 l = gst_uri_to_string (joined);
317 fail_unless_equals_string (l, "http://example.com/new_filename.xml");
319 gst_uri_unref (joined);
322 /* test relative file beyond root directory */
323 rel = gst_uri_from_string ("../../../../new_filename.xml");
324 joined = gst_uri_join (base, rel);
325 l = gst_uri_to_string (joined);
326 fail_unless_equals_string (l, "http://example.com/new_filename.xml");
328 gst_uri_unref (joined);
331 /* test add subdirectory */
332 rel = gst_uri_from_string ("subdir/new_filename.xml");
333 joined = gst_uri_join (base, rel);
334 l = gst_uri_to_string (joined);
335 fail_unless_equals_string (l,
336 "http://example.com/path/to/dir/subdir/new_filename.xml");
338 gst_uri_unref (joined);
341 /* test change directory */
342 rel = gst_uri_from_string ("../subdir/new_filename.xml");
343 joined = gst_uri_join (base, rel);
344 l = gst_uri_to_string (joined);
345 fail_unless_equals_string (l,
346 "http://example.com/path/to/subdir/new_filename.xml");
348 gst_uri_unref (joined);
351 gst_uri_unref (base);
353 /* change base for path ending in directory */
354 base = gst_uri_from_string ("http://example.com/path/to/dir/");
356 /* test adding file to directory */
357 rel = gst_uri_from_string ("new_filename.xml");
358 joined = gst_uri_join (base, rel);
359 l = gst_uri_to_string (joined);
360 fail_unless_equals_string (l,
361 "http://example.com/path/to/dir/new_filename.xml");
363 gst_uri_unref (joined);
366 /* test adding file to directory using relative path */
367 rel = gst_uri_from_string ("./new_filename.xml");
368 joined = gst_uri_join (base, rel);
369 l = gst_uri_to_string (joined);
370 fail_unless_equals_string (l,
371 "http://example.com/path/to/dir/new_filename.xml");
373 gst_uri_unref (joined);
376 /* test filename in parent directory */
377 rel = gst_uri_from_string ("../new_filename.xml");
378 joined = gst_uri_join (base, rel);
379 l = gst_uri_to_string (joined);
380 fail_unless_equals_string (l, "http://example.com/path/to/new_filename.xml");
382 gst_uri_unref (joined);
385 /* test replace with absolute */
386 rel = gst_uri_from_string ("https://ssl.example.com/new_filename.xml");
387 joined = gst_uri_join (base, rel);
388 l = gst_uri_to_string (joined);
389 fail_unless_equals_string (l, "https://ssl.example.com/new_filename.xml");
391 gst_uri_unref (joined);
394 gst_uri_unref (base);
399 GST_START_TEST (test_url_equality)
405 ("ScHeMe://User:Pass@HOST.com:1234/path/./from/../to%7d/item%2dobj?query=something#fragment");
410 ("scheme://User:Pass@host.com:1234/path/to%7D/item-obj?query=something#fragment");
411 fail_unless (gst_uri_equal (url1, url2));
412 fail_unless (gst_uri_equal (url2, url1));
413 gst_uri_unref (url2);
415 /* different fragment */
418 ("scheme://User:Pass@host.com:1234/path/to%7D/item-obj?query=something#different-fragment");
419 fail_unless (!gst_uri_equal (url1, url2));
420 gst_uri_unref (url2);
422 /* different query */
425 ("scheme://User:Pass@host.com:1234/path/to%7D/item-obj?query=different-something#fragment");
426 fail_unless (!gst_uri_equal (url1, url2));
427 gst_uri_unref (url2);
432 ("scheme://User:Pass@host.com:1234/path/to%7D/different-item-obj?query=something#fragment");
433 fail_unless (!gst_uri_equal (url1, url2));
434 gst_uri_unref (url2);
439 ("scheme://User:Pass@host.com:4321/path/to%7D/item-obj?query=something#fragment");
440 fail_unless (!gst_uri_equal (url1, url2));
441 gst_uri_unref (url2);
446 ("scheme://User:Pass@different-host.com:1234/path/to%7D/item-obj?query=something#fragment");
447 fail_unless (!gst_uri_equal (url1, url2));
448 gst_uri_unref (url2);
450 /* different userinfo */
453 ("scheme://Different-User:Pass@host.com:1234/path/to%7D/item-obj?query=something#fragment");
454 fail_unless (!gst_uri_equal (url1, url2));
455 gst_uri_unref (url2);
457 /* different scheme */
460 ("different+scheme://User:Pass@host.com:1234/path/to%7D/item-obj?query=something#fragment");
461 fail_unless (!gst_uri_equal (url1, url2));
462 gst_uri_unref (url2);
464 /* different (no scheme) */
467 ("//User:Pass@host.com:1234/path/to%7D/item-obj?query=something#fragment");
468 fail_unless (!gst_uri_equal (url1, url2));
469 gst_uri_unref (url2);
471 /* different (no userinfo) */
474 ("scheme://host.com:1234/path/to%7D/item-obj?query=something#fragment");
475 fail_unless (!gst_uri_equal (url1, url2));
476 gst_uri_unref (url2);
478 /* different (no host) */
481 ("scheme://User:Pass@:1234/path/to%7D/item-obj?query=something#fragment");
482 fail_unless (!gst_uri_equal (url1, url2));
483 gst_uri_unref (url2);
485 /* different (no port) */
488 ("scheme://User:Pass@host.com/path/to%7D/item-obj?query=something#fragment");
489 fail_unless (!gst_uri_equal (url1, url2));
490 gst_uri_unref (url2);
492 /* different (no path) */
495 ("scheme://User:Pass@host.com:1234?query=something#fragment");
496 fail_unless (!gst_uri_equal (url1, url2));
497 gst_uri_unref (url2);
499 /* different (no query) */
502 ("scheme://User:Pass@host.com:1234/path/to%7D/item-obj#fragment");
503 fail_unless (!gst_uri_equal (url1, url2));
504 gst_uri_unref (url2);
506 /* different (no fragment) */
509 ("scheme://User:Pass@host.com:1234/path/to%7D/item-obj?query=something");
510 fail_unless (!gst_uri_equal (url1, url2));
511 gst_uri_unref (url2);
513 /* compare two NULL uris */
514 fail_unless (gst_uri_equal (NULL, NULL));
516 /* compare same object */
517 fail_unless (gst_uri_equal (url1, url1));
519 /* compare one NULL and one non-NULL uri */
520 fail_unless (!gst_uri_equal (url1, NULL));
521 fail_unless (!gst_uri_equal (NULL, url1));
523 gst_uri_unref (url1);
528 GST_START_TEST (test_url_constructors)
532 GHashTable *tmp_table;
535 gst_uri_new ("scheme", "userinfo", "hostname", 1234, "/path/to/file",
536 "query", "fragment");
537 fail_unless_equals_string (gst_uri_get_scheme (url1), "scheme");
538 fail_unless_equals_string (gst_uri_get_userinfo (url1), "userinfo");
539 fail_unless_equals_string (gst_uri_get_host (url1), "hostname");
540 fail_unless (gst_uri_get_port (url1) == 1234);
541 tmp_str = gst_uri_get_path (url1);
542 fail_unless_equals_string (tmp_str, "/path/to/file");
544 tmp_table = gst_uri_get_query_table (url1);
545 fail_unless (g_hash_table_size (tmp_table) == 1);
546 fail_unless (g_hash_table_contains (tmp_table, "query"));
547 fail_unless (g_hash_table_lookup (tmp_table, "query") == NULL);
548 g_hash_table_unref (tmp_table);
549 fail_unless_equals_string (gst_uri_get_fragment (url1), "fragment");
550 tmp_str = gst_uri_to_string (url1);
551 fail_unless_equals_string (tmp_str,
552 "scheme://userinfo@hostname:1234/path/to/file?query#fragment");
556 gst_uri_new_with_base (url1, NULL, NULL, NULL, GST_URI_NO_PORT,
557 "new_file", NULL, NULL);
558 fail_unless_equals_string (gst_uri_get_scheme (url2), "scheme");
559 fail_unless_equals_string (gst_uri_get_userinfo (url2), "userinfo");
560 fail_unless_equals_string (gst_uri_get_host (url2), "hostname");
561 fail_unless (gst_uri_get_port (url2) == 1234);
562 tmp_str = gst_uri_get_path (url2);
563 fail_unless_equals_string (tmp_str, "/path/to/new_file");
565 fail_unless (gst_uri_get_query_table (url2) == NULL);
566 fail_unless (gst_uri_get_fragment (url2) == NULL);
567 tmp_str = gst_uri_to_string (url2);
568 fail_unless_equals_string (tmp_str,
569 "scheme://userinfo@hostname:1234/path/to/new_file");
571 gst_uri_unref (url2);
573 url2 = gst_uri_from_string_with_base (url1, "/a/new/path/to/file");
574 fail_unless_equals_string (gst_uri_get_scheme (url2), "scheme");
575 fail_unless_equals_string (gst_uri_get_userinfo (url2), "userinfo");
576 fail_unless_equals_string (gst_uri_get_host (url2), "hostname");
577 fail_unless (gst_uri_get_port (url2) == 1234);
578 tmp_str = gst_uri_get_path (url2);
579 fail_unless_equals_string (tmp_str, "/a/new/path/to/file");
581 fail_unless (gst_uri_get_query_table (url2) == NULL);
582 fail_unless (gst_uri_get_fragment (url2) == NULL);
583 tmp_str = gst_uri_to_string (url2);
584 fail_unless_equals_string (tmp_str,
585 "scheme://userinfo@hostname:1234/a/new/path/to/file");
587 gst_uri_unref (url2);
589 url2 = gst_uri_copy (url1);
590 fail_unless (gst_uri_equal (url1, url2));
591 gst_uri_set_query_value (url2, "key", "value");
592 fail_unless (!gst_uri_equal (url1, url2));
593 gst_uri_unref (url2);
595 gst_uri_unref (url1);
600 GST_START_TEST (test_url_get_set)
606 url = gst_uri_from_string ("scheme://hostname/path/to/file?query#fragment");
608 fail_unless (gst_uri_set_scheme (url, "new+scheme"));
609 fail_unless_equals_string (gst_uri_get_scheme (url), "new+scheme");
610 tmp_str = gst_uri_to_string (url);
611 fail_unless_equals_string (tmp_str,
612 "new+scheme://hostname/path/to/file?query#fragment");
615 fail_unless (gst_uri_set_scheme (url, NULL));
616 fail_unless (gst_uri_get_scheme (url) == NULL);
617 tmp_str = gst_uri_to_string (url);
618 fail_unless_equals_string (tmp_str, "//hostname/path/to/file?query#fragment");
621 fail_unless (!gst_uri_set_scheme (NULL, "fail"));
622 fail_unless (gst_uri_set_scheme (NULL, NULL));
624 fail_unless (gst_uri_set_userinfo (url, "username:password"));
625 fail_unless_equals_string (gst_uri_get_userinfo (url), "username:password");
626 tmp_str = gst_uri_to_string (url);
627 fail_unless_equals_string (tmp_str,
628 "//username:password@hostname/path/to/file?query#fragment");
631 fail_unless (gst_uri_set_userinfo (url, NULL));
632 fail_unless (gst_uri_get_userinfo (url) == NULL);
633 tmp_str = gst_uri_to_string (url);
634 fail_unless_equals_string (tmp_str, "//hostname/path/to/file?query#fragment");
637 fail_unless (!gst_uri_set_userinfo (NULL, "fail"));
638 fail_unless (gst_uri_set_userinfo (NULL, NULL));
640 fail_unless (gst_uri_set_host (url, NULL));
641 fail_unless (gst_uri_get_host (url) == NULL);
642 tmp_str = gst_uri_to_string (url);
643 fail_unless_equals_string (tmp_str, "/path/to/file?query#fragment");
646 fail_unless (gst_uri_set_host (url, "example.com"));
647 fail_unless_equals_string (gst_uri_get_host (url), "example.com");
648 tmp_str = gst_uri_to_string (url);
649 fail_unless_equals_string (tmp_str,
650 "//example.com/path/to/file?query#fragment");
653 fail_unless (!gst_uri_set_host (NULL, "fail"));
654 fail_unless (gst_uri_set_host (NULL, NULL));
656 fail_unless (gst_uri_set_port (url, 12345));
657 fail_unless (gst_uri_get_port (url) == 12345);
658 tmp_str = gst_uri_to_string (url);
659 fail_unless_equals_string (tmp_str,
660 "//example.com:12345/path/to/file?query#fragment");
663 fail_unless (gst_uri_set_port (url, GST_URI_NO_PORT));
664 fail_unless (gst_uri_get_port (url) == GST_URI_NO_PORT);
665 tmp_str = gst_uri_to_string (url);
666 fail_unless_equals_string (tmp_str,
667 "//example.com/path/to/file?query#fragment");
670 fail_unless (!gst_uri_set_port (NULL, 1234));
671 fail_unless (gst_uri_set_port (NULL, GST_URI_NO_PORT));
673 fail_unless (gst_uri_append_path_segment (url, "here"));
674 tmp_str = gst_uri_to_string (url);
675 fail_unless_equals_string (tmp_str,
676 "//example.com/path/to/file/here?query#fragment");
679 fail_unless (!gst_uri_append_path_segment (NULL, "fail"));
680 fail_unless (gst_uri_append_path_segment (NULL, NULL));
682 fail_unless (gst_uri_append_path (url, "../there"));
683 tmp_str = gst_uri_to_string (url);
684 fail_unless_equals_string (tmp_str,
685 "//example.com/path/to/file/here/../there?query#fragment");
688 fail_unless (!gst_uri_append_path (NULL, "fail"));
689 fail_unless (gst_uri_append_path (NULL, NULL));
691 gst_uri_normalize (url);
693 tmp_list = gst_uri_get_path_segments (url);
694 fail_unless (tmp_list != NULL);
695 tmp_list = g_list_append (tmp_list, g_strdup ("segment"));
696 tmp_str = gst_uri_to_string (url);
697 fail_unless_equals_string (tmp_str,
698 "//example.com/path/to/file/there?query#fragment");
700 fail_unless (gst_uri_set_path_segments (url, tmp_list));
701 tmp_str = gst_uri_to_string (url);
702 fail_unless_equals_string (tmp_str,
703 "//example.com/path/to/file/there/segment?query#fragment");
706 tmp_list = g_list_append (NULL, g_strdup ("test"));
707 fail_unless (!gst_uri_set_path_segments (NULL, tmp_list));
708 fail_unless (gst_uri_set_path_segments (NULL, NULL));
710 fail_unless (gst_uri_set_query_value (url, "key", "value"));
711 tmp_str = gst_uri_to_string (url);
712 fail_unless_equals_string (tmp_str,
713 "//example.com/path/to/file/there/segment?query&key=value#fragment");
716 fail_unless (gst_uri_set_query_value (url, "key", NULL));
717 tmp_str = gst_uri_to_string (url);
718 fail_unless_equals_string (tmp_str,
719 "//example.com/path/to/file/there/segment?query&key#fragment");
722 fail_unless (!gst_uri_set_query_value (NULL, "key", "value"));
724 fail_unless (gst_uri_remove_query_key (url, "key"));
725 tmp_str = gst_uri_to_string (url);
726 fail_unless_equals_string (tmp_str,
727 "//example.com/path/to/file/there/segment?query#fragment");
730 fail_unless (!gst_uri_remove_query_key (url, "key"));
731 fail_unless (!gst_uri_remove_query_key (NULL, "key"));
733 fail_unless (gst_uri_set_fragment (url, NULL));
734 fail_unless (gst_uri_get_fragment (url) == NULL);
735 tmp_str = gst_uri_to_string (url);
736 fail_unless_equals_string (tmp_str,
737 "//example.com/path/to/file/there/segment?query");
740 fail_unless (gst_uri_set_fragment (url, "tag"));
741 fail_unless_equals_string (gst_uri_get_fragment (url), "tag");
742 tmp_str = gst_uri_to_string (url);
743 fail_unless_equals_string (tmp_str,
744 "//example.com/path/to/file/there/segment?query#tag");
747 fail_unless (!gst_uri_set_fragment (NULL, "can't set if no URI"));
748 fail_unless (gst_uri_set_fragment (NULL, NULL));
758 Suite *s = suite_create ("GstURI");
759 TCase *tc_chain = tcase_create ("uri");
761 tcase_set_timeout (tc_chain, 20);
763 suite_add_tcase (s, tc_chain);
764 tcase_add_test (tc_chain, test_protocol_case);
765 tcase_add_test (tc_chain, test_uri_get_location);
766 tcase_add_test (tc_chain, test_uri_misc);
767 tcase_add_test (tc_chain, test_element_make_from_uri);
769 tcase_add_test (tc_chain, test_win32_uri);
771 tcase_add_test (tc_chain, test_url_parsing);
772 tcase_add_test (tc_chain, test_url_normalization);
773 tcase_add_test (tc_chain, test_url_joining);
774 tcase_add_test (tc_chain, test_url_equality);
775 tcase_add_test (tc_chain, test_url_constructors);
776 tcase_add_test (tc_chain, test_url_get_set);
781 GST_CHECK_MAIN (gst_uri);