Declare overloaded comparison operators as non-member functions
Change-Id: I4fd4638c29d01b39df69ad6d8cbc3a0dc9604db3
diff --git a/tests/unit/util/scheduler.t.cpp b/tests/unit/util/scheduler.t.cpp
index 3c13c70..d403a7c 100644
--- a/tests/unit/util/scheduler.t.cpp
+++ b/tests/unit/util/scheduler.t.cpp
@@ -222,23 +222,31 @@
BOOST_CHECK(!eid);
}
-BOOST_AUTO_TEST_CASE(Compare)
+BOOST_AUTO_TEST_CASE(Equality)
{
EventId eid, eid2;
- BOOST_CHECK_EQUAL(eid == eid2, true);
- BOOST_CHECK_EQUAL(eid != eid2, false);
+ BOOST_CHECK(eid == eid2);
eid = scheduler.schedule(10_ms, []{});
- BOOST_CHECK_EQUAL(eid == eid2, false);
- BOOST_CHECK_EQUAL(eid != eid2, true);
-
- eid2 = eid;
- BOOST_CHECK_EQUAL(eid, eid2);
- BOOST_CHECK_EQUAL(eid != eid2, false);
+ BOOST_CHECK(eid != eid2);
eid2 = scheduler.schedule(10_ms, []{});
- BOOST_CHECK_EQUAL(eid == eid2, false);
- BOOST_CHECK_NE(eid, eid2);
+ BOOST_CHECK(eid != eid2);
+
+ eid.cancel();
+ BOOST_CHECK(eid != eid2);
+ BOOST_CHECK(eid == EventId{});
+
+ eid2.cancel();
+ BOOST_CHECK(eid == eid2);
+
+ eid = eid2 = scheduler.schedule(20_ms, []{});
+ BOOST_CHECK(eid == eid2);
+ BOOST_CHECK(eid != EventId{});
+
+ eid.cancel();
+ BOOST_CHECK(eid == eid2);
+ BOOST_CHECK(eid == EventId{});
}
BOOST_AUTO_TEST_CASE(Valid)
diff --git a/tests/unit/util/signal.t.cpp b/tests/unit/util/signal.t.cpp
index f0eb192..2c53336 100644
--- a/tests/unit/util/signal.t.cpp
+++ b/tests/unit/util/signal.t.cpp
@@ -444,6 +444,35 @@
BOOST_CHECK_EQUAL(hit, 2); // handler called
}
+BOOST_AUTO_TEST_CASE(ConnectionEquality)
+{
+ SignalOwner0 so;
+
+ Connection conn1, conn2;
+ BOOST_CHECK(conn1 == conn2);
+
+ conn1 = so.sig.connect([]{});
+ BOOST_CHECK(conn1 != conn2);
+
+ conn2 = so.sig.connect([]{});
+ BOOST_CHECK(conn1 != conn2);
+
+ conn1.disconnect();
+ BOOST_CHECK(conn1 != conn2);
+ BOOST_CHECK(conn1 == Connection{});
+
+ conn2.disconnect();
+ BOOST_CHECK(conn1 == conn2);
+
+ conn1 = conn2 = so.sig.connect([]{});
+ BOOST_CHECK(conn1 == conn2);
+ BOOST_CHECK(conn1 != Connection{});
+
+ conn1.disconnect();
+ BOOST_CHECK(conn1 == conn2);
+ BOOST_CHECK(conn1 == Connection{});
+}
+
BOOST_AUTO_TEST_SUITE_END() // TestSignal
BOOST_AUTO_TEST_SUITE_END() // Util