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 3 : void test_readline (void)
24 : {
25 :
26 3 : char * filename = srcdir_file ("line/linetest");
27 3 : Key * parentKey = keyNew ("user:/tests/line", KEY_VALUE, filename, KEY_END);
28 3 : KeySet * conf = 0;
29 3 : PLUGIN_OPEN ("line");
30 3 : printf ("%s\n", filename);
31 :
32 3 : KeySet * ks = ksNew (0, KS_END);
33 3 : succeed_if (plugin->kdbGet (plugin, ks, parentKey) >= 1, "call to kdbGet was not successful");
34 3 : Key * key = ksLookupByName (ks, "user:/tests/line/#0", 0);
35 3 : exit_if_fail (key, "line1 key not found");
36 3 : succeed_if (strcmp ("test1", keyValue (key)) == 0, "line ยด does not match");
37 :
38 3 : key = ksLookupByName (ks, "user:/tests/line/#_10", 0);
39 3 : exit_if_fail (key, "line11 key not found");
40 3 : succeed_if (strcmp ("", keyValue (key)) == 0, "line 10 should be blank");
41 :
42 3 : key = ksLookupByName (ks, "user:/tests/line/#_13", 0);
43 3 : exit_if_fail (key, "line14 key not found");
44 3 : succeed_if (strcmp ("printf(\"hello world\\n\");", keyValue (key)) == 0, "line 13 not correct");
45 :
46 3 : ksDel (ks);
47 3 : keyDel (parentKey);
48 :
49 3 : PLUGIN_CLOSE ();
50 3 : }
51 :
52 3 : int main (int argc, char ** argv)
53 : {
54 3 : printf ("LINE TESTS\n");
55 3 : printf ("==================\n\n");
56 :
57 3 : init (argc, argv);
58 :
59 3 : test_readline ();
60 :
61 9 : print_result ("test_line");
62 :
63 3 : return nbError;
64 : }
|