1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*
Copyright (C) 2019 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
DCP-o-matic is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
DCP-o-matic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
*/
/** @file test/reel_writer_test.cc
* @brief Test ReelWriter class.
* @ingroup selfcontained
*/
#include "lib/reel_writer.h"
#include "lib/film.h"
#include "lib/cross.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
using std::string;
using boost::shared_ptr;
using boost::optional;
static bool equal (dcp::FrameInfo a, ReelWriter const & writer, shared_ptr<InfoFileHandle> file, Frame frame, Eyes eyes)
{
dcp::FrameInfo b = writer.read_frame_info(file, frame, eyes);
return a.offset == b.offset && a.size == b.size && a.hash == b.hash;
}
BOOST_AUTO_TEST_CASE (write_frame_info_test)
{
shared_ptr<Film> film = new_test_film2 ("write_frame_info_test");
dcpomatic::DCPTimePeriod const period (dcpomatic::DCPTime(0), dcpomatic::DCPTime(96000));
ReelWriter writer (film, period, shared_ptr<Job>(), 0, 1, optional<string>());
/* Write the first one */
dcp::FrameInfo info1(0, 123, "12345678901234567890123456789012");
writer.write_frame_info (0, EYES_LEFT, info1);
{
shared_ptr<InfoFileHandle> file = film->info_file_handle(period, true);
BOOST_CHECK (equal(info1, writer, file, 0, EYES_LEFT));
}
/* Write some more */
dcp::FrameInfo info2(596, 14921, "123acb789f1234ae782012n456339522");
writer.write_frame_info (5, EYES_RIGHT, info2);
{
shared_ptr<InfoFileHandle> file = film->info_file_handle(period, true);
BOOST_CHECK (equal(info1, writer, file, 0, EYES_LEFT));
BOOST_CHECK (equal(info2, writer, file, 5, EYES_RIGHT));
}
dcp::FrameInfo info3(12494, 99157123, "xxxxyyyyabc12356ffsfdsf456339522");
writer.write_frame_info (10, EYES_LEFT, info3);
{
shared_ptr<InfoFileHandle> file = film->info_file_handle(period, true);
BOOST_CHECK (equal(info1, writer, file, 0, EYES_LEFT));
BOOST_CHECK (equal(info2, writer, file, 5, EYES_RIGHT));
BOOST_CHECK (equal(info3, writer, file, 10, EYES_LEFT));
}
/* Overwrite one */
dcp::FrameInfo info4(55512494, 123599157123, "ABCDEFGyabc12356ffsfdsf4563395ZZ");
writer.write_frame_info (5, EYES_RIGHT, info4);
{
shared_ptr<InfoFileHandle> file = film->info_file_handle(period, true);
BOOST_CHECK (equal(info1, writer, file, 0, EYES_LEFT));
BOOST_CHECK (equal(info4, writer, file, 5, EYES_RIGHT));
BOOST_CHECK (equal(info3, writer, file, 10, EYES_LEFT));
}
}
|