Fix operator== to take everything in VerificationNote into account.
authorCarl Hetherington <cth@carlh.net>
Mon, 25 Dec 2023 23:32:55 +0000 (00:32 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 25 Dec 2023 23:32:55 +0000 (00:32 +0100)
src/verify.cc
test/verify_test.cc

index 960f0438816a3c726a604ecdcf692ac79fa5f4c5..c5abb85743b054d3567c1a4a1969f329d3385e24 100644 (file)
@@ -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("");
 }
 
 
index 47b5cc787908876e280787a7728b02579eb787bc..1127c2bf057d3ccc90625ae155c133c04a962cfa 100644 (file)
@@ -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<dcp::VerificationNote> 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);
 }