Tidy up find_cpl() and add find_pkl().
authorCarl Hetherington <cth@carlh.net>
Thu, 15 Dec 2022 22:52:43 +0000 (23:52 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 15 Dec 2022 22:52:43 +0000 (23:52 +0100)
test/verify_test.cc

index 02067cf348f5f8e1ba5340e929518c6695d200f7..52d774bdf6c42d8a87d5113076860e199329701e 100644 (file)
@@ -963,19 +963,32 @@ BOOST_AUTO_TEST_CASE (verify_valid_cpl_metadata)
 }
 
 
+path
+find_prefix(path dir, string prefix)
+{
+       auto iter = std::find_if(directory_iterator(dir), directory_iterator(), [prefix](path const& p) {
+               return boost::starts_with(p.filename().string(), prefix);
+       });
+
+       BOOST_REQUIRE(iter != directory_iterator());
+       return iter->path();
+}
+
+
 path find_cpl (path dir)
 {
-       for (auto i: directory_iterator(dir)) {
-               if (boost::starts_with(i.path().filename().string(), "cpl_")) {
-                       return i.path();
-               }
-       }
+       return find_prefix(dir, "cpl_");
+}
+
 
-       BOOST_REQUIRE (false);
-       return {};
+path
+find_pkl(path dir)
+{
+       return find_prefix(dir, "pkl_");
 }
 
 
+
 /* DCP with invalid CompositionMetadataAsset */
 BOOST_AUTO_TEST_CASE (verify_invalid_cpl_metadata_bad_tag)
 {