1 /* GStreamer unit tests for the RTSP support library
3 * Copyright (C) 2010 Andy Wingo <wingo@oblong.com>
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., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
25 #include <gst/check/gstcheck.h>
27 #include <gst/rtsp/gstrtspurl.h>
30 GST_START_TEST (test_rtsp_url_basic)
32 GstRTSPUrl *url = NULL;
35 res = gst_rtsp_url_parse ("rtsp://localhost/foo/bar", &url);
36 fail_unless (res == GST_RTSP_OK);
37 fail_unless (url != NULL);
38 fail_unless (url->transports & GST_RTSP_LOWER_TRANS_TCP);
39 fail_unless (url->transports & GST_RTSP_LOWER_TRANS_UDP);
40 fail_unless (url->transports & GST_RTSP_LOWER_TRANS_UDP_MCAST);
41 fail_unless (url->family == GST_RTSP_FAM_INET);
42 fail_unless (!url->user);
43 fail_unless (!url->passwd);
44 fail_unless (!strcmp (url->host, "localhost"));
45 /* fail_unless (url->port == GST_RTSP_DEFAULT_PORT); */
46 fail_unless (!strcmp (url->abspath, "/foo/bar"));
47 fail_unless (!url->query);
49 gst_rtsp_url_free (url);
54 GST_START_TEST (test_rtsp_url_components_1)
56 GstRTSPUrl *url = NULL;
60 res = gst_rtsp_url_parse ("rtsp://localhost/foo/bar", &url);
61 fail_unless (res == GST_RTSP_OK);
62 fail_unless (url != NULL);
64 comps = gst_rtsp_url_decode_path_components (url);
65 fail_unless (comps != NULL);
66 fail_unless (g_strv_length (comps) == 3);
67 fail_unless (!strcmp (comps[0], ""));
68 fail_unless (!strcmp (comps[1], "foo"));
69 fail_unless (!strcmp (comps[2], "bar"));
72 gst_rtsp_url_free (url);
77 GST_START_TEST (test_rtsp_url_components_2)
79 GstRTSPUrl *url = NULL;
83 res = gst_rtsp_url_parse ("rtsp://localhost/foo%2Fbar/qux%20baz", &url);
84 fail_unless (res == GST_RTSP_OK);
85 fail_unless (url != NULL);
87 comps = gst_rtsp_url_decode_path_components (url);
88 fail_unless (comps != NULL);
89 fail_unless (g_strv_length (comps) == 3);
90 fail_unless (!strcmp (comps[0], ""));
91 fail_unless (!strcmp (comps[1], "foo/bar"));
92 fail_unless (!strcmp (comps[2], "qux baz"));
95 gst_rtsp_url_free (url);
100 GST_START_TEST (test_rtsp_url_components_3)
102 GstRTSPUrl *url = NULL;
104 gchar **comps = NULL;
106 res = gst_rtsp_url_parse ("rtsp://localhost/foo%00bar/qux%20baz", &url);
107 fail_unless (res == GST_RTSP_OK);
108 fail_unless (url != NULL);
110 comps = gst_rtsp_url_decode_path_components (url);
111 fail_unless (comps != NULL);
112 fail_unless (g_strv_length (comps) == 3);
113 fail_unless (!strcmp (comps[0], ""));
114 fail_unless (!strcmp (comps[1], "foo%00bar"));
115 fail_unless (!strcmp (comps[2], "qux baz"));
118 gst_rtsp_url_free (url);
126 Suite *s = suite_create ("rtsp support library");
127 TCase *tc_chain = tcase_create ("general");
129 suite_add_tcase (s, tc_chain);
130 tcase_add_test (tc_chain, test_rtsp_url_basic);
131 tcase_add_test (tc_chain, test_rtsp_url_components_1);
132 tcase_add_test (tc_chain, test_rtsp_url_components_2);
133 tcase_add_test (tc_chain, test_rtsp_url_components_3);
139 main (int argc, char **argv)
143 Suite *s = rtsp_suite ();
144 SRunner *sr = srunner_create (s);
146 gst_check_init (&argc, &argv);
148 srunner_run_all (sr, CK_NORMAL);
149 nf = srunner_ntests_failed (sr);