2 Copyright (C) 2019 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/>.
21 /** @file test/reel_writer_test.cc
22 * @brief Test ReelWriter class.
23 * @ingroup selfcontained
26 #include "lib/reel_writer.h"
28 #include "lib/cross.h"
30 #include <boost/test/unit_test.hpp>
33 using boost::shared_ptr;
34 using boost::optional;
36 static bool equal (dcp::FrameInfo a, ReelWriter const & writer, shared_ptr<InfoFileHandle> file, Frame frame, Eyes eyes)
38 dcp::FrameInfo b = writer.read_frame_info(file, frame, eyes);
39 return a.offset == b.offset && a.size == b.size && a.hash == b.hash;
42 BOOST_AUTO_TEST_CASE (write_frame_info_test)
44 shared_ptr<Film> film = new_test_film2 ("write_frame_info_test");
45 DCPTimePeriod const period (DCPTime(0), DCPTime(96000));
46 ReelWriter writer (film, period, shared_ptr<Job>(), 0, 1, optional<string>());
48 /* Write the first one */
50 dcp::FrameInfo info1(0, 123, "12345678901234567890123456789012");
51 writer.write_frame_info (0, EYES_LEFT, info1);
54 shared_ptr<InfoFileHandle> file = film->info_file_handle(period, true);
55 BOOST_CHECK (equal(info1, writer, file, 0, EYES_LEFT));
60 dcp::FrameInfo info2(596, 14921, "123acb789f1234ae782012n456339522");
61 writer.write_frame_info (5, EYES_RIGHT, info2);
64 shared_ptr<InfoFileHandle> file = film->info_file_handle(period, true);
65 BOOST_CHECK (equal(info1, writer, file, 0, EYES_LEFT));
66 BOOST_CHECK (equal(info2, writer, file, 5, EYES_RIGHT));
69 dcp::FrameInfo info3(12494, 99157123, "xxxxyyyyabc12356ffsfdsf456339522");
70 writer.write_frame_info (10, EYES_LEFT, info3);
73 shared_ptr<InfoFileHandle> file = film->info_file_handle(period, true);
74 BOOST_CHECK (equal(info1, writer, file, 0, EYES_LEFT));
75 BOOST_CHECK (equal(info2, writer, file, 5, EYES_RIGHT));
76 BOOST_CHECK (equal(info3, writer, file, 10, EYES_LEFT));
81 dcp::FrameInfo info4(55512494, 123599157123, "ABCDEFGyabc12356ffsfdsf4563395ZZ");
82 writer.write_frame_info (5, EYES_RIGHT, info4);
85 shared_ptr<InfoFileHandle> file = film->info_file_handle(period, true);
86 BOOST_CHECK (equal(info1, writer, file, 0, EYES_LEFT));
87 BOOST_CHECK (equal(info4, writer, file, 5, EYES_RIGHT));
88 BOOST_CHECK (equal(info3, writer, file, 10, EYES_LEFT));