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 : *
24 : * Zipios++ unit tests for various stream and buffer classes.
25 : */
26 :
27 : #include "catch_tests.hpp"
28 :
29 : #include "zipios++/zipfile.hpp"
30 : #include "zipios++/zipiosexceptions.hpp"
31 : #include "src/filterinputstreambuf.hpp"
32 : #include "src/filteroutputstreambuf.hpp"
33 :
34 : #include "src/dostime.h"
35 :
36 : #include <fstream>
37 :
38 : #include <unistd.h>
39 : #include <string.h>
40 :
41 :
42 :
43 :
44 :
45 4 : TEST_CASE("An input filter", "[Buffer]")
46 : {
47 3 : SECTION("Valid input stream buffer")
48 : {
49 1 : zipios_test::auto_unlink_t auto_unlink("input.buf");
50 : {
51 1 : std::ofstream out("input.buf", std::ios::out | std::ios::binary);
52 1 : out << "Test file" << std::endl;
53 : }
54 :
55 2 : std::unique_ptr<std::ifstream> in_ptr(new std::ifstream("input.buf", std::ios::in | std::ios::binary));
56 2 : std::unique_ptr<zipios::FilterInputStreambuf> buf_ptr(new zipios::FilterInputStreambuf(in_ptr->rdbuf()));
57 3 : }
58 :
59 3 : SECTION("Invalid input stream buffer")
60 : {
61 1 : REQUIRE_THROWS_AS(new zipios::FilterInputStreambuf(nullptr), zipios::InvalidStateException);
62 3 : }
63 3 : }
64 :
65 :
66 4 : TEST_CASE("An output filter", "[Buffer]")
67 : {
68 3 : SECTION("Valid output stream buffer")
69 : {
70 1 : zipios_test::auto_unlink_t auto_unlink("output.buf");
71 :
72 2 : std::ofstream out("output.buf", std::ios::out | std::ios::binary);
73 2 : std::unique_ptr<zipios::FilterOutputStreambuf> buf_ptr(new zipios::FilterOutputStreambuf(out.rdbuf()));
74 3 : }
75 :
76 3 : SECTION("Invalid output stream buffer")
77 : {
78 1 : REQUIRE_THROWS_AS(new zipios::FilterOutputStreambuf(nullptr), zipios::InvalidStateException);
79 3 : }
80 6 : }
81 :
82 :
83 :
84 :
85 :
86 : // vim: ts=4 sw=4 et
87 :
88 : // Local Variables:
89 : // mode: cpp
90 : // indent-tabs-mode: nil
91 : // c-basic-offset: 4
92 : // tab-width: 4
93 : // End:
|