File tree 2 files changed +28
-3
lines changed 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]")
75
75
assert (ok);
76
76
assert (copy.equal (&multipart));
77
77
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
+
78
93
multipart.clear ();
79
94
assert (multipart.empty ());
80
95
Original file line number Diff line number Diff line change @@ -612,16 +612,26 @@ class multipart_t
612
612
}
613
613
614
614
// Check if equal to other multipart
615
- bool equal (const multipart_t *other) const
615
+ bool equal (const multipart_t *other) const ZMQ_NOTHROW
616
616
{
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 ())
618
623
return false ;
619
624
for (size_t i = 0 ; i < size (); i++)
620
- if (* peek (i) != * other-> peek (i))
625
+ if (at (i) != other. at (i))
621
626
return false ;
622
627
return true ;
623
628
}
624
629
630
+ bool operator !=(const multipart_t &other) const ZMQ_NOTHROW
631
+ {
632
+ return !(*this == other);
633
+ }
634
+
625
635
#ifdef ZMQ_CPP11
626
636
627
637
// Return single part message_t encoded from this multipart_t.
You can’t perform that action at this time.
0 commit comments