summaryrefslogtreecommitdiff
path: root/tests/get-properties/t-get-stringlist.c
blob: 0b6e4d4cbb59f9d5166cac6beb636a61b5e965cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
 *  xfconf
 *
 *  Copyright (c) 2007 Brian Tarricone <bjt23@cornell.edu>
 *
 *  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; version 2 of the License ONLY.
 *
 *  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 Library 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */

#include "tests-common.h"

#ifdef HAVE_STRING_H
#include <string.h>
#endif

int
main(int argc,
     char **argv)
{
    XfconfChannel *channel;
    
    if(!xfconf_tests_start())
        return 1;
    
    channel = xfconf_channel_new(TEST_CHANNEL_NAME);
    
    {
        gchar **strlist = xfconf_channel_get_string_list(channel,
                                                         test_strlist_property);
        gint i;
        
        if(!strlist) {
            g_critical("Test failed: xfconf_channel_get_string_list() returned NULL");
            xfconf_tests_end();
            return 1;
        }
        
        for(i = 0; strlist[i] && test_strlist[i]; ++i) {
            if(strcmp(strlist[i], test_strlist[i])) {
                g_critical("Test failed: string list values don't match (%s != %s)",
                           strlist[i], test_strlist[i]);
                xfconf_tests_end();
                return 1;
            }
        }
        
        if(strlist[i] || test_strlist[i]) {
            g_critical("Test failed: in string list, element %d should be NULL (0x%p, 0x%p)",
                       i, strlist[i], test_strlist[i]);
            xfconf_tests_end();
            return 1;
        }
        
        g_strfreev(strlist);
    }
    
    g_object_unref(G_OBJECT(channel));
    
    xfconf_tests_end();
    
    return 0;
}