Add --gain option to dcpomatic_create.
[dcpomatic.git] / test / create_cli_test.cc
index ad794226f8adc47640b9eb5ebadf7cc0f47e5377..aae243d997ea040899057c86d1ae8c794e5603b9 100644 (file)
@@ -35,13 +35,13 @@ run (string cmd)
        /* This approximates the logic which splits command lines up into argc/argv */
 
        boost::escaped_list_separator<char> els ("", " ", "\"\'");
-       boost::tokenizer<boost::escaped_list_separator<char> > tok (cmd, els);
+       boost::tokenizer<boost::escaped_list_separator<char>> tok (cmd, els);
 
        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());
+       for (auto i: tok) {
+               argv[argc++] = strdup (i.c_str());
        }
 
        CreateCLI cc (argc, argv.data());
@@ -154,4 +154,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);
 }