LCOV - code coverage report
Current view: top level - tests - stream.cpp (source / functions) Hit Total Coverage
Test: coverage.info Lines: 18 18 100.0 %
Date: 2019-04-24 14:10:30 Functions: 4 4 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-2019  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.1 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
      20             : */
      21             : 
      22             : /** \file
      23             :  *
      24             :  * Zipios unit tests for various stream and buffer classes.
      25             :  */
      26             : 
      27             : #include "tests.hpp"
      28             : 
      29             : #include "zipios/zipfile.hpp"
      30             : #include "zipios/zipiosexceptions.hpp"
      31             : 
      32             : #include "src/filterinputstreambuf.hpp"
      33             : #include "src/filteroutputstreambuf.hpp"
      34             : 
      35             : #include <fstream>
      36             : 
      37             : #include <unistd.h>
      38             : #include <string.h>
      39             : 
      40             : 
      41             : 
      42             : 
      43             : 
      44           3 : TEST_CASE("An input filter", "[Buffer]")
      45             : {
      46           4 :     SECTION("Valid input stream buffer")
      47             :     {
      48           2 :         zipios_test::auto_unlink_t auto_unlink("input.buf");
      49             :         {
      50           2 :             std::ofstream out("input.buf", std::ios::out | std::ios::binary);
      51           1 :             out << "Test file" << std::endl;
      52             :         }
      53             : 
      54           2 :         std::unique_ptr<std::ifstream> in_ptr(new std::ifstream("input.buf", std::ios::in | std::ios::binary));
      55           1 :         std::unique_ptr<zipios::FilterInputStreambuf> buf_ptr(new zipios::FilterInputStreambuf(in_ptr->rdbuf()));
      56             :     }
      57             : 
      58           4 :     SECTION("Invalid input stream buffer")
      59             :     {
      60           1 :         REQUIRE_THROWS_AS(new zipios::FilterInputStreambuf(nullptr), zipios::InvalidStateException);
      61             :     }
      62           2 : }
      63             : 
      64             : 
      65           3 : TEST_CASE("An output filter", "[Buffer]")
      66             : {
      67           4 :     SECTION("Valid output stream buffer")
      68             :     {
      69           2 :         zipios_test::auto_unlink_t auto_unlink("output.buf");
      70             : 
      71           2 :         std::ofstream out("output.buf", std::ios::out | std::ios::binary);
      72           1 :         std::unique_ptr<zipios::FilterOutputStreambuf> buf_ptr(new zipios::FilterOutputStreambuf(out.rdbuf()));
      73             :     }
      74             : 
      75           4 :     SECTION("Invalid output stream buffer")
      76             :     {
      77           1 :         REQUIRE_THROWS_AS(new zipios::FilterOutputStreambuf(nullptr), zipios::InvalidStateException);
      78             :     }
      79           5 : }
      80             : 
      81             : 
      82             : 
      83             : 
      84             : 
      85             : // Local Variables:
      86             : // mode: cpp
      87             : // indent-tabs-mode: nil
      88             : // c-basic-offset: 4
      89             : // tab-width: 4
      90             : // End:
      91             : 
      92             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.12