From: Rémi Denis-Courmont Date: Sun, 9 Apr 2006 18:33:22 +0000 (+0000) Subject: Basic unit test for URI decoding X-Git-Tag: 0.9.0-test0~11558 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=b40cd0ce13ebf7d7f97433678ad16a29516d30b8;p=vlc Basic unit test for URI decoding --- diff --git a/src/Makefile.am b/src/Makefile.am index 0c1632dcbb..d82a251056 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -385,7 +385,7 @@ stamp-api: Makefile.in $(HEADERS_include) ../vlc-api.pl # Unit/regression test ############################################################################### if USE_LIBTOOL -check_PROGRAMS = test_i18n_atof +check_PROGRAMS = test_i18n_atof test_url TESTS = $(check_PROGRAMS) CFLAGS_tests = `$(VLC_CONFIG) --cflags vlc` @@ -393,5 +393,9 @@ CFLAGS_tests = `$(VLC_CONFIG) --cflags vlc` test_i18n_atof_SOURCES = test/i18n_atof.c test_i18n_atof_LDADD = libvlc.la test_i18n_atof_CFLAGS = $(CFLAGS_tests) + +test_url_SOURCES = test/url.c +test_url_LDADD = libvlc.la +test_url_CFLAGS = $(CFLAGS_tests) endif diff --git a/src/test/url.c b/src/test/url.c new file mode 100644 index 0000000000..61df8475a5 --- /dev/null +++ b/src/test/url.c @@ -0,0 +1,50 @@ +/***************************************************************************** + * url.c: Test for url encoding/decoding stuff + ***************************************************************************** + * Copyright (C) 2006 Rémi Denis-Courmont + * $Id$ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ + +#include +#include "vlc_url.h" + +#undef NDEBUG +#include + +int main (void) +{ + const char url1[] = "this_should_not_be_modified_1234"; + const char url2[] = "This+should+be+modified+1234!"; + const char url3[] = "This%20should%20be%20modified%201234!"; + + char *durl = decode_URI_duplicate (url1); + assert (durl != NULL); + assert (!strcmp (durl, url1)); + free (durl); + + durl = decode_URI_duplicate (url2); + assert (durl != NULL); + assert (!strcmp (durl, "This should be modified 1234!")); + free (durl); + + durl = decode_URI_duplicate (url3); + assert (durl != NULL); + assert (!strcmp (durl, "This should be modified 1234!")); + free (durl); + + return 0; +}