1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/*
* serviceregistry_t.cppunit.cc
* CMSSW
*
* Created by Chris Jones on 9/7/05.
*
*/
#include <iostream>
#include "FWCore/ServiceRegistry/interface/connect_but_block_self.h"
#include <cppunit/extensions/HelperMacros.h>
class testConnectButBlockSelf : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(testConnectButBlockSelf);
CPPUNIT_TEST(test);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {}
void tearDown() {}
void test();
};
///registration of the test so that the runner can find it
CPPUNIT_TEST_SUITE_REGISTRATION(testConnectButBlockSelf);
namespace {
struct ReSignaller {
edm::signalslot::Signal<void()>* signal_;
int& seen_;
ReSignaller(edm::signalslot::Signal<void()>& iSig, int& iSee) : signal_(&iSig), seen_(iSee) {}
void operator()() {
//std::cout <<"see signal"<<std::endl;
++seen_;
(*signal_)();
}
};
} // namespace
void testConnectButBlockSelf::test() {
using namespace edm::serviceregistry;
edm::signalslot::Signal<void()> theSignal;
int iOne(0);
ReSignaller one(theSignal, iOne);
connect_but_block_self(theSignal, one);
int iTwo(0);
ReSignaller two(theSignal, iTwo);
connect_but_block_self(theSignal, two);
theSignal();
//std::cout <<"one "<<iOne <<std::endl;
//std::cout <<"two "<<iTwo <<std::endl;
//Both see two changes, but they never see their 'own' change
CPPUNIT_ASSERT(iOne == 2);
CPPUNIT_ASSERT(iTwo == 2);
}
|