Expand read_smpte_subtitle_test somewhat.
authorCarl Hetherington <cth@carlh.net>
Mon, 8 Jun 2015 09:17:35 +0000 (10:17 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 8 Jun 2015 09:17:35 +0000 (10:17 +0100)
src/local_time.cc
src/local_time.h
src/smpte_subtitle_asset.h
src/types.cc
src/types.h
test/read_smpte_subtitle_test.cc

index 32e8e093bd2702b64fb828ccddc5320ccc8d6364..09729543c160c3b9fbb352b63cd2e1e857a7064a 100644 (file)
@@ -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;
+}
index b1751f8b0e884b8a620ad21ab24f196868fa7895..5112307c76a26cca369b28cc923641170e7ee424 100644 (file)
@@ -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
index c796e1d45c5640bfcd9c98c15959de47015502b2..6df924aa1c9c07b739cfccfdc60af940e9c39146 100644 (file)
@@ -74,6 +74,10 @@ public:
                return _issue_date;
        }
 
+       boost::optional<int> reel_number () const {
+               return _reel_number;
+       }
+
        Fraction edit_rate () const {
                return _edit_rate;
        }
index 376667019ab150f0d821bf202e37d5ef6dd06adc..f32d90bdd73b9cae51550797b2b645cdf7ac801d 100644 (file)
@@ -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)
index ca7603abdbad9d5df1480d49edcf7dd9bd9b421e..46881a608231c5a5b12d1e8ed8f92e54a8fee70d 100644 (file)
@@ -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.
index 04169d658f22d10391298822400c803f8694cafe..81749a15d13a7f541fe302ccc86ae02643e59572 100644 (file)
 
 #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));
 }