From: Carl Hetherington Date: Mon, 25 Dec 2023 23:32:55 +0000 (+0100) Subject: Fix operator== to take everything in VerificationNote into account. X-Git-Tag: v1.8.91~2 X-Git-Url: https://git.carlh.net/gitweb/?p=libdcp.git;a=commitdiff_plain;h=07314aa75683a7d6d34069514a8bb377bd2def77 Fix operator== to take everything in VerificationNote into account. --- diff --git a/src/verify.cc b/src/verify.cc index 960f0438..c5abb857 100644 --- a/src/verify.cc +++ b/src/verify.cc @@ -2124,7 +2124,16 @@ dcp::note_to_string (VerificationNote note) bool dcp::operator== (dcp::VerificationNote const& a, dcp::VerificationNote const& b) { - return a.type() == b.type() && a.code() == b.code() && a.note() == b.note() && a.file() == b.file() && a.line() == b.line(); + return a.type() == b.type() && + a.code() == b.code() && + a.note() == b.note() && + a.file() == b.file() && + a.line() == b.line() && + a.frame() == b.frame() && + a.component() == b.component() && + a.size() == b.size() && + a.id() == b.id() && + a.other_id() == b.other_id(); } @@ -2147,7 +2156,27 @@ dcp::operator< (dcp::VerificationNote const& a, dcp::VerificationNote const& b) return a.file().get_value_or("") < b.file().get_value_or(""); } - return a.line().get_value_or(0) < b.line().get_value_or(0); + if (a.line() != b.line()) { + return a.line().get_value_or(0) < b.line().get_value_or(0); + } + + if (a.frame() != b.frame()) { + return a.frame().get_value_or(0) < b.frame().get_value_or(0); + } + + if (a.component() != b.component()) { + return a.component().get_value_or(0) < b.component().get_value_or(0); + } + + if (a.size() != b.size()) { + return a.size().get_value_or(0) < b.size().get_value_or(0); + } + + if (a.id() != b.id()) { + return a.id().get_value_or("") < b.id().get_value_or(""); + } + + return a.other_id().get_value_or("") < b.other_id().get_value_or(""); } diff --git a/test/verify_test.cc b/test/verify_test.cc index 47b5cc78..1127c2bf 100644 --- a/test/verify_test.cc +++ b/test/verify_test.cc @@ -3645,15 +3645,37 @@ BOOST_AUTO_TEST_CASE(verify_invalid_tile_part_size) dcp->set_annotation_text("A Test DCP"); dcp->write_xml(); - check_verify_result( - { path }, - {}, - { - dcp::VerificationNote(dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_JPEG2000_TILE_PART_SIZE).set_frame(0).set_component(0).set_size(1321721), - { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_SIZE_IN_BYTES, canonical(path / "video.mxf") }, - { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::MISSING_FFOC }, - { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::MISSING_LFOC }, - }); + vector expected; + + expected.push_back( + { dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_PICTURE_FRAME_SIZE_IN_BYTES, canonical(path / "video.mxf") } + ); + + int component_sizes[] = { + 1321721, + 1294364, + 1289952, + }; + + for (auto frame = 0; frame < 24; frame++) { + for (auto component = 0; component < 3; component++) { + expected.push_back( + dcp::VerificationNote( + dcp::VerificationNote::Type::ERROR, dcp::VerificationNote::Code::INVALID_JPEG2000_TILE_PART_SIZE + ).set_frame(frame).set_component(component).set_size(component_sizes[component]) + ); + } + } + + expected.push_back( + { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::MISSING_FFOC } + ); + + expected.push_back( + { dcp::VerificationNote::Type::WARNING, dcp::VerificationNote::Code::MISSING_LFOC } + ); + + check_verify_result({ path }, {}, expected); }