Add content name to FilenameFormat.
[libdcp.git] / test / text_test.cc
1 /*
2     Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
3
4     This file is part of libdcp.
5
6     libdcp is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     libdcp is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with libdcp.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "text_node.h"
21 #include <libcxml/cxml.h>
22 #include <libxml++/libxml++.h>
23 #include <boost/test/unit_test.hpp>
24
25 /** Simple test of Text class parsing some XML */
26 BOOST_AUTO_TEST_CASE (text_test1)
27 {
28         xmlpp::Document doc;
29         xmlpp::Element* text = doc.create_root_node("Text");
30         text->set_attribute("VPosition", "4.2");
31         text->set_attribute("VAlign", "top");
32         text->add_child_text("Hello world");
33
34         dcp::TextNode t (cxml::NodePtr (new cxml::Node (text)), 250, dcp::INTEROP);
35         BOOST_CHECK_CLOSE (t.v_position, 0.042, 0.001);
36         BOOST_CHECK_EQUAL (t.v_align, dcp::VALIGN_TOP);
37         BOOST_CHECK_EQUAL (t.text, "Hello world");
38 }
39
40 /** Similar to text_test1 but with different capitalisation of attribute names */
41 BOOST_AUTO_TEST_CASE (text_test2)
42 {
43         xmlpp::Document doc;
44         xmlpp::Element* text = doc.create_root_node("Text");
45         text->set_attribute("Vposition", "4.2");
46         text->set_attribute("Valign", "top");
47         text->add_child_text("Hello world");
48
49         dcp::TextNode t (cxml::NodePtr (new cxml::Node (text)), 250, dcp::INTEROP);
50         BOOST_CHECK_CLOSE (t.v_position, 0.042, 0.001);
51         BOOST_CHECK_EQUAL (t.v_align, dcp::VALIGN_TOP);
52         BOOST_CHECK_EQUAL (t.text, "Hello world");
53 }