forked from ElektraInitiative/libelektra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestmod_iterate.c
65 lines (44 loc) · 1.49 KB
/
testmod_iterate.c
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
/**
* @file
*
* @brief Tests for iterate plugin
*
* @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
*
*/
#include <stdlib.h>
#include <string.h>
#include <kdbconfig.h>
#include <tests_plugin.h>
static void test_basics (void)
{
printf ("test basics\n");
Key * parentKey = keyNew ("user:/tests/iterate", KEY_END);
KeySet * conf = ksNew (0, KS_END);
PLUGIN_OPEN ("iterate");
KeySet * ks = ksNew (0, KS_END);
succeed_if (plugin->kdbOpen (plugin, parentKey) == 1, "call to kdbOpen was not successful");
succeed_if (plugin->kdbGet (plugin, ks, parentKey) == 0, "call to kdbGet was not successful");
succeed_if (plugin->kdbSet (plugin, ks, parentKey) == 0, "call to kdbSet was not successful");
// clang-format off
ksAppendKey (ks, keyNew("user:/tests/iterate/key",
KEY_META, "iterate", "has",
KEY_END));
// clang-format on
succeed_if (plugin->kdbGet (plugin, ks, parentKey) == 1, "call to kdbGet was not successful");
succeed_if (plugin->kdbSet (plugin, ks, parentKey) == 1, "call to kdbSet was not successful");
succeed_if (plugin->kdbError (plugin, ks, parentKey) == 1, "call to kdbError was not successful");
succeed_if (plugin->kdbClose (plugin, parentKey) == 1, "call to kdbClose was not successful");
keyDel (parentKey);
ksDel (ks);
PLUGIN_CLOSE ();
}
int main (int argc, char ** argv)
{
printf ("ITERATE TESTS\n");
printf ("==================\n\n");
init (argc, argv);
test_basics ();
print_result ("testmod_iterate");
return nbError;
}