[vlc-devel] [PATCH 2/4] Test vlc_url* for '[[serveraddr]:[serverport]@[bindhost]:[bindport]]'
Jean-Paul Saman
jpsaman at videolan.org
Thu Oct 27 15:42:25 CEST 2016
---
src/test/url.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/src/test/url.c b/src/test/url.c
index 0f7f3e0..1402d0c 100644
--- a/src/test/url.c
+++ b/src/test/url.c
@@ -113,6 +113,39 @@ static void test_url_parse(const char* in, const char* protocol, const char* use
#undef CHECK
}
+static void test_url_udp(const char *in, const char *protocol,
+ const char *host, const unsigned port,
+ const char *bindhost, const unsigned bindport)
+{
+#define CHECK( a, b ) \
+ if (a == NULL) \
+ assert(b == NULL); \
+ else \
+ assert(b != NULL && !strcmp((a), (b)))
+
+ fprintf(stderr, "\"%s\" -> ", in);
+
+ vlc_url_t url;
+ vlc_UrlParse( &url, in );
+ CHECK( url.psz_protocol, protocol );
+ CHECK( url.psz_username, NULL );
+ CHECK( url.psz_password, NULL );
+ CHECK( url.psz_host, host );
+ CHECK( url.psz_bind_host, bindhost );
+ CHECK( url.psz_path, NULL );
+ assert( url.i_port == port );
+ assert( url.i_bind_port == bindport );
+ CHECK( url.psz_option, NULL );
+
+ fprintf(stderr, "\"%s\" \"%s\" : \"%d\" @ \"%s\" : \"%d\"\n",
+ url.psz_protocol,
+ url.psz_host, url.i_port,
+ url.psz_bind_host, url.i_bind_port);
+ vlc_UrlClean( &url );
+
+#undef CHECK
+}
+
static void test_url_resolve(const char *base, const char *reference,
const char *expected)
{
@@ -283,10 +316,22 @@ int main (void)
NULL, "opt=val");
test_url_parse("//example.com/f?o=v", NULL, NULL, NULL, "example.com", 0,
"/f", "o=v");
+
/* Invalid URIs */
test_url_parse("p://G a r b a g e", "p", NULL, NULL, NULL, 0, NULL, NULL);
test_url_parse("p://h/G a r b a g e", "p", NULL, NULL, "h", 0, NULL, NULL);
+ /* Valid udp:// urls */
+ test_url_udp("udp://serveraddr:2022@bindhost:1234", "udp", "serveraddr", 2022, "bindhost", 1234);
+ test_url_udp("udp://[2001:db8::1]:2022@[2022:db8::1]:1234", "udp", "2001:db8::1", 2022, "2022:db8::1", 1234);
+ test_url_udp("udp://:1234", "udp", "", 1234, NULL, 0);
+ test_url_udp("udp://@:2022", "udp", "", 0, "", 2022);
+ test_url_udp("udp://192.168.0.1:2022", "udp", "192.168.0.1", 2022, NULL, 0);
+ test_url_udp("udp://[2001:db8::1]", "udp", "2001:db8::1", 0, NULL, 0);
+ test_url_udp("udp://[2001:db8::1]:2022", "udp", "2001:db8::1", 2022, NULL, 0);
+ test_url_udp("udp://@:2022", "udp", "", 0, "", 2022);
+ test_url_udp("udp://@[2022:db8::1]:2022", "udp", "", 0, "2022:db8::1", 2022);
+
/* Reference test cases for reference URI resolution */
static const char *rfc3986_cases[] =
{
--
2.7.4
More information about the vlc-devel
mailing list