LCOV - code coverage report
Current view: top level - tests - catch_tests.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 14 14 100.0 %
Date: 2015-04-12 Functions: 3 3 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   Zipios++ - a small C++ library that provides easy access to .zip files.
       3             : 
       4             :   Copyright (C) 2000-2007  Thomas Sondergaard
       5             :   Copyright (C) 2015  Made to Order Software Corporation
       6             : 
       7             :   This library is free software; you can redistribute it and/or
       8             :   modify it under the terms of the GNU Lesser General Public
       9             :   License as published by the Free Software Foundation; either
      10             :   version 2 of the License, or (at your option) any later version.
      11             : 
      12             :   This library is distributed in the hope that it will be useful,
      13             :   but WITHOUT ANY WARRANTY; without even the implied warranty of
      14             :   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      15             :   Lesser General Public License for more details.
      16             : 
      17             :   You should have received a copy of the GNU Lesser General Public
      18             :   License along with this library; if not, write to the Free Software
      19             :   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
      20             : */
      21             : 
      22             : /** \file
      23             :  * \anchor catch_tests_anchor
      24             :  *
      25             :  * Zipios++ unit test suite using catch.hpp, see for details:
      26             :  *
      27             :  *   https://github.com/philsquared/Catch/blob/master/docs/tutorial.md
      28             :  */
      29             : 
      30             : // Ask Catch to define the main() function in this file
      31             : #define CATCH_CONFIG_RUNNER
      32             : 
      33             : #include "catch_tests.hpp"
      34             : 
      35             : #include <cstring>
      36             : 
      37             : #include <stdlib.h>
      38             : 
      39             : 
      40             : // static variables
      41             : namespace
      42             : {
      43             : 
      44             : char *g_progname;
      45             : 
      46             : }
      47             : 
      48             : 
      49           1 : int main(int argc, char *argv[])
      50             : {
      51             :     // define program name
      52           1 :     g_progname = argv[0];
      53           1 :     char *e(strrchr(g_progname, '/'));
      54           1 :     if(e)
      55             :     {
      56             :         g_progname = e + 1; // LCOV_EXCL_LINE
      57             :     }
      58           1 :     e = strrchr(g_progname, '\\');
      59           1 :     if(e)
      60             :     {
      61             :         g_progname = e + 1; // LCOV_EXCL_LINE
      62             :     }
      63             : 
      64           1 :     unsigned int seed(static_cast<unsigned int>(time(nullptr)));
      65           1 :     bool help(false);
      66           1 :     for(int i(1); i < argc; ++i)
      67             :     {
      68             :         if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0) // LCOV_EXCL_LINE
      69             :         {
      70             :             help = true; // LCOV_EXCL_LINE
      71             :         }
      72             :         else if(strcmp(argv[i], "--seed") == 0) // LCOV_EXCL_LINE
      73             :         {
      74             :             if(i + 1 >= argc) // LCOV_EXCL_LINE
      75             :             {
      76             :                 std::cerr << "error: --seed need to be followed by the actual seed." << std::endl; // LCOV_EXCL_LINE
      77             :                 exit(1); // LCOV_EXCL_LINE
      78             :             }
      79             :             seed = atoll(argv[i + 1]); // LCOV_EXCL_LINE
      80             :             // remove the --seed and <value>
      81             :             for(int j(i); j + 2 < argc; ++j) // LCOV_EXCL_LINE
      82             :             {
      83             :                 argv[j] = argv[j + 2]; // LCOV_EXCL_LINE
      84             :             }
      85             :             argc -= 2; // LCOV_EXCL_LINE
      86             :         }
      87             :     }
      88           1 :     srand(seed);
      89           1 :     std::cout << g_progname << "[" << getpid() << "]" << ": version " << ZIPIOS_VERSION_STRING << ", seed is " << seed << std::endl;
      90             : 
      91           1 :     if(help)
      92             :     {
      93             :         std::cout << std::endl // LCOV_EXCL_LINE
      94             :                   << "WARNING: at this point we hack the main() to add the following options:" << std::endl // LCOV_EXCL_LINE
      95             :                   << "  --seed <seed>    to force the seed at the start of the process to a specific value (i.e. to reproduce the exact same test over and over again)" << std::endl // LCOV_EXCL_LINE
      96             :                   << std::endl; // LCOV_EXCL_LINE
      97             :     }
      98             : 
      99           1 :     return Catch::Session().run(argc, argv);
     100           3 : }
     101             : 
     102             : 
     103             : 
     104             : // Local Variables:
     105             : // mode: cpp
     106             : // indent-tabs-mode: nil
     107             : // c-basic-offset: 4
     108             : // tab-width: 4
     109             : // End:
     110             : 
     111             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.10