2 Copyright (C) 2024 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic 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.
11 DCP-o-matic 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.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 /** @file test/unzipper_test.cc
23 * @brief Test Unzipper class.
24 * @ingroup selfcontained
28 #include "lib/exceptions.h"
29 #include "lib/unzipper.h"
30 #include "lib/zipper.h"
32 #include <dcp/filesystem.h>
34 #include <boost/test/unit_test.hpp>
35 #include <boost/filesystem.hpp>
41 /** Basic test of Unzipper working normally */
42 BOOST_AUTO_TEST_CASE(unzipper_test1)
44 boost::system::error_code ec;
45 boost::filesystem::remove("build/test/zipped.zip", ec);
47 Zipper zipper("build/test/zipped.zip");
48 zipper.add("foo.txt", "1234567890");
49 zipper.add("bar.txt", "xxxxxxCCCCbbbbbbb1");
50 zipper.add("its_bigger_than_that_chris_its_large.txt", string(128 * 1024, 'X'));
53 Unzipper unzipper("build/test/zipped.zip");
54 BOOST_CHECK_EQUAL(unzipper.get("foo.txt"), "1234567890");
55 BOOST_CHECK_EQUAL(unzipper.get("bar.txt"), "xxxxxxCCCCbbbbbbb1");
56 BOOST_CHECK_THROW(unzipper.get("hatstand"), std::runtime_error);
57 BOOST_CHECK_THROW(unzipper.get("its_bigger_than_that_chris_its_large.txt"), std::runtime_error);