LCOV - code coverage report
Current view: top level - tests - catch_main.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 16 17 94.1 %
Date: 2024-06-03 22:21:57 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2011-2023  Made to Order Software Corp.  All Rights Reserved
       2             : //
       3             : // https://snapwebsites.org/project/libaddr
       4             : // contact@m2osw.com
       5             : //
       6             : // Permission is hereby granted, free of charge, to any
       7             : // person obtaining a copy of this software and
       8             : // associated documentation files (the "Software"), to
       9             : // deal in the Software without restriction, including
      10             : // without limitation the rights to use, copy, modify,
      11             : // merge, publish, distribute, sublicense, and/or sell
      12             : // copies of the Software, and to permit persons to whom
      13             : // the Software is furnished to do so, subject to the
      14             : // following conditions:
      15             : //
      16             : // The above copyright notice and this permission notice
      17             : // shall be included in all copies or substantial
      18             : // portions of the Software.
      19             : //
      20             : // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
      21             : // ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
      22             : // LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
      23             : // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
      24             : // EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
      25             : // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
      26             : // WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
      27             : // ARISING FROM, OUT OF OR IN CONNECTION WITH THE
      28             : // SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
      29             : // SOFTWARE.
      30             : 
      31             : 
      32             : /** \file
      33             :  * \brief The main() function of the addr library tests.
      34             :  *
      35             :  * This file implements the main() function of the unit tests used to
      36             :  * verify the addr library.
      37             :  *
      38             :  * It defines any globals (none at this point) and a few basic command
      39             :  * line options such as --help and --version.
      40             :  */
      41             : 
      42             : // Tell catch we want it to add the runner code in this file.
      43             : #define CATCH_CONFIG_RUNNER
      44             : 
      45             : // self
      46             : //
      47             : #include    "catch_main.h"
      48             : 
      49             : 
      50             : // snapdev
      51             : //
      52             : #include    <snapdev/not_used.h>
      53             : 
      54             : 
      55             : // last include
      56             : //
      57             : #include    <snapdev/poison.h>
      58             : 
      59             : 
      60             : 
      61             : namespace SNAP_CATCH2_NAMESPACE
      62             : {
      63             : 
      64             : int         g_tcp_port = -1;
      65             : 
      66             : }
      67             : 
      68             : 
      69             : namespace
      70             : {
      71             : 
      72             : 
      73           2 : void add_command_line_options(Catch::Clara::Parser & cli)
      74             : {
      75           4 :     cli |= Catch::Clara::Opt(SNAP_CATCH2_NAMESPACE::g_tcp_port, "port")
      76           4 :               ["--tcp-port"]
      77           2 :               ("define a TCP port we can connect to in order to test the get_from_socket() function");
      78           2 : }
      79             : 
      80             : 
      81           1 : int finish_init(Catch::Session & session)
      82             : {
      83           1 :     snapdev::NOT_USED(session);
      84             : 
      85           1 :     cppthread::set_log_callback(SNAP_CATCH2_NAMESPACE::log_for_test);
      86             : 
      87           1 :     return 0;
      88             : }
      89             : 
      90             : 
      91           1 : void cleanup()
      92             : {
      93           1 :     SNAP_CATCH2_NAMESPACE::expected_logs_stack_is_empty();
      94             : 
      95           1 :     if(system("rm -rf socket-test*") != 0)
      96             :     {
      97           0 :         std::cerr << "error: test could not properly clean up socket files." << std::endl;
      98             :     }
      99           1 : }
     100             : 
     101             : 
     102             : }
     103             : // namespace
     104             : 
     105             : 
     106           2 : int main(int argc, char * argv[])
     107             : {
     108           2 :     return SNAP_CATCH2_NAMESPACE::snap_catch2_main(
     109             :               "libaddr"
     110             :             , LIBADDR_VERSION_STRING
     111             :             , argc
     112             :             , argv
     113             :             , nullptr
     114             :             , &add_command_line_options
     115             :             , &finish_init
     116             :             , &cleanup
     117           2 :         );
     118             : }
     119             : 
     120             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.14

Snap C++ | List of projects | List of versions