From 381f7a665ffc65f51356c80226f7a708d8a59f74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Denis-Courmont?= Date: Sat, 19 Dec 2015 20:07:37 +0200 Subject: [PATCH] https: add some file test cases --- modules/access/http/file_test.c | 35 +++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/modules/access/http/file_test.c b/modules/access/http/file_test.c index 1699aec19f..d3e347d6a4 100644 --- a/modules/access/http/file_test.c +++ b/modules/access/http/file_test.c @@ -165,10 +165,45 @@ int main(void) assert(vlc_http_file_seek(f, offset = 1234) == 0); vlc_http_file_destroy(f); + /* Invalid responses */ + replies[0] = "HTTP/1.1 206 Partial Content\r\n" + "Content-Type: multipart/byteranges\r\n" + "\r\n"; + offset = 0; + + f = vlc_http_file_create(NULL, url, ua, NULL); + assert(f != NULL); + assert(vlc_http_file_get_size(f) == (uintmax_t)-1); + + replies[0] = "HTTP/1.1 206 Partial Content\r\n" + "Content-Range: seconds 60-120/180\r\n" + "\r\n"; + assert(vlc_http_file_seek(f, 0) == -1); + + /* Incomplete range */ + replies[0] = "HTTP/1.1 206 Partial Content\r\n" + "Content-Range: bytes 0-1233/*\r\n" + "\r\n"; + assert(vlc_http_file_seek(f, 0) == 0); + assert(vlc_http_file_get_size(f) == 1234); + + /* Extraneous range */ + replies[0] = "HTTP/1.1 200 OK\r\n" + "Content-Range: bytes 0-1233/1234\r\n" + "\r\n"; + assert(vlc_http_file_seek(f, 0) == 0); + assert(vlc_http_file_get_size(f) == (uintmax_t)-1); + + vlc_http_file_destroy(f); /* Dummy API calls */ f = vlc_http_file_create(NULL, "ftp://localhost/foo", NULL, NULL); assert(f == NULL); + f = vlc_http_file_create(NULL, "/foo", NULL, NULL); + assert(f == NULL); + f = vlc_http_file_create(NULL, "http://www.example.com", NULL, NULL); + assert(f != NULL); + vlc_http_file_destroy(f); return 0; } -- GitLab