]> git.sesse.net Git - vlc/commitdiff
Basic unit test for URI decoding
authorRémi Denis-Courmont <rem@videolan.org>
Sun, 9 Apr 2006 18:33:22 +0000 (18:33 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Sun, 9 Apr 2006 18:33:22 +0000 (18:33 +0000)
src/Makefile.am
src/test/url.c [new file with mode: 0644]

index 0c1632dcbb90958b9b1a4d9d814fdb0fda4890f4..d82a2510560dd058713fe7ee37ba3673a23f9d8b 100644 (file)
@@ -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 (file)
index 0000000..61df847
--- /dev/null
@@ -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 <vlc/vlc.h>
+#include "vlc_url.h"
+
+#undef NDEBUG
+#include <assert.h>
+
+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;
+}