1
/* Copyright (C) 2000-2002, 2005 Red Hat, Inc.
3
* This is free software; you can redistribute it and/or modify it under
4
* the terms of the GNU Library General Public License as published by
5
* the Free Software Foundation; either version 2 of the License, or
6
* (at your option) any later version.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
* General Public License for more details.
13
* You should have received a copy of the GNU Library General Public
14
* License along with this program; if not, write to the Free Software
15
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25
#include "../lib/user.h"
32
struct lu_context *ctx;
33
struct lu_error *error;
37
ctx = lu_start(NULL, 0, NULL, NULL, lu_prompt_console_quiet, NULL,
40
fprintf(stderr, "Error initializing %s: %s.\n", PACKAGE,
46
list = lu_cfg_read(ctx, "test/name", NULL);
47
assert(g_list_length(list) == 2);
48
assert(strcmp(list->data, "value1") == 0);
49
assert(strcmp(list->next->data, "value2") == 0);
51
list = lu_cfg_read(ctx, "test/nonexistent", "default");
52
assert(g_list_length(list) == 1);
53
assert(strcmp(list->data, "default") == 0);
55
list = lu_cfg_read(ctx, "test/nonexistent", NULL);
56
assert(g_list_length(list) == 0);
58
assert(strcmp(lu_cfg_read_single(ctx, "test/name", NULL), "value1")
60
assert(strcmp(lu_cfg_read_single(ctx, "test/nonexistent", "default"),
62
assert(lu_cfg_read_single(ctx, "test/nonexistent", NULL) == NULL);
64
list = lu_cfg_read_keys(ctx, "test");
65
assert(g_list_length(list) == 2);
66
assert(strcmp(list->data, "name") == 0);
67
assert(strcmp(list->next->data, "name2") == 0);
69
list = lu_cfg_read_keys(ctx, "invalid");
70
assert(g_list_length(list) == 0);