1 /*****************************************************************************
2 * chain.c: test configuration chains
3 *****************************************************************************
4 * Copyright (C) 2010 VideoLAN and authors
7 * Authors: RĂ©mi Duraffort <ivoire@videolan.org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
27 #include "../../libvlc/test.h"
29 #include <vlc_common.h>
30 #include <vlc_configuration.h>
34 const char *psz_string;
35 const char *psz_escaped;
38 static const sample_t samples[] =
41 { "azertyuiop", "azertyuiop" },
42 { " test ", " test " },
44 { "''''", "\\'\\'\\'\\'" },
45 { "' a '", "\\' a \\'" },
46 { "\"quote\"", "\\\"quote\\\"" },
47 { " az\" ", " az\\\" " },
48 { "\\test", "\\\\test" },
52 static void test_config_StringEscape()
54 for( int i = 0; samples[i].psz_string; i++ )
56 char *psz_tmp = config_StringEscape( samples[i].psz_string );
57 assert( !strcmp( psz_tmp, samples[i].psz_escaped ) );
62 static void test_config_StringUnEscape()
64 for( int i =0; samples[i].psz_string; i++ )
66 char *psz_tmp = strdup( samples[i].psz_escaped );
67 config_StringUnescape( psz_tmp );
68 assert( !strcmp( psz_tmp, samples[i].psz_string ) );
75 log( "Testing config chain escaping\n" );
76 test_config_StringEscape();
77 log( "Testing config chain un-escaping\n" );
78 test_config_StringUnEscape();