LCOV - code coverage report
Current view: top level - tests - catch_main.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 8 8 100.0 %
Date: 2022-04-20 16:57:29 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2006-2022  Made to Order Software Corp.  All Rights Reserved
       2             : //
       3             : // https://snapwebsites.org/project/libutf8
       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             : #pragma once
      20             : 
      21             : // libutf8 lib
      22             : //
      23             : #include    <libutf8/libutf8.h>     // for the ostream
      24             : 
      25             : 
      26             : // catch2 lib
      27             : //
      28             : #include    <catch2/snapcatch2.hpp>
      29             : 
      30             : 
      31             : // C++ lib
      32             : //
      33             : #include    <string>
      34             : #include    <cstring>
      35             : #include    <cstdlib>
      36             : #include    <iostream>
      37             : 
      38             : 
      39             : // last include
      40             : //
      41             : #include    <snapdev/poison.h>
      42             : 
      43             : 
      44             : 
      45             : namespace SNAP_CATCH2_NAMESPACE
      46             : {
      47             : 
      48             : 
      49             : 
      50             : 
      51     2098473 : inline char32_t rand_char(bool full_range = false)
      52             : {
      53     2098473 :     char32_t const max((full_range ? 0x0110000 : 0x0010000) - (0xE000 - 0xD800));
      54             : 
      55             :     char32_t wc;
      56          29 :     do
      57             :     {
      58     2098502 :         wc = ((rand() << 16) ^ rand()) % max;
      59             :     }
      60     2098502 :     while(wc == 0);
      61     2098473 :     if(wc >= 0xD800)
      62             :     {
      63             :         // skip the surrogates
      64             :         //
      65      273456 :         wc += 0xE000 - 0xD800;
      66             :     }
      67             : 
      68     2098473 :     return wc;
      69             : }
      70             : 
      71             : 
      72             : 
      73             : }
      74             : // unittest namespace
      75             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.13