Accept any old case for DCP content kinds.
authorCarl Hetherington <cth@carlh.net>
Thu, 5 Dec 2013 22:39:50 +0000 (22:39 +0000)
committerCarl Hetherington <cth@carlh.net>
Thu, 5 Dec 2013 22:39:50 +0000 (22:39 +0000)
src/util.cc
test/util_test.cc

index 3508e64fe16812781e0d102880a9033f7a0f3150..cb58694ad28875c88e0bfa0ea11fabbbb9d33d87 100644 (file)
@@ -161,13 +161,13 @@ libdcp::content_kind_to_string (ContentKind kind)
 libdcp::ContentKind
 libdcp::content_kind_from_string (string type)
 {
-       /* XXX: should probably just convert type to lower-case and have done with it */
+       transform (type.begin(), type.end(), type.begin(), ::tolower);
        
        if (type == "feature") {
                return FEATURE;
        } else if (type == "short") {
                return SHORT;
-       } else if (type == "trailer" || type == "Trailer") {
+       } else if (type == "trailer") {
                return TRAILER;
        } else if (type == "test") {
                return TEST;
@@ -175,7 +175,7 @@ libdcp::content_kind_from_string (string type)
                return TRANSITIONAL;
        } else if (type == "rating") {
                return RATING;
-       } else if (type == "teaser" || type == "Teaser") {
+       } else if (type == "teaser") {
                return TEASER;
        } else if (type == "policy") {
                return POLICY;
index 2ed5e46a4187e3b89155ffb09b19f7e0029ff195..f7114e90752d59a1257f58e45ade2825e2e47b7f 100644 (file)
@@ -24,7 +24,7 @@
 using std::ifstream;
 using std::string;
 
-BOOST_AUTO_TEST_CASE (bsae64_decode_test)
+BOOST_AUTO_TEST_CASE (base64_decode_test)
 {
        int const N = 256;
        
@@ -54,3 +54,19 @@ BOOST_AUTO_TEST_CASE (bsae64_decode_test)
                BOOST_CHECK_EQUAL (decoded[i], ref_decoded[i]);
        }
 }
+
+BOOST_AUTO_TEST_CASE (content_kind_test)
+{
+       BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("feature"), libdcp::FEATURE);
+       BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("Feature"), libdcp::FEATURE);
+       BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("FeaturE"), libdcp::FEATURE);
+       BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("Short"), libdcp::SHORT);
+       BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("trailer"), libdcp::TRAILER);
+       BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("test"), libdcp::TEST);
+       BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("transitional"), libdcp::TRANSITIONAL);
+       BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("rating"), libdcp::RATING);
+       BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("teaser"), libdcp::TEASER);
+       BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("policy"), libdcp::POLICY);
+       BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("psa"), libdcp::PUBLIC_SERVICE_ANNOUNCEMENT);
+       BOOST_CHECK_EQUAL (libdcp::content_kind_from_string ("advertisement"), libdcp::ADVERTISEMENT);
+}