diff options
| author | Carl Hetherington <cth@carlh.net> | 2024-12-23 16:30:01 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2024-12-23 17:35:02 +0100 |
| commit | 52d807654169d6443909c1d5dd20a155801faa26 (patch) | |
| tree | 727774d21ea1f4b54ccd61a09127894cb8d572ef /test/verify_test.cc | |
| parent | a6ccc587277b848b4a60c07456b11eb1b076d181 (diff) | |
Remove String::compose and use fmt instead.
Diffstat (limited to 'test/verify_test.cc')
| -rw-r--r-- | test/verify_test.cc | 63 |
1 files changed, 31 insertions, 32 deletions
diff --git a/test/verify_test.cc b/test/verify_test.cc index 608409ee..a78b0ccf 100644 --- a/test/verify_test.cc +++ b/test/verify_test.cc @@ -32,7 +32,6 @@ */ -#include "compose.hpp" #include "cpl.h" #include "dcp.h" #include "file.h" @@ -56,7 +55,7 @@ #include "verify.h" #include "verify_internal.h" #include "verify_j2k.h" -#include <fmt/core.h> +#include <fmt/format.h> #include <boost/algorithm/string.hpp> #include <boost/random.hpp> #include <boost/test/unit_test.hpp> @@ -191,9 +190,9 @@ find_asset_map(path dir) static path setup (int reference_number, string verify_test_suffix) { - auto const dir = dcp::String::compose("build/test/verify_test%1", verify_test_suffix); + auto const dir = fmt::format("build/test/verify_test{}", verify_test_suffix); prepare_directory (dir); - for (auto i: directory_iterator(dcp::String::compose("test/ref/DCP/dcp_test%1", reference_number))) { + for (auto i: directory_iterator(fmt::format("test/ref/DCP/dcp_test{}", reference_number))) { copy_file (i.path(), dir / i.path().filename()); } @@ -236,18 +235,18 @@ static string to_string(dcp::VerificationNote const& note) { - string s = note_to_string(note) + dcp::String::compose( - "\n [%1 %2 %3 %4 %5 %6 ", + string s = note_to_string(note) + fmt::format( + "\n [{} {} {} {} {} {} ", static_cast<int>(note.type()), static_cast<int>(note.code()), note.note().get_value_or("<none>"), - note.file().get_value_or("<none>"), + note.file().get_value_or("<none>").string(), note.line().get_value_or(0), note.frame().get_value_or(0) ); - s += dcp::String::compose( - "%1 %2 %3 %4 %5]\n", + s += fmt::format( + "{} {} {} {} {}]\n", note.id().get_value_or("<none>"), note.other_id().get_value_or("<none>"), note.cpl_id().get_value_or("<none>"), @@ -580,7 +579,7 @@ static path dcp_test1_cpl_path(string suffix) { - return dcp::String::compose("build/test/verify_test%1/%2", suffix, dcp_test1_cpl()); + return fmt::format("build/test/verify_test{}/{}", suffix, dcp_test1_cpl().string()); } @@ -588,7 +587,7 @@ static path dcp_test1_pkl_path(string suffix) { - return dcp::String::compose("build/test/verify_test%1/%2", suffix, dcp_test1_pkl()); + return fmt::format("build/test/verify_test{}/{}", suffix, dcp_test1_pkl().string()); } @@ -596,7 +595,7 @@ static path asset_map (string suffix) { - return dcp::String::compose("build/test/verify_test%1/ASSETMAP.xml", suffix); + return fmt::format("build/test/verify_test{}/ASSETMAP.xml", suffix); } @@ -606,7 +605,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_picture_frame_rate) replace(suffix, &dcp_test1_cpl_path, "<FrameRate>24 1", "<FrameRate>99 1"); - auto const dir = dcp::String::compose("build/test/verify_test%1", suffix); + auto const dir = fmt::format("build/test/verify_test{}", suffix); auto const cpl_path = find_cpl(dir); auto cpl = std::make_shared<dcp::CPL>(cpl_path); @@ -671,7 +670,7 @@ BOOST_AUTO_TEST_CASE (verify_empty_asset_path) replace("empty_asset_path", &asset_map, "<Path>video.mxf</Path>", "<Path></Path>"); - auto const dir = dcp::String::compose("build/test/verify_test%1", suffix); + auto const dir = fmt::format("build/test/verify_test{}", suffix); auto const cpl_path = find_cpl(dir); auto cpl = std::make_shared<dcp::CPL>(cpl_path); @@ -701,7 +700,7 @@ BOOST_AUTO_TEST_CASE (verify_mismatched_standard) replace(suffix, &dcp_test1_cpl_path, "http://www.smpte-ra.org/schemas/429-7/2006/CPL", "http://www.digicine.com/PROTO-ASDCP-CPL-20040511#"); - auto const dir = dcp::String::compose("build/test/verify_test%1", suffix); + auto const dir = fmt::format("build/test/verify_test{}", suffix); auto const cpl_path = find_cpl(dir); auto cpl = std::make_shared<dcp::CPL>(cpl_path); @@ -756,7 +755,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_xml_cpl_id) /* There's no MISMATCHED_CPL_HASHES error here because it can't find the correct hash by ID (since the ID is wrong) */ replace("invalid_xml_cpl_id", &dcp_test1_cpl_path, "<Id>urn:uuid:6affb8ee-0020-4dff-a53c-17652f6358ab", "<Id>urn:uuid:6affb8ee-0020-4dff-a53c-17652f6358a"); - auto const dir = dcp::String::compose("build/test/verify_test%1", suffix); + auto const dir = fmt::format("build/test/verify_test{}", suffix); auto const cpl_path = find_cpl(dir); auto cpl = std::make_shared<dcp::CPL>(cpl_path); @@ -792,7 +791,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_xml_issue_date) replace("invalid_xml_issue_date", &dcp_test1_cpl_path, "<IssueDate>", "<IssueDate>x"); - auto const dir = dcp::String::compose("build/test/verify_test%1", suffix); + auto const dir = fmt::format("build/test/verify_test{}", suffix); auto const cpl_path = find_cpl(dir); auto cpl = std::make_shared<dcp::CPL>(cpl_path); @@ -830,7 +829,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_xml_pkl_id) replace("invalid_xml_pkl_id", &dcp_test1_pkl_path, "<Id>urn:uuid:" + dcp_test1_pkl_id().substr(0, 3), "<Id>urn:uuid:x" + dcp_test1_pkl_id().substr(1, 2)); - auto const dir = dcp::String::compose("build/test/verify_test%1", suffix); + auto const dir = fmt::format("build/test/verify_test{}", suffix); auto const pkl_path = find_pkl(dir); auto const cpl_path = find_cpl(dir); auto cpl = std::make_shared<dcp::CPL>(cpl_path); @@ -868,7 +867,7 @@ BOOST_AUTO_TEST_CASE (verify_invalid_xml_asset_map_id) replace("invalid_xml_asset_map_id", &asset_map, "<Id>urn:uuid:" + dcp_test1_asset_map_id.substr(0, 3), "<Id>urn:uuid:x" + dcp_test1_asset_map_id.substr(1, 2)); - auto const dir = dcp::String::compose("build/test/verify_test%1", suffix); + auto const dir = fmt::format("build/test/verify_test{}", suffix); auto const cpl_path = find_cpl(dir); auto const asset_map_path = find_asset_map(dir); auto cpl = std::make_shared<dcp::CPL>(cpl_path); @@ -1891,7 +1890,7 @@ check_picture_size_ok (int width, int height, int frame_rate, bool three_d) dcp::VerificationNote( dcp::VerificationNote::Type::OK, dcp::VerificationNote::Code::VALID_MAIN_PICTURE_ACTIVE_AREA, - dcp::String::compose("%1x%2", width, height), + fmt::format("{}x{}", width, height), cpl->file().get() ).set_cpl_id(cpl->id()), ok(dcp::VerificationNote::Code::CORRECT_PICTURE_HASH, canonical(dir / "video.mxf"), cpl), @@ -1920,13 +1919,13 @@ check_picture_size_bad_frame_size (int width, int height, int frame_rate, bool t dcp::VerificationNote( dcp::VerificationNote::Type::OK, dcp::VerificationNote::Code::VALID_MAIN_PICTURE_ACTIVE_AREA, - dcp::String::compose("%1x%2", width, height), + fmt::format("{}x{}", width, height), cpl->file().get() ).set_cpl_id(cpl->id()), ok(dcp::VerificationNote::Code::CORRECT_PICTURE_HASH, canonical(dir / "video.mxf"), cpl), ok(dcp::VerificationNote::Code::VALID_PICTURE_FRAME_SIZES_IN_BYTES, canonical(dir / "video.mxf"), cpl), dcp::VerificationNote( - dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_SIZE_IN_PIXELS, dcp::String::compose("%1x%2", width, height), canonical(dir / "video.mxf") + dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_SIZE_IN_PIXELS, fmt::format("{}x{}", width, height), canonical(dir / "video.mxf") ).set_cpl_id(cpl->id()) }; check_verify_result(notes, expected); @@ -1952,16 +1951,16 @@ check_picture_size_bad_2k_frame_rate (int width, int height, int frame_rate, boo dcp::VerificationNote( dcp::VerificationNote::Type::OK, dcp::VerificationNote::Code::VALID_MAIN_PICTURE_ACTIVE_AREA, - dcp::String::compose("%1x%2", width, height), + fmt::format("{}x{}", width, height), cpl->file().get() ).set_cpl_id(cpl->id()), ok(dcp::VerificationNote::Code::CORRECT_PICTURE_HASH, canonical(dir / "video.mxf"), cpl), ok(dcp::VerificationNote::Code::VALID_PICTURE_FRAME_SIZES_IN_BYTES, canonical(dir / "video.mxf"), cpl), dcp::VerificationNote( - dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE, dcp::String::compose("%1/1", frame_rate * (three_d ? 2 : 1)) + dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE, fmt::format("{}/1", frame_rate * (three_d ? 2 : 1)) ).set_cpl_id(cpl->id()), dcp::VerificationNote( - dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_2K, dcp::String::compose("%1/1", frame_rate), canonical(dir / "video.mxf") + dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_2K, fmt::format("{}/1", frame_rate), canonical(dir / "video.mxf") ).set_cpl_id(cpl->id()) }; @@ -1988,13 +1987,13 @@ check_picture_size_bad_4k_frame_rate (int width, int height, int frame_rate, boo dcp::VerificationNote( dcp::VerificationNote::Type::OK, dcp::VerificationNote::Code::VALID_MAIN_PICTURE_ACTIVE_AREA, - dcp::String::compose("%1x%2", width, height), + fmt::format("{}x{}", width, height), cpl->file().get() ).set_cpl_id(cpl->id()), ok(dcp::VerificationNote::Code::CORRECT_PICTURE_HASH, canonical(dir / "video.mxf"), cpl), ok(dcp::VerificationNote::Code::VALID_PICTURE_FRAME_SIZES_IN_BYTES, canonical(dir / "video.mxf"), cpl), dcp::VerificationNote( - dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_4K, dcp::String::compose("%1/1", frame_rate), canonical(dir / "video.mxf") + dcp::VerificationNote::Type::BV21_ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_RATE_FOR_4K, fmt::format("{}/1", frame_rate), canonical(dir / "video.mxf") ).set_cpl_id(cpl->id()) }; @@ -2154,7 +2153,7 @@ make_large_subtitle_asset (path font_file) dcp::ArrayData big_fake_font(1024 * 1024); big_fake_font.write (font_file); for (int i = 0; i < 116; ++i) { - asset->add_font (dcp::String::compose("big%1", i), big_fake_font); + asset->add_font(fmt::format("big{}", i), big_fake_font); } return asset; } @@ -4824,10 +4823,10 @@ BOOST_AUTO_TEST_CASE (verify_mismatched_subtitle_resource_id) auto subs_mxf = dir / "subs.mxf"; auto r = writer.OpenWrite(subs_mxf.string().c_str(), writer_info, descriptor, 4096); BOOST_REQUIRE (ASDCP_SUCCESS(r)); - writer.WriteTimedTextResource (dcp::String::compose( + writer.WriteTimedTextResource(fmt::format( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" "<SubtitleReel xmlns=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\">" - "<Id>urn:uuid:%1</Id>" + "<Id>urn:uuid:{}</Id>" "<ContentTitleText>Content</ContentTitleText>" "<AnnotationText>Annotation</AnnotationText>" "<IssueDate>2018-10-02T12:25:14</IssueDate>" @@ -4904,10 +4903,10 @@ BOOST_AUTO_TEST_CASE (verify_incorrect_timed_text_id) auto subs_mxf = dir / "subs.mxf"; auto r = writer.OpenWrite(subs_mxf.string().c_str(), writer_info, descriptor, 4096); BOOST_REQUIRE (ASDCP_SUCCESS(r)); - writer.WriteTimedTextResource (dcp::String::compose( + writer.WriteTimedTextResource(fmt::format( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" "<SubtitleReel xmlns=\"http://www.smpte-ra.org/schemas/428-7/2010/DCST\">" - "<Id>urn:uuid:%1</Id>" + "<Id>urn:uuid:{}</Id>" "<ContentTitleText>Content</ContentTitleText>" "<AnnotationText>Annotation</AnnotationText>" "<IssueDate>2018-10-02T12:25:14+02:00</IssueDate>" |
