vlc | branch: master | Hugo Beauzée-Luyssen <[email protected]> | Tue Mar 10 15:45:03 2015 +0100| [c639abd71521ff6412e9d980cdccf46185a0dd58] | committer: Rémi Denis-Courmont
Add vlc_UrlParse tests Signed-off-by: Rémi Denis-Courmont <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c639abd71521ff6412e9d980cdccf46185a0dd58 --- src/test/url.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/test/url.c b/src/test/url.c index c199271..b976cb8 100644 --- a/src/test/url.c +++ b/src/test/url.c @@ -87,6 +87,26 @@ static inline void test_current_directory_path (const char *in, const char *cwd, test (make_URI_def, in, expected_result); } +static void test_url_parse(const char* in, const char* protocol, const char* user, + const char* pass, const char* host, unsigned i_port, + const char* path, const char* option ) +{ +#define CHECK( a, b ) assert(((a == NULL) && (b == NULL)) || !strcmp((a), (b))) + vlc_url_t url; + vlc_UrlParse( &url, in, '?' ); + CHECK( url.psz_protocol, protocol ); + CHECK( url.psz_username, user ); + CHECK( url.psz_password, pass ); + CHECK( url.psz_host, host ); + CHECK( url.psz_path, path ); + assert( url.i_port == i_port ); + CHECK( url.psz_option, option ); + + vlc_UrlClean( &url ); + +#undef CHECK +} + int main (void) { int val; @@ -156,5 +176,11 @@ int main (void) test ("fd://12345", "/dev/fd/12345"); #undef test + test_url_parse("http://test.com", "http", NULL, NULL, "test.com", 0, NULL, NULL); + test_url_parse("http://test.com/", "http", NULL, NULL, "test.com", 0, "/", NULL); + test_url_parse("protocol://john:[email protected]:567", "protocol", "john", "doe", "1.2.3.4", 567, NULL, NULL); + test_url_parse("http://a.b/?opt=val", "http", NULL, NULL, "a.b", 0, "/", "opt=val"); + test_url_parse("p://u:p@host:123/a/b/c?o=v", "p", "u", "p", "host", 123, "/a/b/c", "o=v"); + return 0; } _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
