LCOV - code coverage report
Current view: top level - src/plugins/iterate - testmod_iterate.c (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 27 27 100.0 %
Date: 2019-09-12 12:28:41 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /**
       2             :  * @file
       3             :  *
       4             :  * @brief Tests for iterate plugin
       5             :  *
       6             :  * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
       7             :  *
       8             :  */
       9             : 
      10             : #include <stdlib.h>
      11             : #include <string.h>
      12             : 
      13             : #include <kdbconfig.h>
      14             : 
      15             : #include <tests_plugin.h>
      16             : 
      17           2 : static void test_basics (void)
      18             : {
      19           2 :         printf ("test basics\n");
      20             : 
      21           2 :         Key * parentKey = keyNew ("user/tests/iterate", KEY_END);
      22           2 :         KeySet * conf = ksNew (0, KS_END);
      23           2 :         PLUGIN_OPEN ("iterate");
      24             : 
      25           2 :         KeySet * ks = ksNew (0, KS_END);
      26             : 
      27           2 :         succeed_if (plugin->kdbOpen (plugin, parentKey) == 1, "call to kdbOpen was not successful");
      28             : 
      29           2 :         succeed_if (plugin->kdbGet (plugin, ks, parentKey) == 0, "call to kdbGet was not successful");
      30             : 
      31           2 :         succeed_if (plugin->kdbSet (plugin, ks, parentKey) == 0, "call to kdbSet was not successful");
      32             : 
      33             :         // clang-format off
      34           2 :         ksAppendKey (ks, keyNew("user/tests/iterate/key",
      35             :                                 KEY_META, "iterate", "has",
      36             :                                 KEY_END));
      37             :         // clang-format on
      38             : 
      39           2 :         ksRewind (ks);
      40           2 :         succeed_if (plugin->kdbGet (plugin, ks, parentKey) == 1, "call to kdbGet was not successful");
      41             : 
      42           2 :         ksRewind (ks);
      43           2 :         succeed_if (plugin->kdbSet (plugin, ks, parentKey) == 1, "call to kdbSet was not successful");
      44             : 
      45           2 :         succeed_if (plugin->kdbError (plugin, ks, parentKey) == 1, "call to kdbError was not successful");
      46             : 
      47           2 :         succeed_if (plugin->kdbClose (plugin, parentKey) == 1, "call to kdbClose was not successful");
      48             : 
      49           2 :         keyDel (parentKey);
      50           2 :         ksDel (ks);
      51           2 :         PLUGIN_CLOSE ();
      52           2 : }
      53             : 
      54             : 
      55           2 : int main (int argc, char ** argv)
      56             : {
      57           2 :         printf ("ITERATE     TESTS\n");
      58           2 :         printf ("==================\n\n");
      59             : 
      60           2 :         init (argc, argv);
      61             : 
      62           2 :         test_basics ();
      63             : 
      64           2 :         print_result ("testmod_iterate");
      65             : 
      66           2 :         return nbError;
      67             : }

Generated by: LCOV version 1.13