X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=test%2Fcreate_cli_test.cc;h=97ac25374da8a135e3e6c7f38e46c099f93749f3;hb=fcba100f0dfd1d4214291abb76f22ebd696c24d4;hp=31c8ae877e8a8841ecbed7ac0f93c1a90b8cb21a;hpb=28111007e2e6fd62f5810be780706ae1618bd33f;p=dcpomatic.git diff --git a/test/create_cli_test.cc b/test/create_cli_test.cc index 31c8ae877..97ac25374 100644 --- a/test/create_cli_test.cc +++ b/test/create_cli_test.cc @@ -37,21 +37,19 @@ run (string cmd) boost::escaped_list_separator els ("", " ", "\"\'"); boost::tokenizer > tok (cmd, els); - char** argv = new char*[256]; + std::vector argv(256); int argc = 0; for (boost::tokenizer >::iterator i = tok.begin(); i != tok.end(); ++i) { argv[argc++] = strdup (i->c_str()); } - CreateCLI cc (argc, argv); + CreateCLI cc (argc, argv.data()); for (int i = 0; i < argc; ++i) { free (argv[i]); } - delete[] argv; - return cc; } @@ -130,20 +128,26 @@ BOOST_AUTO_TEST_CASE (create_cli_test) BOOST_CHECK_EQUAL (*cc.output_dir, "flaps"); BOOST_REQUIRE_EQUAL (cc.content.size(), 3U); BOOST_CHECK_EQUAL (cc.content[0].path, "fred"); - BOOST_CHECK_EQUAL (cc.content[0].frame_type, VIDEO_FRAME_TYPE_2D); + BOOST_CHECK_EQUAL (cc.content[0].frame_type, VideoFrameType::TWO_D); BOOST_CHECK_EQUAL (cc.content[1].path, "jim"); - BOOST_CHECK_EQUAL (cc.content[1].frame_type, VIDEO_FRAME_TYPE_2D); + BOOST_CHECK_EQUAL (cc.content[1].frame_type, VideoFrameType::TWO_D); BOOST_CHECK_EQUAL (cc.content[2].path, "sheila"); - BOOST_CHECK_EQUAL (cc.content[2].frame_type, VIDEO_FRAME_TYPE_2D); + BOOST_CHECK_EQUAL (cc.content[2].frame_type, VideoFrameType::TWO_D); cc = run ("dcpomatic2_create --left-eye left.mp4 --right-eye right.mp4"); BOOST_REQUIRE_EQUAL (cc.content.size(), 2U); BOOST_CHECK_EQUAL (cc.content[0].path, "left.mp4"); - BOOST_CHECK_EQUAL (cc.content[0].frame_type, VIDEO_FRAME_TYPE_3D_LEFT); + BOOST_CHECK_EQUAL (cc.content[0].frame_type, VideoFrameType::THREE_D_LEFT); BOOST_CHECK_EQUAL (cc.content[1].path, "right.mp4"); - BOOST_CHECK_EQUAL (cc.content[1].frame_type, VIDEO_FRAME_TYPE_3D_RIGHT); + BOOST_CHECK_EQUAL (cc.content[1].frame_type, VideoFrameType::THREE_D_RIGHT); BOOST_CHECK_EQUAL (cc.fourk, false); + cc = run ("dcpomatic2_create --twok foo.mp4"); + BOOST_REQUIRE_EQUAL (cc.content.size(), 1U); + BOOST_CHECK_EQUAL (cc.content[0].path, "foo.mp4"); + BOOST_CHECK_EQUAL (cc.twok, true); + BOOST_CHECK (!cc.error); + cc = run ("dcpomatic2_create --fourk foo.mp4"); BOOST_REQUIRE_EQUAL (cc.content.size(), 1U); BOOST_CHECK_EQUAL (cc.content[0].path, "foo.mp4"); @@ -156,4 +160,28 @@ BOOST_AUTO_TEST_CASE (create_cli_test) BOOST_REQUIRE (cc.j2k_bandwidth); BOOST_CHECK_EQUAL (*cc.j2k_bandwidth, 120000000); BOOST_CHECK (!cc.error); + + cc = run ("dcpomatic2_create --channel L fred.wav --channel R jim.wav sheila.wav"); + BOOST_REQUIRE_EQUAL (cc.content.size(), 3U); + BOOST_CHECK_EQUAL (cc.content[0].path, "fred.wav"); + BOOST_CHECK (cc.content[0].channel); + BOOST_CHECK (*cc.content[0].channel == dcp::Channel::LEFT); + BOOST_CHECK_EQUAL (cc.content[1].path, "jim.wav"); + BOOST_CHECK (cc.content[1].channel); + BOOST_CHECK (*cc.content[1].channel == dcp::Channel::RIGHT); + BOOST_CHECK_EQUAL (cc.content[2].path, "sheila.wav"); + BOOST_CHECK (!cc.content[2].channel); + + cc = run ("dcpomatic2_create --channel foo fred.wav"); + BOOST_REQUIRE (cc.error); + BOOST_CHECK (boost::algorithm::starts_with(*cc.error, "dcpomatic2_create: foo is not valid for --channel")); + + cc = run ("dcpomatic2_create fred.wav --gain -6 jim.wav --gain 2 sheila.wav"); + BOOST_REQUIRE_EQUAL (cc.content.size(), 3U); + BOOST_CHECK_EQUAL (cc.content[0].path, "fred.wav"); + BOOST_CHECK (!cc.content[0].gain); + BOOST_CHECK_EQUAL (cc.content[1].path, "jim.wav"); + BOOST_CHECK_CLOSE (*cc.content[1].gain, -6, 0.001); + BOOST_CHECK_EQUAL (cc.content[2].path, "sheila.wav"); + BOOST_CHECK_CLOSE (*cc.content[2].gain, 2, 0.001); }