Allow specification of the CPL ID to use in a DCP with _create (#2302).
[dcpomatic.git] / test / create_cli_test.cc
index dff10a11c2fed9203329a8360b3c770d190d9bdc..71281a63e34630cc40d7684ee45ab4a17f6044b5 100644 (file)
@@ -37,21 +37,19 @@ run (string cmd)
        boost::escaped_list_separator<char> els ("", " ", "\"\'");
        boost::tokenizer<boost::escaped_list_separator<char> > tok (cmd, els);
 
-       char** argv = new char*[256];
+       std::vector<char*> argv(256);
        int argc = 0;
 
        for (boost::tokenizer<boost::escaped_list_separator<char> >::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;
 }
 
@@ -144,6 +142,12 @@ BOOST_AUTO_TEST_CASE (create_cli_test)
        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");
@@ -171,4 +175,19 @@ BOOST_AUTO_TEST_CASE (create_cli_test)
        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);
+
+       cc = run("dcpomatic2_create --cpl 123456-789-0 dcp");
+       BOOST_REQUIRE_EQUAL(cc.content.size(), 1U);
+       BOOST_CHECK_EQUAL(cc.content[0].path, "dcp");
+       BOOST_REQUIRE(static_cast<bool>(cc.content[0].cpl));
+       BOOST_CHECK_EQUAL(*cc.content[0].cpl, "123456-789-0");
 }