summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-04-29 09:14:20 +0200
committerCarl Hetherington <cth@carlh.net>2021-04-29 20:53:49 +0200
commit39fb8198febde1937019db1c300ec363aab5aa56 (patch)
tree52bc32134e8ae2b5587b3a62130baa9acf815b60 /test
parentb249700e1da7dd6631a8b4440587f4093a2bdef1 (diff)
C++11 tidying.
Diffstat (limited to 'test')
-rw-r--r--test/4k_test.cc10
-rw-r--r--test/audio_analysis_test.cc96
-rw-r--r--test/audio_filter_test.cc19
-rw-r--r--test/audio_processor_delay_test.cc23
-rw-r--r--test/butler_test.cc20
-rw-r--r--test/client_server_test.cc23
-rw-r--r--test/config_test.cc5
-rw-r--r--test/crypto_test.cc7
-rw-r--r--test/disk_writer_test.cc2
-rw-r--r--test/empty_test.cc46
-rw-r--r--test/ffmpeg_decoder_sequential_test.cc20
-rw-r--r--test/ffmpeg_pts_offset_test.cc13
-rw-r--r--test/isdcf_name_test.cc2
-rw-r--r--test/job_test.cc16
-rw-r--r--test/markers_test.cc2
-rw-r--r--test/pixel_formats_test.cc55
-rw-r--r--test/rect_test.cc11
-rw-r--r--test/silence_padding_test.cc8
-rw-r--r--test/threed_test.cc4
-rw-r--r--test/time_calculation_test.cc45
-rw-r--r--test/torture_test.cc8
-rw-r--r--test/video_level_test.cc46
-rw-r--r--test/zipper_test.cc7
23 files changed, 290 insertions, 198 deletions
diff --git a/test/4k_test.cc b/test/4k_test.cc
index f3ce0bfcc..4db576cfc 100644
--- a/test/4k_test.cc
+++ b/test/4k_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,6 +18,7 @@
*/
+
/** @defgroup completedcp Complete builds of DCPs */
/** @file test/4k_test.cc
@@ -27,6 +28,7 @@
* The output is checked against test/data/4k_test.
*/
+
#include <boost/test/unit_test.hpp>
#include "lib/film.h"
#include "lib/ffmpeg_content.h"
@@ -36,9 +38,11 @@
#include "lib/dcpomatic_log.h"
#include "test.h"
+
using std::shared_ptr;
using std::make_shared;
+
BOOST_AUTO_TEST_CASE (fourk_test)
{
auto film = new_test_film ("4k_test");
@@ -58,8 +62,8 @@ BOOST_AUTO_TEST_CASE (fourk_test)
dcp::VerificationNote::Code::MISSING_FFEC_IN_FEATURE
});
- boost::filesystem::path p (test_film_dir ("4k_test"));
+ boost::filesystem::path p (test_film_dir("4k_test"));
p /= film->dcp_name ();
- check_dcp ("test/data/4k_test", p.string ());
+ check_dcp ("test/data/4k_test", p.string());
}
diff --git a/test/audio_analysis_test.cc b/test/audio_analysis_test.cc
index 9da286746..e131ce57c 100644
--- a/test/audio_analysis_test.cc
+++ b/test/audio_analysis_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,6 +18,7 @@
*/
+
/** @defgroup selfcontained Self-contained tests of single classes / method sets */
/** @file test/audio_analysis_test.cc
@@ -25,36 +26,38 @@
* @ingroup selfcontained
*/
-#include <boost/test/unit_test.hpp>
-#include "lib/audio_analysis.h"
+
+#include "test.h"
#include "lib/analyse_audio_job.h"
-#include "lib/film.h"
-#include "lib/ffmpeg_content.h"
+#include "lib/audio_analysis.h"
+#include "lib/audio_content.h"
+#include "lib/content_factory.h"
#include "lib/dcp_content_type.h"
#include "lib/ffmpeg_content.h"
-#include "lib/ratio.h"
+#include "lib/ffmpeg_content.h"
+#include "lib/film.h"
#include "lib/job_manager.h"
-#include "lib/audio_content.h"
-#include "lib/content_factory.h"
#include "lib/playlist.h"
-#include "test.h"
+#include "lib/ratio.h"
+#include <boost/test/unit_test.hpp>
#include <iostream>
-using std::vector;
+
+using std::make_shared;
using std::shared_ptr;
+using std::vector;
using namespace dcpomatic;
-static float
-random_float ()
-{
- return (float (rand ()) / RAND_MAX) * 2 - 1;
-}
BOOST_AUTO_TEST_CASE (audio_analysis_serialisation_test)
{
int const channels = 3;
int const points = 4096;
+ auto random_float = []() {
+ return (float (rand ()) / RAND_MAX) * 2 - 1;
+ };
+
AudioAnalysis a (3);
for (int i = 0; i < channels; ++i) {
for (int j = 0; j < points; ++j) {
@@ -67,7 +70,7 @@ BOOST_AUTO_TEST_CASE (audio_analysis_serialisation_test)
vector<AudioAnalysis::PeakTime> peak;
for (int i = 0; i < channels; ++i) {
- peak.push_back (AudioAnalysis::PeakTime (random_float(), DCPTime (rand())));
+ peak.push_back (AudioAnalysis::PeakTime(random_float(), DCPTime(rand())));
}
a.set_sample_peak (peak);
@@ -96,58 +99,52 @@ BOOST_AUTO_TEST_CASE (audio_analysis_serialisation_test)
BOOST_CHECK_EQUAL (a.sample_rate(), 48000);
}
-static void
-finished ()
-{
-
-}
BOOST_AUTO_TEST_CASE (audio_analysis_test)
{
- shared_ptr<Film> film = new_test_film ("audio_analysis_test");
- film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
- film->set_container (Ratio::from_id ("185"));
+ auto film = new_test_film ("audio_analysis_test");
+ film->set_dcp_content_type (DCPContentType::from_isdcf_name("FTR"));
+ film->set_container (Ratio::from_id("185"));
film->set_name ("audio_analysis_test");
boost::filesystem::path p = TestPaths::private_data() / "betty_L.wav";
- shared_ptr<FFmpegContent> c (new FFmpegContent(p));
+ auto c = make_shared<FFmpegContent>(p);
film->examine_and_add_content (c);
BOOST_REQUIRE (!wait_for_jobs());
- shared_ptr<AnalyseAudioJob> job (new AnalyseAudioJob (film, film->playlist(), false));
- job->Finished.connect (boost::bind (&finished));
+ auto job = make_shared<AnalyseAudioJob>(film, film->playlist(), false);
JobManager::instance()->add (job);
BOOST_REQUIRE (!wait_for_jobs());
}
+
/** Check that audio analysis works (i.e. runs without error) with a -ve delay */
BOOST_AUTO_TEST_CASE (audio_analysis_negative_delay_test)
{
- shared_ptr<Film> film = new_test_film ("audio_analysis_negative_delay_test");
+ auto film = new_test_film ("audio_analysis_negative_delay_test");
film->set_name ("audio_analysis_negative_delay_test");
- shared_ptr<FFmpegContent> c (new FFmpegContent(TestPaths::private_data() / "boon_telly.mkv"));
+ auto c = make_shared<FFmpegContent>(TestPaths::private_data() / "boon_telly.mkv");
film->examine_and_add_content (c);
BOOST_REQUIRE (!wait_for_jobs());
c->audio->set_delay (-250);
- shared_ptr<AnalyseAudioJob> job (new AnalyseAudioJob (film, film->playlist(), false));
- job->Finished.connect (boost::bind (&finished));
+ auto job = make_shared<AnalyseAudioJob>(film, film->playlist(), false);
JobManager::instance()->add (job);
BOOST_REQUIRE (!wait_for_jobs());
}
+
/** Check audio analysis that is incorrect in 2e98263 */
BOOST_AUTO_TEST_CASE (audio_analysis_test2)
{
- shared_ptr<Film> film = new_test_film ("audio_analysis_test2");
+ auto film = new_test_film ("audio_analysis_test2");
film->set_name ("audio_analysis_test2");
- shared_ptr<FFmpegContent> c (new FFmpegContent(TestPaths::private_data() / "3d_thx_broadway_2010_lossless.m2ts"));
+ auto c = make_shared<FFmpegContent>(TestPaths::private_data() / "3d_thx_broadway_2010_lossless.m2ts");
film->examine_and_add_content (c);
BOOST_REQUIRE (!wait_for_jobs());
- shared_ptr<AnalyseAudioJob> job (new AnalyseAudioJob (film, film->playlist(), false));
- job->Finished.connect (boost::bind (&finished));
+ auto job = make_shared<AnalyseAudioJob>(film, film->playlist(), false);
JobManager::instance()->add (job);
BOOST_REQUIRE (!wait_for_jobs());
}
@@ -161,57 +158,60 @@ analysis_finished ()
done = true;
}
+
/* Test a case which was reported to throw an exception; analysing
* a 12-channel DCP's audio.
*/
BOOST_AUTO_TEST_CASE (audio_analysis_test3)
{
- shared_ptr<Film> film = new_test_film ("analyse_audio_test");
+ auto film = new_test_film ("analyse_audio_test");
film->set_container (Ratio::from_id ("185"));
- film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
+ film->set_dcp_content_type (DCPContentType::from_isdcf_name("TLR"));
film->set_name ("frobozz");
- shared_ptr<FFmpegContent> content (new FFmpegContent("test/data/white.wav"));
+ auto content = make_shared<FFmpegContent>("test/data/white.wav");
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
film->set_audio_channels (12);
boost::signals2::connection connection;
- JobManager::instance()->analyse_audio (film, film->playlist(), false, connection, boost::bind (&analysis_finished));
+ JobManager::instance()->analyse_audio(film, film->playlist(), false, connection, boost::bind(&analysis_finished));
BOOST_REQUIRE (!wait_for_jobs());
BOOST_CHECK (done);
}
+
/** Run an audio analysis that triggered an exception in the audio decoder at one point */
BOOST_AUTO_TEST_CASE (analyse_audio_test4)
{
- shared_ptr<Film> film = new_test_film ("analyse_audio_test");
+ auto film = new_test_film ("analyse_audio_test");
film->set_container (Ratio::from_id ("185"));
- film->set_dcp_content_type (DCPContentType::from_isdcf_name ("TLR"));
+ film->set_dcp_content_type (DCPContentType::from_isdcf_name("TLR"));
film->set_name ("frobozz");
- shared_ptr<Content> content = content_factory(TestPaths::private_data() / "20 The Wedding Convoy Song.m4a").front();
+ auto content = content_factory(TestPaths::private_data() / "20 The Wedding Convoy Song.m4a").front();
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
- shared_ptr<Playlist> playlist (new Playlist);
+ auto playlist = make_shared<Playlist>();
playlist->add (film, content);
boost::signals2::connection c;
- JobManager::instance()->analyse_audio (film, playlist, false, c, boost::bind (&finished));
+ JobManager::instance()->analyse_audio(film, playlist, false, c, []() {});
BOOST_CHECK (!wait_for_jobs ());
}
+
BOOST_AUTO_TEST_CASE (analyse_audio_leqm_test)
{
- shared_ptr<Film> film = new_test_film2 ("analyse_audio_leqm_test");
+ auto film = new_test_film2 ("analyse_audio_leqm_test");
film->set_audio_channels (2);
- shared_ptr<Content> content = content_factory(TestPaths::private_data() / "betty_stereo_48k.wav").front();
+ auto content = content_factory(TestPaths::private_data() / "betty_stereo_48k.wav").front();
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
- shared_ptr<Playlist> playlist (new Playlist);
+ auto playlist = make_shared<Playlist>();
playlist->add (film, content);
boost::signals2::connection c;
- JobManager::instance()->analyse_audio (film, playlist, false, c, boost::bind (&finished));
+ JobManager::instance()->analyse_audio(film, playlist, false, c, []() {});
BOOST_CHECK (!wait_for_jobs());
AudioAnalysis analysis(film->audio_analysis_path(playlist));
diff --git a/test/audio_filter_test.cc b/test/audio_filter_test.cc
index 13b098910..d4fc550f1 100644
--- a/test/audio_filter_test.cc
+++ b/test/audio_filter_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,17 +18,22 @@
*/
+
/** @file test/audio_filter_test.cc
* @brief Test AudioFilter, LowPassAudioFilter, HighPassAudioFilter classes.
* @ingroup selfcontained
*/
+
#include <boost/test/unit_test.hpp>
#include "lib/audio_filter.h"
#include "lib/audio_buffers.h"
+
+using std::make_shared;
using std::shared_ptr;
+
static void
audio_filter_impulse_test_one (AudioFilter& f, int block_size, int num_blocks)
{
@@ -36,12 +41,12 @@ audio_filter_impulse_test_one (AudioFilter& f, int block_size, int num_blocks)
for (int i = 0; i < num_blocks; ++i) {
- shared_ptr<AudioBuffers> in (new AudioBuffers (1, block_size));
+ auto in = make_shared<AudioBuffers>(1, block_size);
for (int j = 0; j < block_size; ++j) {
in->data()[0][j] = c + j;
}
- shared_ptr<AudioBuffers> out = f.run (in);
+ auto out = f.run (in);
for (int j = 0; j < out->frames(); ++j) {
BOOST_CHECK_EQUAL (out->data()[0][j], c + j);
@@ -51,6 +56,7 @@ audio_filter_impulse_test_one (AudioFilter& f, int block_size, int num_blocks)
}
}
+
/** Create a filter with an impulse as a kernel and check that it
* passes data through unaltered.
*/
@@ -70,6 +76,7 @@ BOOST_AUTO_TEST_CASE (audio_filter_impulse_kernel_test)
audio_filter_impulse_test_one (f, 2048, 1);
}
+
/** Create filters and pass them impulses as input and check that
* the filter kernels comes back.
*/
@@ -77,11 +84,11 @@ BOOST_AUTO_TEST_CASE (audio_filter_impulse_input_test)
{
LowPassAudioFilter lpf (0.02, 0.3);
- shared_ptr<AudioBuffers> in (new AudioBuffers (1, 1751));
+ auto in = make_shared<AudioBuffers>(1, 1751);
in->make_silent ();
in->data(0)[0] = 1;
- shared_ptr<AudioBuffers> out = lpf.run (in);
+ auto out = lpf.run (in);
for (int j = 0; j < out->frames(); ++j) {
if (j <= lpf._M) {
BOOST_CHECK_EQUAL (out->data(0)[j], lpf._ir[j]);
@@ -92,7 +99,7 @@ BOOST_AUTO_TEST_CASE (audio_filter_impulse_input_test)
HighPassAudioFilter hpf (0.02, 0.3);
- in.reset (new AudioBuffers (1, 9133));
+ in = make_shared<AudioBuffers>(1, 9133);
in->make_silent ();
in->data(0)[0] = 1;
diff --git a/test/audio_processor_delay_test.cc b/test/audio_processor_delay_test.cc
index 6fd644a7e..47a1cc8ad 100644
--- a/test/audio_processor_delay_test.cc
+++ b/test/audio_processor_delay_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,27 +18,33 @@
*/
+
/** @file test/audio_processor_delay_test.cc
* @brief Test the AudioDelay class.
* @ingroup selfcontained
*/
-#include "lib/audio_delay.h"
+
#include "lib/audio_buffers.h"
+#include "lib/audio_delay.h"
#include <boost/test/unit_test.hpp>
#include <cmath>
#include <iostream>
+
using std::cerr;
using std::cout;
+using std::make_shared;
using std::shared_ptr;
+
#define CHECK_SAMPLE(c,f,r) \
if (fabs(out->data(c)[f] - (r)) > 0.1) { \
cerr << "Sample " << f << " at line " << __LINE__ << " is " << out->data(c)[f] << " not " << r << "; difference is " << fabs(out->data(c)[f] - (r)) << "\n"; \
BOOST_REQUIRE (fabs(out->data(c)[f] - (r)) <= 0.1); \
}
+
/** Block size greater than delay */
BOOST_AUTO_TEST_CASE (audio_processor_delay_test1)
{
@@ -46,14 +52,14 @@ BOOST_AUTO_TEST_CASE (audio_processor_delay_test1)
int const C = 2;
- shared_ptr<AudioBuffers> in (new AudioBuffers (C, 256));
+ auto in = make_shared<AudioBuffers>(C, 256);
for (int i = 0; i < C; ++i) {
for (int j = 0; j < 256; ++j) {
in->data(i)[j] = j;
}
}
- shared_ptr<AudioBuffers> out = delay.run (in);
+ auto out = delay.run (in);
BOOST_REQUIRE_EQUAL (out->frames(), in->frames());
/* Silence at the start */
@@ -86,6 +92,7 @@ BOOST_AUTO_TEST_CASE (audio_processor_delay_test1)
}
}
+
/** Block size less than delay */
BOOST_AUTO_TEST_CASE (audio_processor_delay_test2)
{
@@ -96,14 +103,14 @@ BOOST_AUTO_TEST_CASE (audio_processor_delay_test2)
/* Feeding 4 blocks of 64 should give silence each time */
for (int i = 0; i < 4; ++i) {
- shared_ptr<AudioBuffers> in (new AudioBuffers (C, 64));
+ auto in = make_shared<AudioBuffers>(C, 64);
for (int j = 0; j < C; ++j) {
for (int k = 0; k < 64; ++k) {
in->data(j)[k] = k + i * 64;
}
}
- shared_ptr<AudioBuffers> out = delay.run (in);
+ auto out = delay.run (in);
BOOST_REQUIRE_EQUAL (out->frames(), in->frames());
/* Check for silence */
@@ -117,9 +124,9 @@ BOOST_AUTO_TEST_CASE (audio_processor_delay_test2)
/* Now feed 4 blocks of silence and we should see the data */
for (int i = 0; i < 4; ++i) {
/* Feed some silence */
- shared_ptr<AudioBuffers> in (new AudioBuffers (C, 64));
+ auto in = make_shared<AudioBuffers>(C, 64);
in->make_silent ();
- shared_ptr<AudioBuffers> out = delay.run (in);
+ auto out = delay.run (in);
/* Should now see the delayed data */
for (int j = 0; j < C; ++j) {
diff --git a/test/butler_test.cc b/test/butler_test.cc
index 016767e1c..dbd7a287e 100644
--- a/test/butler_test.cc
+++ b/test/butler_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2017 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2017-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,6 +18,7 @@
*/
+
#include "lib/butler.h"
#include "lib/film.h"
#include "lib/dcp_content_type.h"
@@ -28,34 +29,37 @@
#include "test.h"
#include <boost/test/unit_test.hpp>
+
+using std::make_shared;
using std::shared_ptr;
#if BOOST_VERSION >= 106100
using namespace boost::placeholders;
#endif
using namespace dcpomatic;
+
BOOST_AUTO_TEST_CASE (butler_test1)
{
- shared_ptr<Film> film = new_test_film ("butler_test1");
- film->set_dcp_content_type (DCPContentType::from_isdcf_name ("FTR"));
+ auto film = new_test_film ("butler_test1");
+ film->set_dcp_content_type (DCPContentType::from_isdcf_name("FTR"));
film->set_name ("butler_test1");
film->set_container (Ratio::from_id ("185"));
- shared_ptr<Content> video = content_factory("test/data/flat_red.png").front ();
+ auto video = content_factory("test/data/flat_red.png").front();
film->examine_and_add_content (video);
- shared_ptr<Content> audio = content_factory("test/data/staircase.wav").front ();
+ auto audio = content_factory("test/data/staircase.wav").front();
film->examine_and_add_content (audio);
BOOST_REQUIRE (!wait_for_jobs ());
film->set_audio_channels (6);
/* This is the map of the player output (5.1) to the butler output (also 5.1) */
- AudioMapping map = AudioMapping (6, 6);
+ auto map = AudioMapping (6, 6);
for (int i = 0; i < 6; ++i) {
map.set (i, i, 1);
}
- Butler butler (film, shared_ptr<Player>(new Player(film)), map, 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, false);
+ Butler butler (film, make_shared<Player>(film), map, 6, bind(&PlayerVideo::force, _1, AV_PIX_FMT_RGB24), VideoRange::FULL, false, false);
BOOST_CHECK (butler.get_video(true, 0).second == DCPTime());
BOOST_CHECK (butler.get_video(true, 0).second == DCPTime::from_frames(1, 24));
@@ -63,7 +67,7 @@ BOOST_AUTO_TEST_CASE (butler_test1)
/* XXX: check the frame contents */
float buffer[256 * 6];
- BOOST_REQUIRE (butler.get_audio (buffer, 256) == DCPTime());
+ BOOST_REQUIRE (butler.get_audio(buffer, 256) == DCPTime());
for (int i = 0; i < 256; ++i) {
BOOST_REQUIRE_EQUAL (buffer[i * 6 + 0], 0);
BOOST_REQUIRE_EQUAL (buffer[i * 6 + 1], 0);
diff --git a/test/client_server_test.cc b/test/client_server_test.cc
index 3dceb31b0..f518f9383 100644
--- a/test/client_server_test.cc
+++ b/test/client_server_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,6 +18,7 @@
*/
+
/** @file test/client_server_test.cc
* @brief Test the server class.
* @ingroup feature
@@ -27,28 +28,31 @@
* encoded data to check that they are the same.
*/
-#include "lib/encode_server.h"
-#include "lib/image.h"
+
#include "lib/cross.h"
#include "lib/dcp_video.h"
-#include "lib/player_video.h"
-#include "lib/raw_image_proxy.h"
-#include "lib/j2k_image_proxy.h"
+#include "lib/dcpomatic_log.h"
+#include "lib/encode_server.h"
#include "lib/encode_server_description.h"
#include "lib/file_log.h"
-#include "lib/dcpomatic_log.h"
+#include "lib/image.h"
+#include "lib/j2k_image_proxy.h"
+#include "lib/player_video.h"
+#include "lib/raw_image_proxy.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
#include <boost/thread.hpp>
+
using std::list;
+using std::make_shared;
using std::shared_ptr;
using std::weak_ptr;
-using std::make_shared;
using boost::thread;
using boost::optional;
using dcp::ArrayData;
+
void
do_remote_encode (shared_ptr<DCPVideo> frame, EncodeServerDescription description, ArrayData locally_encoded)
{
@@ -59,6 +63,7 @@ do_remote_encode (shared_ptr<DCPVideo> frame, EncodeServerDescription descriptio
BOOST_CHECK_EQUAL (memcmp (locally_encoded.data(), remotely_encoded.data(), locally_encoded.size()), 0);
}
+
BOOST_AUTO_TEST_CASE (client_server_test_rgb)
{
auto image = make_shared<Image>(AV_PIX_FMT_RGB24, dcp::Size (1998, 1080), true);
@@ -145,6 +150,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_rgb)
delete server;
}
+
BOOST_AUTO_TEST_CASE (client_server_test_yuv)
{
auto image = make_shared<Image>(AV_PIX_FMT_YUV420P, dcp::Size (1998, 1080), true);
@@ -227,6 +233,7 @@ BOOST_AUTO_TEST_CASE (client_server_test_yuv)
delete server;
}
+
BOOST_AUTO_TEST_CASE (client_server_test_j2k)
{
auto image = make_shared<Image>(AV_PIX_FMT_YUV420P, dcp::Size (1998, 1080), true);
diff --git a/test/config_test.cc b/test/config_test.cc
index 67c00cf41..d78b9357b 100644
--- a/test/config_test.cc
+++ b/test/config_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,13 +18,16 @@
*/
+
#include "lib/config.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
#include <fstream>
+
using std::ofstream;
+
static void
rewrite_bad_config ()
{
diff --git a/test/crypto_test.cc b/test/crypto_test.cc
index 26c6748b8..53451b352 100644
--- a/test/crypto_test.cc
+++ b/test/crypto_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2018-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,15 +18,18 @@
*/
+
#include "lib/crypto.h"
#include "lib/exceptions.h"
#include "test.h"
#include <openssl/rand.h>
#include <boost/test/unit_test.hpp>
+
using std::string;
using std::list;
+
BOOST_AUTO_TEST_CASE (crypto_test)
{
dcp::ArrayData key (dcpomatic::crypto_key_length());
@@ -34,7 +37,7 @@ BOOST_AUTO_TEST_CASE (crypto_test)
RAND_bytes (key.data(), dcpomatic::crypto_key_length());
- dcp::ArrayData ciphertext = dcpomatic::encrypt ("Can you see any fish?", key, iv);
+ auto ciphertext = dcpomatic::encrypt ("Can you see any fish?", key, iv);
BOOST_REQUIRE_EQUAL (dcpomatic::decrypt (ciphertext, key, iv), "Can you see any fish?");
key.data()[5]++;
diff --git a/test/disk_writer_test.cc b/test/disk_writer_test.cc
index 37c8f42d5..1146c2e1b 100644
--- a/test/disk_writer_test.cc
+++ b/test/disk_writer_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
diff --git a/test/empty_test.cc b/test/empty_test.cc
index 8a42bd6b8..b186954b3 100644
--- a/test/empty_test.cc
+++ b/test/empty_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2017-2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2017-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,22 +18,25 @@
*/
+
/** @file test/empty_test.cc
* @brief Test the creation of Empty objects.
* @ingroup feature
*/
-#include "lib/film.h"
+
#include "lib/dcp_content_type.h"
-#include "lib/ratio.h"
-#include "lib/video_content.h"
-#include "lib/image_content.h"
+#include "lib/decoder.h"
#include "lib/empty.h"
+#include "lib/film.h"
+#include "lib/image_content.h"
#include "lib/player.h"
-#include "lib/decoder.h"
+#include "lib/ratio.h"
+#include "lib/video_content.h"
#include "test.h"
#include <boost/test/unit_test.hpp>
+
using std::list;
using std::make_shared;
using std::shared_ptr;
@@ -42,18 +45,20 @@ using namespace boost::placeholders;
#endif
using namespace dcpomatic;
+
bool
has_video (shared_ptr<const Content> content)
{
return static_cast<bool>(content->video);
}
+
BOOST_AUTO_TEST_CASE (empty_test1)
{
- shared_ptr<Film> film = new_test_film2 ("empty_test1");
+ auto film = new_test_film2 ("empty_test1");
film->set_sequence (false);
- shared_ptr<ImageContent> contentA (new ImageContent("test/data/simple_testcard_640x480.png"));
- shared_ptr<ImageContent> contentB (new ImageContent("test/data/simple_testcard_640x480.png"));
+ auto contentA = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
+ auto contentB = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
film->examine_and_add_content (contentA);
film->examine_and_add_content (contentB);
@@ -65,13 +70,13 @@ BOOST_AUTO_TEST_CASE (empty_test1)
* A A A B
*/
contentA->video->set_length (3);
- contentA->set_position (film, DCPTime::from_frames (2, vfr));
+ contentA->set_position (film, DCPTime::from_frames(2, vfr));
contentB->video->set_length (1);
- contentB->set_position (film, DCPTime::from_frames (7, vfr));
+ contentB->set_position (film, DCPTime::from_frames(7, vfr));
Empty black (film, film->playlist(), bind(&has_video, _1), film->playlist()->length(film));
BOOST_REQUIRE_EQUAL (black._periods.size(), 2U);
- list<dcpomatic::DCPTimePeriod>::const_iterator i = black._periods.begin();
+ auto i = black._periods.begin();
BOOST_CHECK (i->from == DCPTime::from_frames(0, vfr));
BOOST_CHECK (i->to == DCPTime::from_frames(2, vfr));
++i;
@@ -79,13 +84,14 @@ BOOST_AUTO_TEST_CASE (empty_test1)
BOOST_CHECK (i->to == DCPTime::from_frames(7, vfr));
}
+
/** Some tests where the first empty period is not at time 0 */
BOOST_AUTO_TEST_CASE (empty_test2)
{
- shared_ptr<Film> film = new_test_film2 ("empty_test2");
+ auto film = new_test_film2 ("empty_test2");
film->set_sequence (false);
- shared_ptr<ImageContent> contentA (new ImageContent("test/data/simple_testcard_640x480.png"));
- shared_ptr<ImageContent> contentB (new ImageContent("test/data/simple_testcard_640x480.png"));
+ auto contentA = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
+ auto contentB = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
film->examine_and_add_content (contentA);
film->examine_and_add_content (contentB);
@@ -117,13 +123,14 @@ BOOST_AUTO_TEST_CASE (empty_test2)
BOOST_CHECK (black.done ());
}
+
/** Test for when the film's playlist is not the same as the one passed into Empty */
BOOST_AUTO_TEST_CASE (empty_test3)
{
- shared_ptr<Film> film = new_test_film2 ("empty_test3");
+ auto film = new_test_film2 ("empty_test3");
film->set_sequence (false);
- shared_ptr<ImageContent> contentA (new ImageContent("test/data/simple_testcard_640x480.png"));
- shared_ptr<ImageContent> contentB (new ImageContent("test/data/simple_testcard_640x480.png"));
+ auto contentA = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
+ auto contentB = make_shared<ImageContent>("test/data/simple_testcard_640x480.png");
film->examine_and_add_content (contentA);
film->examine_and_add_content (contentB);
@@ -139,7 +146,7 @@ BOOST_AUTO_TEST_CASE (empty_test3)
contentB->video->set_length (1);
contentB->set_position (film, DCPTime::from_frames(7, vfr));
- shared_ptr<Playlist> playlist (new Playlist);
+ auto playlist = make_shared<Playlist>();
playlist->add (film, contentB);
Empty black (film, playlist, bind(&has_video, _1), playlist->length(film));
BOOST_REQUIRE_EQUAL (black._periods.size(), 1U);
@@ -150,6 +157,7 @@ BOOST_AUTO_TEST_CASE (empty_test3)
BOOST_CHECK (black.position() == DCPTime::from_frames(0, vfr));
}
+
BOOST_AUTO_TEST_CASE (empty_test_with_overlapping_content)
{
auto film = new_test_film2 ("empty_test_with_overlapping_content");
diff --git a/test/ffmpeg_decoder_sequential_test.cc b/test/ffmpeg_decoder_sequential_test.cc
index f81ebda9c..b2069a8b1 100644
--- a/test/ffmpeg_decoder_sequential_test.cc
+++ b/test/ffmpeg_decoder_sequential_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,12 +18,14 @@
*/
+
/** @file test/ffmpeg_decoder_sequential_test.cc
* @brief Check that the FFmpeg decoder and Player produce sequential frames without gaps or dropped frames;
* Also that the decoder picks up frame rates correctly.
* @ingroup feature
*/
+
#include "lib/ffmpeg_content.h"
#include "lib/ffmpeg_decoder.h"
#include "lib/content_video.h"
@@ -36,9 +38,11 @@
#include <boost/test/unit_test.hpp>
#include <iostream>
-using std::cout;
+
using std::cerr;
+using std::cout;
using std::list;
+using std::make_shared;
using std::shared_ptr;
using boost::optional;
using boost::bind;
@@ -47,9 +51,11 @@ using namespace boost::placeholders;
#endif
using namespace dcpomatic;
+
static DCPTime next;
static DCPTime frame;
+
static void
check (shared_ptr<PlayerVideo>, DCPTime time)
{
@@ -57,18 +63,19 @@ check (shared_ptr<PlayerVideo>, DCPTime time)
next += frame;
}
+
void
ffmpeg_decoder_sequential_test_one (boost::filesystem::path file, float fps, int video_length)
{
- boost::filesystem::path path = TestPaths::private_data() / file;
+ auto path = TestPaths::private_data() / file;
BOOST_REQUIRE (boost::filesystem::exists (path));
- shared_ptr<Film> film = new_test_film ("ffmpeg_decoder_sequential_test_" + file.string());
- shared_ptr<FFmpegContent> content (new FFmpegContent(path));
+ auto film = new_test_film ("ffmpeg_decoder_sequential_test_" + file.string());
+ auto content = make_shared<FFmpegContent>(path);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
film->write_metadata ();
- shared_ptr<Player> player (new Player(film));
+ auto player = make_shared<Player>(film);
BOOST_REQUIRE (content->video_frame_rate());
BOOST_CHECK_CLOSE (content->video_frame_rate().get(), fps, 0.01);
@@ -81,6 +88,7 @@ ffmpeg_decoder_sequential_test_one (boost::filesystem::path file, float fps, int
BOOST_REQUIRE (next == DCPTime::from_frames (video_length, film->video_frame_rate()));
}
+
BOOST_AUTO_TEST_CASE (ffmpeg_decoder_sequential_test)
{
ffmpeg_decoder_sequential_test_one ("boon_telly.mkv", 29.97, 6912);
diff --git a/test/ffmpeg_pts_offset_test.cc b/test/ffmpeg_pts_offset_test.cc
index 134881c0d..4aa4c1d9a 100644
--- a/test/ffmpeg_pts_offset_test.cc
+++ b/test/ffmpeg_pts_offset_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,11 +18,13 @@
*/
+
/** @file test/ffmpeg_pts_offset_test.cc
* @brief Check the computation of _pts_offset in FFmpegDecoder.
* @ingroup selfcontained
*/
+
#include <boost/test/unit_test.hpp>
#include "lib/film.h"
#include "lib/ffmpeg_decoder.h"
@@ -31,17 +33,20 @@
#include "lib/audio_content.h"
#include "test.h"
+
+using std::make_shared;
using std::shared_ptr;
using namespace dcpomatic;
+
BOOST_AUTO_TEST_CASE (ffmpeg_pts_offset_test)
{
- shared_ptr<Film> film = new_test_film ("ffmpeg_pts_offset_test");
- shared_ptr<FFmpegContent> content (new FFmpegContent ("test/data/test.mp4"));
+ auto film = new_test_film ("ffmpeg_pts_offset_test");
+ auto content = make_shared<FFmpegContent>("test/data/test.mp4");
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
- content->audio.reset (new AudioContent (content.get()));
+ content->audio = make_shared<AudioContent>(content.get());
content->audio->add_stream (shared_ptr<FFmpegAudioStream> (new FFmpegAudioStream));
content->_video_frame_rate = 24;
diff --git a/test/isdcf_name_test.cc b/test/isdcf_name_test.cc
index cf39c112e..a41bf84b3 100644
--- a/test/isdcf_name_test.cc
+++ b/test/isdcf_name_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2014-2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
diff --git a/test/job_test.cc b/test/job_test.cc
index c834ec12e..7fb240843 100644
--- a/test/job_test.cc
+++ b/test/job_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2012-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,18 +18,23 @@
*/
+
/** @file test/job_test.cc
* @brief Test Job and JobManager.
* @ingroup selfcontained
*/
-#include <boost/test/unit_test.hpp>
+
+#include "lib/cross.h"
#include "lib/job.h"
#include "lib/job_manager.h"
-#include "lib/cross.h"
+#include <boost/test/unit_test.hpp>
-using std::string;
+
+using std::make_shared;
using std::shared_ptr;
+using std::string;
+
class TestJob : public Job
{
@@ -71,12 +76,13 @@ public:
}
};
+
BOOST_AUTO_TEST_CASE (job_manager_test)
{
shared_ptr<Film> film;
/* Single job */
- shared_ptr<TestJob> a (new TestJob (film));
+ auto a = make_shared<TestJob>(film);
JobManager::instance()->add (a);
dcpomatic_sleep_seconds (1);
diff --git a/test/markers_test.cc b/test/markers_test.cc
index 70f4cad82..844f25660 100644
--- a/test/markers_test.cc
+++ b/test/markers_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
diff --git a/test/pixel_formats_test.cc b/test/pixel_formats_test.cc
index 952cc0af9..f59c594e9 100644
--- a/test/pixel_formats_test.cc
+++ b/test/pixel_formats_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,6 +18,7 @@
*/
+
/** @file src/pixel_formats_test.cc
* @brief Make sure that Image::sample_size() and Image::bytes_per_pixel() return the right
* things for various pixel formats.
@@ -25,6 +26,7 @@
* @see test/image_test.cc
*/
+
#include <boost/test/unit_test.hpp>
#include <list>
extern "C" {
@@ -34,9 +36,11 @@ extern "C" {
#include "lib/image.h"
#include <iostream>
+
using std::list;
using std::cout;
+
/** @struct Case
* @brief A test case for pixel_formats_test.
*/
@@ -63,33 +67,34 @@ struct Case
BOOST_AUTO_TEST_CASE (pixel_formats_test)
{
- list<Case> cases;
- cases.push_back(Case(AV_PIX_FMT_RGB24, 1, 480, 480, 480, 3, 0, 0 ));
- cases.push_back(Case(AV_PIX_FMT_RGBA, 1, 480, 480, 480, 4, 0, 0 ));
- cases.push_back(Case(AV_PIX_FMT_YUV420P, 3, 480, 240, 240, 1, 0.5, 0.5));
- cases.push_back(Case(AV_PIX_FMT_YUV422P, 3, 480, 480, 480, 1, 0.5, 0.5));
- cases.push_back(Case(AV_PIX_FMT_YUV422P10LE, 3, 480, 480, 480, 2, 1, 1 ));
- cases.push_back(Case(AV_PIX_FMT_YUV422P16LE, 3, 480, 480, 480, 2, 1, 1 ));
- cases.push_back(Case(AV_PIX_FMT_UYVY422, 1, 480, 480, 480, 2, 0, 0 ));
- cases.push_back(Case(AV_PIX_FMT_YUV444P, 3, 480, 480, 480, 1, 1, 1 ));
- cases.push_back(Case(AV_PIX_FMT_YUV444P9BE, 3, 480, 480, 480, 2, 2, 2 ));
- cases.push_back(Case(AV_PIX_FMT_YUV444P9LE, 3, 480, 480, 480, 2, 2, 2 ));
- cases.push_back(Case(AV_PIX_FMT_YUV444P10BE, 3, 480, 480, 480, 2, 2, 2 ));
- cases.push_back(Case(AV_PIX_FMT_YUV444P10LE, 3, 480, 480, 480, 2, 2, 2 ));
-
- for (list<Case>::iterator i = cases.begin(); i != cases.end(); ++i) {
- AVFrame* f = av_frame_alloc ();
+ list<Case> cases = {
+ { AV_PIX_FMT_RGB24, 1, 480, 480, 480, 3, 0, 0 },
+ { AV_PIX_FMT_RGBA, 1, 480, 480, 480, 4, 0, 0 },
+ { AV_PIX_FMT_YUV420P, 3, 480, 240, 240, 1, 0.5, 0.5},
+ { AV_PIX_FMT_YUV422P, 3, 480, 480, 480, 1, 0.5, 0.5},
+ { AV_PIX_FMT_YUV422P10LE, 3, 480, 480, 480, 2, 1, 1 },
+ { AV_PIX_FMT_YUV422P16LE, 3, 480, 480, 480, 2, 1, 1 },
+ { AV_PIX_FMT_UYVY422, 1, 480, 480, 480, 2, 0, 0 },
+ { AV_PIX_FMT_YUV444P, 3, 480, 480, 480, 1, 1, 1 },
+ { AV_PIX_FMT_YUV444P9BE, 3, 480, 480, 480, 2, 2, 2 },
+ { AV_PIX_FMT_YUV444P9LE, 3, 480, 480, 480, 2, 2, 2 },
+ { AV_PIX_FMT_YUV444P10BE, 3, 480, 480, 480, 2, 2, 2 },
+ { AV_PIX_FMT_YUV444P10LE, 3, 480, 480, 480, 2, 2, 2 }
+ };
+
+ for (auto const& i: cases) {
+ auto f = av_frame_alloc ();
f->width = 640;
f->height = 480;
- f->format = static_cast<int> (i->format);
+ f->format = static_cast<int> (i.format);
av_frame_get_buffer (f, true);
Image t (f);
- BOOST_CHECK_EQUAL(t.planes(), i->planes);
- BOOST_CHECK_EQUAL(t.sample_size(0).height, i->lines[0]);
- BOOST_CHECK_EQUAL(t.sample_size(1).height, i->lines[1]);
- BOOST_CHECK_EQUAL(t.sample_size(2).height, i->lines[2]);
- BOOST_CHECK_EQUAL(t.bytes_per_pixel(0), i->bpp[0]);
- BOOST_CHECK_EQUAL(t.bytes_per_pixel(1), i->bpp[1]);
- BOOST_CHECK_EQUAL(t.bytes_per_pixel(2), i->bpp[2]);
+ BOOST_CHECK_EQUAL(t.planes(), i.planes);
+ BOOST_CHECK_EQUAL(t.sample_size(0).height, i.lines[0]);
+ BOOST_CHECK_EQUAL(t.sample_size(1).height, i.lines[1]);
+ BOOST_CHECK_EQUAL(t.sample_size(2).height, i.lines[2]);
+ BOOST_CHECK_EQUAL(t.bytes_per_pixel(0), i.bpp[0]);
+ BOOST_CHECK_EQUAL(t.bytes_per_pixel(1), i.bpp[1]);
+ BOOST_CHECK_EQUAL(t.bytes_per_pixel(2), i.bpp[2]);
}
}
diff --git a/test/rect_test.cc b/test/rect_test.cc
index f603b1230..24df33316 100644
--- a/test/rect_test.cc
+++ b/test/rect_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2016-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,29 +18,34 @@
*/
+
/** @file test/rect_test.cc
* @brief Test dcpomatic::Rect class.
* @ingroup selfcontained
*/
+
#include "lib/rect.h"
#include <boost/test/unit_test.hpp>
#include <iostream>
+
using boost::optional;
+
BOOST_AUTO_TEST_CASE (rect_test1)
{
dcpomatic::Rect<int> a (0, 0, 100, 100);
dcpomatic::Rect<int> b (200, 200, 100, 100);
- optional<dcpomatic::Rect<int> > c = a.intersection (b);
+ auto c = a.intersection (b);
BOOST_CHECK (!c);
}
+
BOOST_AUTO_TEST_CASE (rect_test2)
{
dcpomatic::Rect<int> a (0, 330, 100, 85);
- a.extend (dcpomatic::Rect<int> (50, 235, 100, 85));
+ a.extend (dcpomatic::Rect<int>(50, 235, 100, 85));
BOOST_CHECK_EQUAL (a.x, 0);
BOOST_CHECK_EQUAL (a.y, 235);
BOOST_CHECK_EQUAL (a.width, 150);
diff --git a/test/silence_padding_test.cc b/test/silence_padding_test.cc
index 328f9bef7..e4c640792 100644
--- a/test/silence_padding_test.cc
+++ b/test/silence_padding_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,11 +18,13 @@
*/
+
/** @file test/silence_padding_test.cc
* @brief Test the padding (with silence) of a mono source to a 6-channel DCP.
* @ingroup feature
*/
+
#include "lib/ffmpeg_content.h"
#include "lib/film.h"
#include "lib/dcp_content_type.h"
@@ -37,11 +39,13 @@
#include <dcp/sound_asset_reader.h>
#include <boost/test/unit_test.hpp>
+
using std::make_shared;
using std::string;
using std::shared_ptr;
using boost::lexical_cast;
+
static void
test_silence_padding (int channels)
{
@@ -120,6 +124,7 @@ test_silence_padding (int channels)
}
+
BOOST_AUTO_TEST_CASE (silence_padding_test)
{
for (int i = 1; i < MAX_DCP_AUDIO_CHANNELS; ++i) {
@@ -127,6 +132,7 @@ BOOST_AUTO_TEST_CASE (silence_padding_test)
}
}
+
/** Test a situation that used to crash because of a sub-sample rounding confusion
* caused by a trim.
*/
diff --git a/test/threed_test.cc b/test/threed_test.cc
index a4889645f..f98464fb5 100644
--- a/test/threed_test.cc
+++ b/test/threed_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2013-2019 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,11 +18,13 @@
*/
+
/** @file test/threed_test.cc
* @brief Create some 3D DCPs (without comparing the results to anything).
* @ingroup completedcp
*/
+
#include "lib/config.h"
#include "lib/content_factory.h"
#include "lib/cross.h"
diff --git a/test/time_calculation_test.cc b/test/time_calculation_test.cc
index d0cf63bb2..ffe77c2b7 100644
--- a/test/time_calculation_test.cc
+++ b/test/time_calculation_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2015-2016 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2015-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,11 +18,13 @@
*/
+
/** @file test/time_calculation_test.cc
* @brief Test calculation of timings when frame rates change.
* @ingroup feature
*/
+
#include "lib/film.h"
#include "lib/ffmpeg_content.h"
#include "lib/video_content.h"
@@ -31,11 +33,14 @@
#include "test.h"
#include <boost/test/unit_test.hpp>
-using std::string;
+
using std::list;
+using std::make_shared;
using std::shared_ptr;
+using std::string;
using namespace dcpomatic;
+
static string const xml = "<Content>"
"<Type>FFmpeg</Type>"
"<BurnSubtitles>0</BurnSubtitles>"
@@ -125,15 +130,16 @@ static string const xml = "<Content>"
"<FirstVideo>0</FirstVideo>"
"</Content>";
+
BOOST_AUTO_TEST_CASE (ffmpeg_time_calculation_test)
{
- shared_ptr<Film> film = new_test_film ("ffmpeg_time_calculation_test");
+ auto film = new_test_film ("ffmpeg_time_calculation_test");
- shared_ptr<cxml::Document> doc (new cxml::Document);
+ auto doc = make_shared<cxml::Document>();
doc->read_string (xml);
list<string> notes;
- shared_ptr<FFmpegContent> content (new FFmpegContent(doc, film->state_version(), notes));
+ auto content = make_shared<FFmpegContent>(doc, film->state_version(), notes);
/* 25fps content, 25fps DCP */
film->set_video_frame_rate (25);
@@ -177,20 +183,21 @@ BOOST_AUTO_TEST_CASE (ffmpeg_time_calculation_test)
}
+
/** Test Player::dcp_to_content_video */
BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
{
- shared_ptr<Film> film = new_test_film ("player_time_calculation_test1");
+ auto film = new_test_film ("player_time_calculation_test1");
- shared_ptr<cxml::Document> doc (new cxml::Document);
+ auto doc = make_shared<cxml::Document>();
doc->read_string (xml);
list<string> notes;
- shared_ptr<FFmpegContent> content (new FFmpegContent(doc, film->state_version(), notes));
+ auto content = make_shared<FFmpegContent>(doc, film->state_version(), notes);
film->set_sequence (false);
film->add_content (content);
- shared_ptr<Player> player (new Player(film));
+ auto player = make_shared<Player>(film);
/* Position 0, no trim, content rate = DCP rate */
content->set_position (film, DCPTime());
@@ -386,17 +393,17 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test1)
/** Test Player::content_video_to_dcp */
BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
{
- shared_ptr<Film> film = new_test_film ("player_time_calculation_test2");
+ auto film = new_test_film ("player_time_calculation_test2");
- shared_ptr<cxml::Document> doc (new cxml::Document);
+ auto doc = make_shared<cxml::Document>();
doc->read_string (xml);
list<string> notes;
- shared_ptr<FFmpegContent> content (new FFmpegContent(doc, film->state_version(), notes));
+ auto content = make_shared<FFmpegContent>(doc, film->state_version(), notes);
film->set_sequence (false);
film->add_content (content);
- shared_ptr<Player> player (new Player(film));
+ auto player = make_shared<Player>(film);
/* Position 0, no trim, content rate = DCP rate */
content->set_position (film, DCPTime());
@@ -562,18 +569,18 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test2)
/** Test Player::dcp_to_content_audio */
BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
{
- shared_ptr<Film> film = new_test_film ("player_time_calculation_test3");
+ auto film = new_test_film ("player_time_calculation_test3");
- shared_ptr<cxml::Document> doc (new cxml::Document);
+ auto doc = make_shared<cxml::Document>();
doc->read_string (xml);
list<string> notes;
- shared_ptr<FFmpegContent> content (new FFmpegContent(doc, film->state_version(), notes));
- AudioStreamPtr stream = content->audio->streams().front();
+ auto content = make_shared<FFmpegContent>(doc, film->state_version(), notes);
+ auto stream = content->audio->streams().front();
film->set_sequence (false);
film->add_content (content);
- shared_ptr<Player> player (new Player(film));
+ auto player = make_shared<Player>(film);
/* Position 0, no trim, video/audio content rate = video/audio DCP rate */
content->set_position (film, DCPTime());
@@ -583,7 +590,7 @@ BOOST_AUTO_TEST_CASE (player_time_calculation_test3)
stream->_frame_rate = 48000;
player->setup_pieces ();
BOOST_REQUIRE_EQUAL (player->_pieces.size(), 1U);
- shared_ptr<Piece> piece = player->_pieces.front ();
+ auto piece = player->_pieces.front ();
BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime ()), 0);
BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (0.5)), 24000);
BOOST_CHECK_EQUAL (player->dcp_to_resampled_audio (piece, DCPTime::from_seconds (3.0)), 144000);
diff --git a/test/torture_test.cc b/test/torture_test.cc
index 6b8cbffbf..c9bffaac7 100644
--- a/test/torture_test.cc
+++ b/test/torture_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2017 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2017-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,11 +18,13 @@
*/
+
/** @file test/torture_test.cc
* @brief Tricky arrangements of content whose resulting DCPs are checked programmatically.
* @ingroup completedcp
*/
+
#include "lib/audio_content.h"
#include "lib/film.h"
#include "lib/dcp_content_type.h"
@@ -41,12 +43,14 @@
#include <boost/test/unit_test.hpp>
#include <iostream>
+
using std::list;
using std::cout;
using std::shared_ptr;
using std::dynamic_pointer_cast;
using namespace dcpomatic;
+
/** Test start/end trim and positioning of some audio content */
BOOST_AUTO_TEST_CASE (torture_test1)
{
@@ -63,7 +67,7 @@ BOOST_AUTO_TEST_CASE (torture_test1)
staircase->audio->set_gain (20 * log10(2));
/* And again at an offset of 50000 samples, trimmed both start and end, with a gain of exactly 2 (linear) */
- staircase = content_factory("test/data/staircase.wav").front ();
+ staircase = content_factory("test/data/staircase.wav").front();
film->examine_and_add_content (staircase);
BOOST_REQUIRE (!wait_for_jobs());
staircase->set_position (film, DCPTime::from_frames(50000, film->audio_frame_rate()));
diff --git a/test/video_level_test.cc b/test/video_level_test.cc
index 22bec742a..acf7fb4e2 100644
--- a/test/video_level_test.cc
+++ b/test/video_level_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -199,7 +199,7 @@ static
pair<int, int>
pixel_range (shared_ptr<Film> film, shared_ptr<const FFmpegContent> content)
{
- shared_ptr<FFmpegDecoder> decoder(new FFmpegDecoder(film, content, false));
+ auto decoder = make_shared<FFmpegDecoder>(film, content, false);
decoder->video->Data.connect (bind(&video_handler, _1));
content_video = boost::none;
while (!content_video) {
@@ -214,7 +214,7 @@ static
pair<int, int>
pixel_range (shared_ptr<Film> film, shared_ptr<const ImageContent> content)
{
- shared_ptr<ImageDecoder> decoder(new ImageDecoder(film, content));
+ auto decoder = make_shared<ImageDecoder>(film, content);
decoder->video->Data.connect (bind(&video_handler, _1));
content_video = boost::none;
while (!content_video) {
@@ -232,9 +232,9 @@ pixel_range (boost::filesystem::path dcp_path)
dcp::DCP dcp (dcp_path);
dcp.read ();
- shared_ptr<dcp::MonoPictureAsset> picture = dynamic_pointer_cast<dcp::MonoPictureAsset>(dcp.cpls().front()->reels().front()->main_picture()->asset());
+ auto picture = dynamic_pointer_cast<dcp::MonoPictureAsset>(dcp.cpls().front()->reels().front()->main_picture()->asset());
BOOST_REQUIRE (picture);
- shared_ptr<dcp::OpenJPEGImage> frame = picture->start_read()->get_frame(0)->xyz_image();
+ auto frame = picture->start_read()->get_frame(0)->xyz_image();
int const width = frame->size().width;
int const height = frame->size().height;
@@ -267,8 +267,8 @@ static
shared_ptr<Film>
movie_V (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<FFmpegContent> content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mp4").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mp4").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
@@ -285,8 +285,8 @@ static
shared_ptr<Film>
movie_VoF (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<FFmpegContent> content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mp4").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mp4").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
@@ -304,8 +304,8 @@ static
shared_ptr<Film>
movie_F (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<FFmpegContent> content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mov").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mov").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
@@ -322,8 +322,8 @@ static
shared_ptr<Film>
movie_FoV (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<FFmpegContent> content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mov").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<FFmpegContent>(content_factory("test/data/rgb_grey_testcard.mov").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
@@ -341,8 +341,8 @@ static
shared_ptr<Film>
image_F (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<ImageContent> content = dynamic_pointer_cast<ImageContent>(content_factory("test/data/rgb_grey_testcard.png").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<ImageContent>(content_factory("test/data/rgb_grey_testcard.png").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
@@ -359,8 +359,8 @@ static
shared_ptr<Film>
image_FoV (string name)
{
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<ImageContent> content = dynamic_pointer_cast<ImageContent>(content_factory("test/data/rgb_grey_testcard.png").front());
+ auto film = new_test_film2 (name);
+ auto content = dynamic_pointer_cast<ImageContent>(content_factory("test/data/rgb_grey_testcard.png").front());
BOOST_REQUIRE (content);
film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
@@ -379,9 +379,9 @@ shared_ptr<Film>
dcp_F (string name)
{
boost::filesystem::path const dcp = "test/data/RgbGreyTestcar_TST-1_F_MOS_2K_20201115_SMPTE_OV";
- shared_ptr<Film> film = new_test_film2 (name);
- shared_ptr<DCPContent> content(new DCPContent(dcp));
- film->examine_and_add_content (shared_ptr<DCPContent>(new DCPContent(dcp)));
+ auto film = new_test_film2 (name);
+ auto content = make_shared<DCPContent>(dcp);
+ film->examine_and_add_content (content);
BOOST_REQUIRE (!wait_for_jobs());
auto range = pixel_range (dcp);
@@ -411,11 +411,9 @@ static
pair<int, int>
V_movie_range (shared_ptr<Film> film)
{
- shared_ptr<TranscodeJob> job (new TranscodeJob(film));
+ auto job = make_shared<TranscodeJob>(film);
job->set_encoder (
- shared_ptr<FFmpegEncoder>(
- new FFmpegEncoder (film, job, film->file("export.mov"), ExportFormat::PRORES, true, false, false, 23)
- )
+ make_shared<FFmpegEncoder>(film, job, film->file("export.mov"), ExportFormat::PRORES, true, false, false, 23)
);
JobManager::instance()->add (job);
BOOST_REQUIRE (!wait_for_jobs());
diff --git a/test/zipper_test.cc b/test/zipper_test.cc
index c3f6ef728..1b8c386f4 100644
--- a/test/zipper_test.cc
+++ b/test/zipper_test.cc
@@ -1,5 +1,5 @@
/*
- Copyright (C) 2020 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2020-2021 Carl Hetherington <cth@carlh.net>
This file is part of DCP-o-matic.
@@ -18,18 +18,21 @@
*/
+
/** @file test/zipper_test.cc
* @brief Test Zipper class.
* @ingroup selfcontained
*/
-#include "lib/zipper.h"
+
#include "lib/exceptions.h"
+#include "lib/zipper.h"
#include "test.h"
#include <dcp/util.h>
#include <boost/test/unit_test.hpp>
#include <boost/filesystem.hpp>
+
/** Basic test of Zipper working normally */
BOOST_AUTO_TEST_CASE (zipper_test1)
{