Sort notes when checking verifications.
authorCarl Hetherington <cth@carlh.net>
Thu, 27 May 2021 09:44:21 +0000 (11:44 +0200)
committerCarl Hetherington <cth@carlh.net>
Thu, 27 May 2021 09:44:21 +0000 (11:44 +0200)
So that the lists in the tests don't have to be in the right order.

src/verify.cc
src/verify.h
test/verify_test.cc

index 7948767a84d8045fcd8c43faf26e6956284b19a4..623794cc9c276684bc00c5f9a97562726d4d0841 100644 (file)
@@ -1618,6 +1618,29 @@ dcp::operator== (dcp::VerificationNote const& a, dcp::VerificationNote const& b)
 }
 
 
+bool
+dcp::operator< (dcp::VerificationNote const& a, dcp::VerificationNote const& b)
+{
+       if (a.type() != b.type()) {
+               return a.type() < b.type();
+       }
+
+       if (a.code() != b.code()) {
+               return a.code() < b.code();
+       }
+
+       if (a.note() != b.note()) {
+               return a.note().get_value_or("") < b.note().get_value_or("");
+       }
+
+       if (a.file() != b.file()) {
+               return a.file().get_value_or("") < b.file().get_value_or("");
+       }
+
+       return a.line().get_value_or(0) < b.line().get_value_or(0);
+}
+
+
 std::ostream&
 dcp::operator<< (std::ostream& s, dcp::VerificationNote const& note)
 {
index 08be77c6333e107bdbe302bf4165395904831f95..372da7644f8f6d08cb5242eb66ac0c0a9542b7e7 100644 (file)
@@ -455,6 +455,7 @@ std::vector<VerificationNote> verify (
 std::string note_to_string (dcp::VerificationNote note);
 
 bool operator== (dcp::VerificationNote const& a, dcp::VerificationNote const& b);
+bool operator< (dcp::VerificationNote const& a, dcp::VerificationNote const& b);
 
 std::ostream& operator<<(std::ostream& s, dcp::VerificationNote const& note);
 
index 42da70059d946a9a0a613d501d145139ef19fc70..417b456344b6460bfc5677fbea589e1a7327abd1 100644 (file)
@@ -211,6 +211,8 @@ check_verify_result (vector<path> dir, vector<dcp::VerificationNote> test_notes)
 {
        auto notes = dcp::verify ({dir}, &stage, &progress, xsd_test);
        BOOST_REQUIRE_EQUAL (notes.size(), test_notes.size());
+       std::sort (notes.begin(), notes.end());
+       std::sort (test_notes.begin(), test_notes.end());
        for (auto i = 0U; i < notes.size(); ++i) {
                BOOST_REQUIRE_EQUAL (notes[i], test_notes[i]);
        }