diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-12-28 02:41:13 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-12-28 02:41:13 +0000 |
| commit | 795b049f4a167677a8a2d39a4a09e8f5c2bb8dca (patch) | |
| tree | 09ed1934110e30e3f5eaa3a1d15cca3e05573572 | |
| parent | 1e0e3f4c2f3c956a4c011aaa1f9fb42a7339b129 (diff) | |
More tests.
| -rw-r--r-- | src/interop_load_font.cc | 2 | ||||
| -rw-r--r-- | src/interop_load_font.h | 7 | ||||
| -rw-r--r-- | test/interop_load_font_test.cc | 66 | ||||
| -rw-r--r-- | test/wscript | 1 |
4 files changed, 70 insertions, 6 deletions
diff --git a/src/interop_load_font.cc b/src/interop_load_font.cc index c40d64c4..dede5696 100644 --- a/src/interop_load_font.cc +++ b/src/interop_load_font.cc @@ -32,7 +32,7 @@ InteropLoadFont::InteropLoadFont (string id_, string uri_) } -InteropLoadFont::InteropLoadFont (shared_ptr<const cxml::Node> node) +InteropLoadFont::InteropLoadFont (cxml::ConstNodePtr node) { optional<string> x = node->optional_string_attribute ("Id"); if (!x) { diff --git a/src/interop_load_font.h b/src/interop_load_font.h index 61f63ffb..c553b557 100644 --- a/src/interop_load_font.h +++ b/src/interop_load_font.h @@ -17,13 +17,10 @@ */ +#include <libcxml/cxml.h> #include <boost/shared_ptr.hpp> #include <boost/optional.hpp> -namespace cxml { - class Node; -} - namespace dcp { class InteropLoadFont @@ -31,7 +28,7 @@ class InteropLoadFont public: InteropLoadFont () {} InteropLoadFont (std::string id, std::string uri); - InteropLoadFont (boost::shared_ptr<const cxml::Node> node); + InteropLoadFont (cxml::ConstNodePtr node); std::string id; std::string uri; diff --git a/test/interop_load_font_test.cc b/test/interop_load_font_test.cc new file mode 100644 index 00000000..b5972762 --- /dev/null +++ b/test/interop_load_font_test.cc @@ -0,0 +1,66 @@ +/* + Copyright (C) 2014 Carl Hetherington <cth@carlh.net> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "interop_load_font.h" +#include <libcxml/cxml.h> +#include <libxml++/libxml++.h> +#include <boost/test/unit_test.hpp> + +BOOST_AUTO_TEST_CASE (interop_load_font_test1) +{ + dcp::InteropLoadFont lf ("my-great-id", "my-great-uri"); + BOOST_CHECK_EQUAL (lf.id, "my-great-id"); + BOOST_CHECK_EQUAL (lf.uri, "my-great-uri"); +} + +BOOST_AUTO_TEST_CASE (interop_load_font_test2) +{ + xmlpp::Document doc; + xmlpp::Element* text = doc.create_root_node("Font"); + + text->set_attribute("Id", "my-great-id"); + text->set_attribute("URI", "my-great-uri"); + dcp::InteropLoadFont lf (cxml::ConstNodePtr (new cxml::Node (text))); + + BOOST_CHECK_EQUAL (lf.id, "my-great-id"); +} + +/** As per _test2 but with another capitalisation of ID */ +BOOST_AUTO_TEST_CASE (interop_load_font_test3) +{ + xmlpp::Document doc; + xmlpp::Element* text = doc.create_root_node("Font"); + + text->set_attribute("ID", "my-great-id"); + text->set_attribute("URI", "my-great-uri"); + dcp::InteropLoadFont lf (cxml::ConstNodePtr (new cxml::Node (text))); + + BOOST_CHECK_EQUAL (lf.id, "my-great-id"); +} + +/** Test operator== and operator!= */ +BOOST_AUTO_TEST_CASE (interop_load_font_test4) +{ + dcp::InteropLoadFont A ("my-create-id", "my-great-uri"); + dcp::InteropLoadFont B ("my-create-id", "my-great-uri"); + dcp::InteropLoadFont C ("my-create-id", "another-great-uri"); + + BOOST_CHECK (A == B); + BOOST_CHECK (B != C); +} diff --git a/test/wscript b/test/wscript index 28248eb4..ad1f0c02 100644 --- a/test/wscript +++ b/test/wscript @@ -37,6 +37,7 @@ def build(bld): encryption_test.cc fraction_test.cc frame_info_test.cc + interop_load_font_test.cc local_time_test.cc kdm_test.cc read_dcp_test.cc |
