LCOV - code coverage report
Current view: top level - libstorage/tests - storage_test.cpp (source / functions) Hit Total Coverage
Test: wfc_demo-coverage.info Lines: 36 36 100.0 %
Date: 2019-08-13 Functions: 16 16 100.0 %

          Line data    Source code
       1             : #include <fas/testing.hpp>
       2             : #include <storage/storage.hpp>
       3             : 
       4             : struct _storage_;
       5             : 
       6           3 : UNIT(set, "")
       7             : {
       8             :   using namespace fas::testing;
       9           1 :   storage& stg = GET_REF(_storage_);
      10           1 :   t << is_false<expect>( stg.set("key1",  "+value1") ) << FAS_FL;
      11           1 :   t << is_false<expect>( stg.set("key99", "+value99") ) << FAS_FL;
      12           1 :   t << is_true<expect>( stg.set("keyX",  "+valueX") ) << FAS_FL;
      13           1 : }
      14             : 
      15           3 : UNIT(get, "")
      16             : {
      17             :   using namespace fas::testing;
      18           1 :   storage& stg = GET_REF(_storage_);
      19           1 :   std::string result;
      20             :   
      21           1 :   bool found = stg.get("key1", &result);
      22           1 :   t << is_true<expect>(found) << " key1 not found." << FAS_FL;
      23           1 :   t << equal<expect, std::string>("value1", result) << FAS_FL;
      24             : 
      25           1 :   found = stg.get("key99", &result);
      26           1 :   t << is_true<expect>(found) << " key99 not found." << FAS_FL;
      27           1 :   t << equal<expect, std::string>("value99", result) << FAS_FL;
      28             : 
      29           1 :   found = stg.get("keyX", &result);
      30           1 :   t << is_true<expect>(found) << " keyX not found." << FAS_FL;
      31           1 :   t << equal<expect, std::string>("+valueX", result) << FAS_FL;
      32             : 
      33           1 :   found = stg.get("keyY", &result);
      34           1 :   t << is_false<expect>(found) << " keyY is found." << FAS_FL;
      35           1 :   t << equal<expect, std::string>("", result) << FAS_FL;
      36             : 
      37           1 : }
      38             : 
      39           3 : UNIT(ini, "")
      40             : {
      41             :   using namespace fas::testing;
      42           1 :   storage& stg = GET_REF(_storage_);
      43         101 :   for (int i = 0; i < 100; ++i)
      44         100 :     stg.set("key"+std::to_string(i), "value"+std::to_string(i));
      45         101 :   for (int i = 0; i < 100; ++i)
      46             :   {
      47         100 :     std::string key = "key"+std::to_string(i);
      48         200 :     std::string value = "value"+std::to_string(i);
      49         200 :     std::string result;
      50             : 
      51         100 :     bool found = stg.get(key, &result);
      52         100 :     t << is_true<expect>(found) << key << " not found." << FAS_FL;
      53         100 :     t << equal<expect>(value, result) << FAS_FL;
      54             :   }
      55           1 : }
      56             : 
      57           1 : BEGIN_SUITE(storage, "")
      58             :   ADD_UNIT( ini )
      59             :   ADD_UNIT( set )
      60             :   ADD_UNIT( get )
      61             :   ADD_VALUE(_storage_, storage)
      62           7 : END_SUITE(storage)

Generated by: LCOV version 1.10