Line data Source code
1 : /**
2 : * @file
3 : *
4 : * @brief
5 : *
6 : * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
7 : */
8 :
9 : #ifdef HAVE_KDBCONFIG_H
10 : #include "kdbconfig.h"
11 : #endif
12 :
13 : #include <stdio.h>
14 : #ifdef HAVE_STDLIB_H
15 : #include <stdlib.h>
16 : #endif
17 : #ifdef HAVE_STRING_H
18 : #include <string.h>
19 : #endif
20 :
21 : #include <tests_plugin.h>
22 :
23 2 : void test_readline (void)
24 : {
25 :
26 2 : char * filename = srcdir_file ("line/linetest");
27 2 : Key * parentKey = keyNew ("user/tests/line", KEY_VALUE, filename, KEY_END);
28 2 : KeySet * conf = 0;
29 2 : PLUGIN_OPEN ("line");
30 2 : printf ("%s\n", filename);
31 :
32 2 : KeySet * ks = ksNew (0, KS_END);
33 2 : succeed_if (plugin->kdbGet (plugin, ks, parentKey) >= 1, "call to kdbGet was not successful");
34 2 : Key * key = ksLookupByName (ks, "user/tests/line/#0", 0);
35 2 : exit_if_fail (key, "line1 key not found");
36 2 : succeed_if (strcmp ("test1", keyValue (key)) == 0, "line ยด does not match");
37 :
38 2 : key = ksLookupByName (ks, "user/tests/line/#_10", 0);
39 2 : exit_if_fail (key, "line11 key not found");
40 2 : succeed_if (strcmp ("", keyValue (key)) == 0, "line 10 should be blank");
41 :
42 2 : key = ksLookupByName (ks, "user/tests/line/#_13", 0);
43 2 : exit_if_fail (key, "line14 key not found");
44 2 : succeed_if (strcmp ("printf(\"hello world\\n\");", keyValue (key)) == 0, "line 13 not correct");
45 :
46 2 : ksDel (ks);
47 2 : keyDel (parentKey);
48 :
49 2 : PLUGIN_CLOSE ();
50 2 : }
51 :
52 2 : int main (int argc, char ** argv)
53 : {
54 2 : printf ("LINE TESTS\n");
55 2 : printf ("==================\n\n");
56 :
57 2 : init (argc, argv);
58 :
59 2 : test_readline ();
60 :
61 2 : print_result ("test_line");
62 :
63 2 : return nbError;
64 : }
|