2 Copyright (C) 2014 Carl Hetherington <cth@carlh.net>
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.
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.
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.
20 #include "text_node.h"
21 #include <libcxml/cxml.h>
22 #include <libxml++/libxml++.h>
23 #include <boost/test/unit_test.hpp>
25 /** Simple test of Text class parsing some XML */
26 BOOST_AUTO_TEST_CASE (text_test1)
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");
34 dcp::TextNode t (cxml::NodePtr (new cxml::Node (text)), 250);
35 BOOST_CHECK_CLOSE (t.v_position, 0.042, 0.001);
36 BOOST_CHECK_EQUAL (t.v_align, dcp::TOP);
37 BOOST_CHECK_EQUAL (t.text, "Hello world");
40 /** Similar to text_test1 but with different capitalisation of attribute names */
41 BOOST_AUTO_TEST_CASE (text_test2)
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");
49 dcp::TextNode t (cxml::NodePtr (new cxml::Node (text)), 250);
50 BOOST_CHECK_CLOSE (t.v_position, 0.042, 0.001);
51 BOOST_CHECK_EQUAL (t.v_align, dcp::TOP);
52 BOOST_CHECK_EQUAL (t.text, "Hello world");