From 16ff53a37012b52b4ccc39d87a383e10f7e5cbb8 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 15 Dec 2022 23:52:43 +0100 Subject: Tidy up find_cpl() and add find_pkl(). --- test/verify_test.cc | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'test') diff --git a/test/verify_test.cc b/test/verify_test.cc index 02067cf3..52d774bd 100644 --- a/test/verify_test.cc +++ b/test/verify_test.cc @@ -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) { -- cgit v1.2.3