diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-06-08 10:17:35 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-06-08 10:17:35 +0100 |
| commit | 43515be4f21d92d66f28588bcd0dc93ee517d301 (patch) | |
| tree | 165e1f458d331730e1b5e0de6bbdf772bf5ff9cb | |
| parent | f5f45d829527a439bca012c2cfa2104a735a58f1 (diff) | |
Expand read_smpte_subtitle_test somewhat.
| -rw-r--r-- | src/local_time.cc | 22 | ||||
| -rw-r--r-- | src/local_time.h | 6 | ||||
| -rw-r--r-- | src/smpte_subtitle_asset.h | 4 | ||||
| -rw-r--r-- | src/types.cc | 7 | ||||
| -rw-r--r-- | src/types.h | 1 | ||||
| -rw-r--r-- | test/read_smpte_subtitle_test.cc | 33 |
6 files changed, 70 insertions, 3 deletions
diff --git a/src/local_time.cc b/src/local_time.cc index 32e8e093..09729543 100644 --- a/src/local_time.cc +++ b/src/local_time.cc @@ -29,6 +29,7 @@ #include <cstdio> using std::string; +using std::ostream; using boost::lexical_cast; using namespace dcp; @@ -156,3 +157,24 @@ LocalTime::time_of_day (bool with_millisecond) const } return buffer; } + +bool +LocalTime::operator== (LocalTime const & other) const +{ + return _year == other._year && _month == other._month && _day == other._day && + _hour == other._hour && _second == other._second && _millisecond == other._millisecond && + _tz_hour == other._tz_hour && _tz_minute == other._tz_minute; +} + +bool +LocalTime::operator!= (LocalTime const & other) const +{ + return !(*this == other); +} + +ostream& +dcp::operator<< (ostream& s, LocalTime const & t) +{ + s << t.as_string (); + return s; +} diff --git a/src/local_time.h b/src/local_time.h index b1751f8b..5112307c 100644 --- a/src/local_time.h +++ b/src/local_time.h @@ -51,6 +51,9 @@ public: std::string date () const; std::string time_of_day (bool with_millisecond = false) const; + bool operator== (LocalTime const & other) const; + bool operator!= (LocalTime const & other) const; + private: friend class ::local_time_test; @@ -69,6 +72,9 @@ private: int _tz_minute; ///< minutes by which this time is offset from UTC }; +std::ostream& +operator<< (std::ostream& s, LocalTime const & t); + } #endif diff --git a/src/smpte_subtitle_asset.h b/src/smpte_subtitle_asset.h index c796e1d4..6df924aa 100644 --- a/src/smpte_subtitle_asset.h +++ b/src/smpte_subtitle_asset.h @@ -74,6 +74,10 @@ public: return _issue_date; } + boost::optional<int> reel_number () const { + return _reel_number; + } + Fraction edit_rate () const { return _edit_rate; } diff --git a/src/types.cc b/src/types.cc index 37666701..f32d90bd 100644 --- a/src/types.cc +++ b/src/types.cc @@ -62,6 +62,13 @@ dcp::operator!= (Fraction const & a, Fraction const & b) return (a.numerator != b.numerator || a.denominator != b.denominator); } +ostream& +dcp::operator<< (ostream& s, Fraction const & f) +{ + s << f.numerator << "/" << f.denominator; + return s; +} + /** Construct a Colour, initialising it to black. */ Colour::Colour () : r (0) diff --git a/src/types.h b/src/types.h index ca7603ab..46881a60 100644 --- a/src/types.h +++ b/src/types.h @@ -147,6 +147,7 @@ public: extern bool operator== (Fraction const & a, Fraction const & b); extern bool operator!= (Fraction const & a, Fraction const & b); +extern std::ostream& operator<< (std::ostream& s, Fraction const & f); /** @struct EqualityOptions * @brief A class to describe what "equality" means for a particular test. diff --git a/test/read_smpte_subtitle_test.cc b/test/read_smpte_subtitle_test.cc index 04169d65..81749a15 100644 --- a/test/read_smpte_subtitle_test.cc +++ b/test/read_smpte_subtitle_test.cc @@ -19,15 +19,42 @@ #include "smpte_subtitle_asset.h" #include "test.h" +#include "local_time.h" +#include "smpte_load_font_node.h" #include <boost/test/unit_test.hpp> +using std::list; +using boost::shared_ptr; +using boost::dynamic_pointer_cast; + /** Check reading of a SMPTE subtitle file */ BOOST_AUTO_TEST_CASE (read_smpte_subtitle_test) { dcp::SMPTESubtitleAsset sc (private_test / "8dfafe11-2bd1-4206-818b-afc109cfe7f6_reel1.xml", false); - BOOST_REQUIRE_EQUAL (sc.id(), "8dfafe11-2bd1-4206-818b-afc109cfe7f6"); + BOOST_CHECK_EQUAL (sc.id(), "8dfafe11-2bd1-4206-818b-afc109cfe7f6"); + BOOST_CHECK_EQUAL (sc.content_title_text(), "Violet"); + BOOST_REQUIRE (sc.annotation_text()); + BOOST_CHECK_EQUAL (sc.annotation_text().get(), "Violet"); + BOOST_CHECK_EQUAL (sc.issue_date(), dcp::LocalTime ("2014-12-23T22:30:07.000-00:00")); + BOOST_REQUIRE (sc.reel_number()); + BOOST_CHECK_EQUAL (sc.reel_number().get(), 1); + BOOST_REQUIRE (sc.language ()); + BOOST_CHECK_EQUAL (sc.language().get (), "Dutch"); + BOOST_CHECK_EQUAL (sc.edit_rate(), dcp::Fraction (24, 1)); + BOOST_CHECK_EQUAL (sc.time_code_rate(), 24); + BOOST_CHECK_EQUAL (sc.start_time(), dcp::Time (0, 0, 0, 23, 24)); + list<shared_ptr<dcp::LoadFontNode> > lfn = sc.load_font_nodes (); + BOOST_REQUIRE_EQUAL (lfn.size(), 1); + shared_ptr<dcp::SMPTELoadFontNode> smpte_lfn = dynamic_pointer_cast<dcp::SMPTELoadFontNode> (lfn.front ()); + BOOST_REQUIRE (smpte_lfn); + BOOST_CHECK_EQUAL (smpte_lfn->id, "theFontId"); + BOOST_CHECK_EQUAL (smpte_lfn->urn, "3dec6dc0-39d0-498d-97d0-928d2eb78391"); BOOST_REQUIRE_EQUAL (sc.subtitles().size(), 159); - BOOST_REQUIRE_EQUAL (sc.subtitles().front().text(), "Jonas ?"); - BOOST_REQUIRE_EQUAL (sc.subtitles().back().text(), "Come on."); + BOOST_CHECK_EQUAL (sc.subtitles().front().text(), "Jonas ?"); + BOOST_CHECK_EQUAL (sc.subtitles().front().in(), dcp::Time (0, 7, 6, 20, 24)); + BOOST_CHECK_EQUAL (sc.subtitles().front().out(), dcp::Time (0, 7, 7, 20, 24)); + BOOST_CHECK_EQUAL (sc.subtitles().back().text(), "Come on."); + BOOST_CHECK_EQUAL (sc.subtitles().back().in(), dcp::Time (1, 13, 37, 11, 24)); + BOOST_CHECK_EQUAL (sc.subtitles().back().out(), dcp::Time (1, 13, 38, 11, 24)); } |
