LCOV - code coverage report
Current view: top level - src/libs/tools/src/helper - comparison.cpp (source / functions) Hit Total Coverage
Test: coverage-filtered.info Lines: 17 18 94.4 %
Date: 2019-09-12 12:28:41 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /**
       2             :  * @file
       3             :  *
       4             :  * @brief Comparison helper functions
       5             :  *
       6             :  * @copyright BSD License (see LICENSE.md or https://www.libelektra.org)
       7             :  *
       8             :  */
       9             : 
      10             : #include <helper/comparison.hpp>
      11             : 
      12             : using namespace std;
      13             : 
      14             : namespace kdb
      15             : {
      16             : 
      17             : namespace tools
      18             : {
      19             : 
      20             : namespace helper
      21             : {
      22             : 
      23        1207 : bool keyDataEqual (const Key & k1, const Key & k2)
      24             : {
      25        2410 :         if (!k1 || !k2) return false;
      26             : 
      27        1826 :         if (k1.isBinary () != k2.isBinary ()) return false;
      28             : 
      29        1199 :         if (k1.isBinary () && k2.isBinary ())
      30             :         {
      31         864 :                 return k1.getBinary () == k2.getBinary ();
      32             :         }
      33             :         else
      34             :         {
      35        1869 :                 return k1.getString () == k2.getString ();
      36             :         }
      37             : 
      38             :         return true;
      39             : }
      40             : 
      41         526 : bool keyMetaEqual (Key & k1, Key & k2)
      42             : {
      43        1048 :         if (!k1 || !k2) return false;
      44             : 
      45         520 :         k1.rewindMeta ();
      46           0 :         Key currentMeta;
      47        2504 :         while ((currentMeta = k1.nextMeta ()))
      48             :         {
      49         220 :                 string metaName = currentMeta.getName ();
      50         122 :                 if (!k2.hasMeta (metaName)) return false;
      51         448 :                 if (currentMeta.getString () != k2.getMeta<string> (metaName)) return false;
      52             :         }
      53             : 
      54             : 
      55             :         k2.rewindMeta ();
      56        2472 :         while ((currentMeta = k2.nextMeta ()))
      57             :         {
      58         214 :                 string metaName = currentMeta.getName ();
      59         110 :                 if (!k1.hasMeta (metaName)) return false;
      60         424 :                 if (currentMeta.getString () != k1.getMeta<string> (metaName)) return false;
      61             :         }
      62             : 
      63             : 
      64             :         return true;
      65             : }
      66             : } // namespace helper
      67             : } // namespace tools
      68             : } // namespace kdb

Generated by: LCOV version 1.13