Commit 2d268697 authored by Rémi Duraffort's avatar Rémi Duraffort

Add a test about chain escaping escaping.

parent e2238b5c
...@@ -18,6 +18,7 @@ check_PROGRAMS = \ ...@@ -18,6 +18,7 @@ check_PROGRAMS = \
test_libvlc_media \ test_libvlc_media \
test_libvlc_media_list \ test_libvlc_media_list \
test_libvlc_media_player \ test_libvlc_media_player \
test_src_config_chain \
test_src_misc_variables \ test_src_misc_variables \
$(NULL) $(NULL)
...@@ -91,6 +92,11 @@ test_src_misc_variables_LDADD = $(top_builddir)/src/libvlc.la ...@@ -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_CFLAGS = $(CFLAGS_tests)
test_src_misc_variables_LDFLAGS = $(LDFLAGS_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: checkall:
$(MAKE) check_PROGRAMS="$(check_PROGRAMS) $(EXTRA_PROGRAMS)" check $(MAKE) check_PROGRAMS="$(check_PROGRAMS) $(EXTRA_PROGRAMS)" check
......
/*****************************************************************************
* chain.c: test configuration chains
*****************************************************************************
* Copyright (C) 2010 VideoLAN and authors
* $Id$
*
* Authors: Rémi Duraffort <ivoire@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();
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment