File tree Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Expand file tree Collapse file tree 2 files changed +28
-3
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,21 @@ TEST_CASE("multipart legacy test", "[multipart]")
7575 assert (ok);
7676 assert (copy.equal (&multipart));
7777
78+ // Test equality operators
79+ assert (copy == multipart);
80+ assert (multipart == copy);
81+
82+ multipart.pop ();
83+
84+ assert (copy != multipart);
85+ assert (multipart != copy);
86+
87+ multipart_t emptyMessage1 {};
88+ multipart_t emptyMessage2 {};
89+
90+ assert (emptyMessage1 == emptyMessage2);
91+ assert (emptyMessage2 == emptyMessage1);
92+
7893 multipart.clear ();
7994 assert (multipart.empty ());
8095
Original file line number Diff line number Diff line change @@ -612,16 +612,26 @@ class multipart_t
612612 }
613613
614614 // Check if equal to other multipart
615- bool equal (const multipart_t *other) const
615+ bool equal (const multipart_t *other) const ZMQ_NOTHROW
616616 {
617- if (size () != other->size ())
617+ return *this == *other;
618+ }
619+
620+ bool operator ==(const multipart_t &other) const ZMQ_NOTHROW
621+ {
622+ if (size () != other.size ())
618623 return false ;
619624 for (size_t i = 0 ; i < size (); i++)
620- if (* peek (i) != * other-> peek (i))
625+ if (at (i) != other. at (i))
621626 return false ;
622627 return true ;
623628 }
624629
630+ bool operator !=(const multipart_t &other) const ZMQ_NOTHROW
631+ {
632+ return !(*this == other);
633+ }
634+
625635#ifdef ZMQ_CPP11
626636
627637 // Return single part message_t encoded from this multipart_t.
You can’t perform that action at this time.
0 commit comments