LCOV - code coverage report
Current view: top level - tests - catch_main.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 100.0 % 5 5
Test Date: 2025-05-30 15:24:13 Functions: 100.0 % 1 1
Legend: Lines: hit not hit

            Line data    Source code
       1              : // Copyright (c) 2012-2024  Made to Order Software Corp.  All Rights Reserved
       2              : //
       3              : // https://snapwebsites.org/project/eventdispatcher
       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
      17              : // along with this program; if not, write to the Free Software
      18              : // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
      19              : #pragma once
      20              : 
      21              : // catch2
      22              : //
      23              : #include    <catch2/snapcatch2.hpp>
      24              : 
      25              : 
      26              : // snapdev
      27              : //
      28              : #include    <snapdev/mkdir_p.h>
      29              : 
      30              : 
      31              : // C++
      32              : //
      33              : #include    <string>
      34              : #include    <cstring>
      35              : #include    <cstdlib>
      36              : #include    <iostream>
      37              : 
      38              : 
      39              : 
      40              : namespace SNAP_CATCH2_NAMESPACE
      41              : {
      42              : 
      43              : 
      44              : 
      45              : extern char ** g_argv;
      46              : 
      47              : 
      48              : 
      49              : inline char32_t rand_char(bool full_range = false)
      50              : {
      51              :     char32_t const max((full_range ? 0x0110000 : 0x0010000) - (0xE000 - 0xD800));
      52              : 
      53              :     char32_t wc;
      54              :     do
      55              :     {
      56              :         wc = ((rand() << 16) ^ rand()) % max;
      57              :     }
      58              :     while(wc == 0);
      59              :     if(wc >= 0xD800)
      60              :     {
      61              :         // skip the surrogates
      62              :         //
      63              :         wc += 0xE000 - 0xD800;
      64              :     }
      65              : 
      66              :     return wc;
      67              : }
      68              : 
      69              : 
      70            3 : inline std::string get_tmp_dir(std::string const & subdir)
      71              : {
      72            3 :     std::string const & tmp_dir(SNAP_CATCH2_NAMESPACE::g_tmp_dir() + "/" + subdir);
      73              : 
      74            3 :     CATCH_REQUIRE(snapdev::mkdir_p(tmp_dir, false, 0700) == 0);
      75              : 
      76            6 :     return tmp_dir;
      77            3 : }
      78              : 
      79              : 
      80              : 
      81              : 
      82              : }
      83              : // namespace SNAP_CATCH2_NAMESPACE
      84              : // vim: ts=4 sw=4 et
        

Generated by: LCOV version 2.0-1

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