File indexing completed on 2024-04-06 12:13:03
0001
0002
0003
0004
0005
0006
0007
0008 #include <iostream>
0009
0010 #include "FWCore/ServiceRegistry/interface/connect_but_block_self.h"
0011
0012 #include <cppunit/extensions/HelperMacros.h>
0013
0014 class testConnectButBlockSelf : public CppUnit::TestFixture {
0015 CPPUNIT_TEST_SUITE(testConnectButBlockSelf);
0016
0017 CPPUNIT_TEST(test);
0018
0019 CPPUNIT_TEST_SUITE_END();
0020
0021 public:
0022 void setUp() {}
0023 void tearDown() {}
0024
0025 void test();
0026 };
0027
0028
0029 CPPUNIT_TEST_SUITE_REGISTRATION(testConnectButBlockSelf);
0030
0031 namespace {
0032 struct ReSignaller {
0033 edm::signalslot::Signal<void()>* signal_;
0034 int& seen_;
0035
0036 ReSignaller(edm::signalslot::Signal<void()>& iSig, int& iSee) : signal_(&iSig), seen_(iSee) {}
0037
0038 void operator()() {
0039
0040 ++seen_;
0041 (*signal_)();
0042 }
0043 };
0044 }
0045
0046 void testConnectButBlockSelf::test() {
0047 using namespace edm::serviceregistry;
0048 edm::signalslot::Signal<void()> theSignal;
0049
0050 int iOne(0);
0051 ReSignaller one(theSignal, iOne);
0052 connect_but_block_self(theSignal, one);
0053
0054 int iTwo(0);
0055 ReSignaller two(theSignal, iTwo);
0056 connect_but_block_self(theSignal, two);
0057
0058 theSignal();
0059
0060
0061
0062
0063
0064 CPPUNIT_ASSERT(iOne == 2);
0065 CPPUNIT_ASSERT(iTwo == 2);
0066 }