[vlc-commits] test/url: make it easier to check invalid URLs
Filip Roséen
git at videolan.org
Fri Oct 28 19:09:36 CEST 2016
vlc | branch: master | Filip Roséen <filip at atch.se> | Fri Oct 28 10:49:45 2016 +0200| [c45bbb818150ee5ec3b56ab73e4a31a0db0697a7] | committer: Thomas Guillem
test/url: make it easier to check invalid URLs
The previous implementation, somewhat unconditionally, made
assumptions about the internal state of the result of `vlc_UrlParse`,
meaning that it was inherently difficult to check if invalid URLs was
correctly rejected.
These changes simply asserts that vlc_UrlParse failed if all of the
arguments (used to verify the result) are NULL or 0.
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c45bbb818150ee5ec3b56ab73e4a31a0db0697a7
---
src/test/url.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/test/url.c b/src/test/url.c
index ffb073c..04ce812 100644
--- a/src/test/url.c
+++ b/src/test/url.c
@@ -106,6 +106,15 @@ static void test_url_parse(const char* in, const char* protocol, const char* use
vlc_url_t url;
int ret = vlc_UrlParse(&url, in);
+ /* XXX: only checking that the port-part is parsed correctly, and
+ * equal to 0, is currently not supported due to the below. */
+ if( !protocol && !user && !pass && !host && !i_port && !path && !option )
+ {
+ vlc_UrlClean( &url );
+ assert( ret == -1 );
+ return;
+ }
+
CHECK( url.psz_protocol, protocol );
CHECK( url.psz_username, user );
CHECK( url.psz_password, pass );
@@ -300,10 +309,9 @@ int main (void)
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);
- test_url_parse("http://example.com:123xyz", "http", NULL, NULL,
- "example.com", 123, NULL, NULL);
+ test_url_parse("p://G a r b a g e", NULL, NULL, NULL, NULL, 0, NULL, NULL);
+ test_url_parse("p://h/G a r b a g e", NULL, NULL, NULL, NULL, 0, NULL, NULL);
+ test_url_parse("http://example.com:123xyz", NULL, NULL, NULL, NULL, 0, NULL, NULL);
/* Reference test cases for reference URI resolution */
static const char *rfc3986_cases[] =
More information about the vlc-commits
mailing list