LCOV - code coverage report
Current view: top level - tests - component.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 9 9 100.0 %
Date: 2021-05-29 11:58:38 Functions: 5 5 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2006-2021  Made to Order Software Corp.  All Rights Reserved
       2             : //
       3             : // https://snapwebsites.org/project/snaplogger
       4             : // contact@m2osw.com
       5             : //
       6             : // This program is free software; you can redistribute it and/or modify
       7             : // it under the terms of the GNU General Public License as published by
       8             : // the Free Software Foundation; either version 2 of the License, or
       9             : // (at your option) any later version.
      10             : //
      11             : // This program is distributed in the hope that it will be useful,
      12             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             : // GNU General Public License for more details.
      15             : //
      16             : // You should have received a copy of the GNU General Public License along
      17             : // with this program; if not, write to the Free Software Foundation, Inc.,
      18             : // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      19             : 
      20             : // self
      21             : //
      22             : #include    "main.h"
      23             : 
      24             : 
      25             : // snaplogger lib
      26             : //
      27             : #include    <snaplogger/component.h>
      28             : //#include    <snaplogger/exception.h>
      29             : //#include    <snaplogger/format.h>
      30             : //#include    <snaplogger/logger.h>
      31             : //#include    <snaplogger/map_diagnostic.h>
      32             : //#include    <snaplogger/message.h>
      33             : //#include    <snaplogger/severity.h>
      34             : //#include    <snaplogger/version.h>
      35             : 
      36             : 
      37             : 
      38             : 
      39             : 
      40           3 : CATCH_TEST_CASE("component", "[component]")
      41             : {
      42           2 :     CATCH_START_SECTION("Make sure creating component generates unique entries")
      43             :     {
      44             :         // this worked from the start since the private logger instance
      45             :         // uses a map to store the components
      46             :         //
      47          30 :         struct name_ptr
      48             :         {
      49             :             typedef std::vector<name_ptr>   vector_t;
      50             : 
      51             :             std::string     f_name = std::string();
      52             :             snaplogger::component::pointer_t
      53             :                             f_component = snaplogger::component::pointer_t();
      54             :         };
      55             :         name_ptr::vector_t names =
      56             :         {
      57             :             { "component1", },
      58             :             { "component2", },
      59             :             { "component3", },
      60             :             { "component4", },
      61             :             { "component5", },
      62             :             { "component6", },
      63             :             { "component7", },
      64             :             { "component8", },
      65             :             { "component9", },
      66             :             { "component10", },
      67           2 :         };
      68             : 
      69             :         // create the components
      70             :         //
      71          11 :         for(auto & p : names)
      72             :         {
      73          10 :             p.f_component = snaplogger::get_component(p.f_name);
      74             :         }
      75             : 
      76             :         // verify the component pointers
      77             :         //
      78          11 :         for(auto & p : names)
      79             :         {
      80          10 :             CATCH_REQUIRE(p.f_component == snaplogger::get_component(p.f_name));
      81             :         }
      82             :     }
      83             :     CATCH_END_SECTION()
      84           7 : }
      85             : 
      86             : 
      87             : 
      88             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.13