[vlc-commits] commit: Add a test about chain escaping escaping. ( Rémi Duraffort )
git at videolan.org
git at videolan.org
Tue Aug 31 22:22:35 CEST 2010
vlc | branch: master | Rémi Duraffort <ivoire at videolan.org> | Tue Aug 31 21:51:02 2010 +0200| [2d268697cdb889a102c580e12e1e1fdfd8f9db6b] | committer: Rémi Duraffort
Add a test about chain escaping escaping.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2d268697cdb889a102c580e12e1e1fdfd8f9db6b
---
test/Makefile.am | 6 +++
test/src/config/chain.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 85 insertions(+), 0 deletions(-)
diff --git a/test/Makefile.am b/test/Makefile.am
index 0b11a9b..e88f78c 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -18,6 +18,7 @@ check_PROGRAMS = \
test_libvlc_media \
test_libvlc_media_list \
test_libvlc_media_player \
+ test_src_config_chain \
test_src_misc_variables \
$(NULL)
@@ -91,6 +92,11 @@ test_src_misc_variables_LDADD = $(top_builddir)/src/libvlc.la
test_src_misc_variables_CFLAGS = $(CFLAGS_tests)
test_src_misc_variables_LDFLAGS = $(LDFLAGS_tests)
+test_src_config_chain_SOURCES = src/config/chain.c
+test_src_config_chain_LDADD = $(top_builddir)/src/libvlc.la
+test_src_config_chain_CFLAGS = $(CFLAGS_tests)
+test_src_config_chain_LDFLAGS = $(LDFLAGS_tests)
+
checkall:
$(MAKE) check_PROGRAMS="$(check_PROGRAMS) $(EXTRA_PROGRAMS)" check
diff --git a/test/src/config/chain.c b/test/src/config/chain.c
new file mode 100644
index 0000000..531e60b
--- /dev/null
+++ b/test/src/config/chain.c
@@ -0,0 +1,79 @@
+/*****************************************************************************
+ * chain.c: test configuration chains
+ *****************************************************************************
+ * Copyright (C) 2010 VideoLAN and authors
+ * $Id$
+ *
+ * Authors: Rémi Duraffort <ivoire at videolan.org>
+ *
+ * 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 <stdlib.h>
+#include <string.h>
+
+#include "../../libvlc/test.h"
+
+#include <vlc_common.h>
+#include <vlc_configuration.h>
+
+typedef struct
+{
+ const char *psz_string;
+ const char *psz_escaped;
+}sample_t;
+
+static const sample_t samples[] =
+{
+ { "a", "a" },
+ { "azertyuiop", "azertyuiop" },
+ { " test ", " test " },
+ { "it's", "it\\'s" },
+ { "''''", "\\'\\'\\'\\'" },
+ { "' a '", "\\' a \\'" },
+ { "\"quote\"", "\\\"quote\\\"" },
+ { " az\" ", " az\\\" " },
+ { "\\test", "\\\\test" },
+ { NULL, NULL }
+};
+
+static void test_config_StringEscape()
+{
+ for( int i = 0; samples[i].psz_string; i++ )
+ {
+ char *psz_tmp = config_StringEscape( samples[i].psz_string );
+ assert( !strcmp( psz_tmp, samples[i].psz_escaped ) );
+ free( psz_tmp );
+ }
+}
+
+static void test_config_StringUnEscape()
+{
+ for( int i =0; samples[i].psz_string; i++ )
+ {
+ char *psz_tmp = strdup( samples[i].psz_escaped );
+ config_StringUnescape( psz_tmp );
+ assert( !strcmp( psz_tmp, samples[i].psz_string ) );
+ free( psz_tmp );
+ }
+}
+
+int main( void )
+{
+ log( "Testing config chain escaping\n" );
+ test_config_StringEscape();
+ log( "Testing config chain un-escaping\n" );
+ test_config_StringUnEscape();
+}
More information about the vlc-commits
mailing list