A few test fixups.
[dcpomatic.git] / test / film_metadata_test.cc
1 /*
2     Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 BOOST_AUTO_TEST_CASE (film_metadata_test)
21 {
22         string const test_film = "build/test/film_metadata_test";
23         
24         if (boost::filesystem::exists (test_film)) {
25                 boost::filesystem::remove_all (test_film);
26         }
27
28         shared_ptr<Film> f (new Film (test_film));
29         f->_dci_date = boost::gregorian::from_undelimited_string ("20130211");
30         BOOST_CHECK (f->container() == 0);
31         BOOST_CHECK (f->dcp_content_type() == 0);
32
33         f->set_name ("fred");
34         f->set_dcp_content_type (DCPContentType::from_pretty_name ("Short"));
35         f->set_container (Ratio::from_id ("185"));
36         f->set_ab (true);
37         f->write_metadata ();
38
39         stringstream s;
40         s << "diff -u test/data/metadata.xml.ref " << test_film << "/metadata.xml";
41         BOOST_CHECK_EQUAL (::system (s.str().c_str ()), 0);
42
43         shared_ptr<Film> g (new Film (test_film));
44         g->read_metadata ();
45
46         BOOST_CHECK_EQUAL (g->name(), "fred");
47         BOOST_CHECK_EQUAL (g->dcp_content_type(), DCPContentType::from_pretty_name ("Short"));
48         BOOST_CHECK_EQUAL (g->container(), Ratio::from_id ("185"));
49         BOOST_CHECK_EQUAL (g->ab(), true);
50         
51         g->write_metadata ();
52         BOOST_CHECK_EQUAL (::system (s.str().c_str ()), 0);
53 }