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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
|
#include "cppunit/extensions/HelperMacros.h"
#include "DataFormats/Provenance/interface/ProductID.h"
#include "DataFormats/Common/interface/DetSetRefVector.h"
#include "DataFormats/Common/interface/TestHandle.h"
class testDetSetRefVector : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(testDetSetRefVector);
CPPUNIT_TEST(checkConstruction);
CPPUNIT_TEST(checkFind);
CPPUNIT_TEST_SUITE_END();
public:
void setUp() {}
void tearDown() {}
void checkConstruction();
void checkFind();
};
CPPUNIT_TEST_SUITE_REGISTRATION(testDetSetRefVector);
namespace testdetsetrefvector {
class Value {
public:
// VALUES must be default constructible
Value() : d_(0.0) {}
// This constructor is used for testing; it is not required by the
// concept VALUE.
explicit Value(double d) : d_(d) {}
// This access function is used for testing; it is not required by
// the concept VALUE.
double val() const { return d_; }
// VALUES must be destructible
~Value() {}
// VALUES must be LessThanComparable
bool operator<(Value const& other) const { return d_ < other.d_; }
// The private stuff below is all implementation detail, and not
// required by the concept VALUE.
private:
double d_;
};
} // namespace testdetsetrefvector
using namespace testdetsetrefvector;
typedef edm::DetSetVector<Value> dsv_type;
typedef dsv_type::detset detset;
void testDetSetRefVector::checkConstruction() {
dsv_type c;
detset d3;
Value v1(1.1);
Value v2(2.2);
d3.id = edm::det_id_type(3);
d3.data.push_back(v1);
d3.data.push_back(v2);
c.insert(d3);
detset d1;
Value v1a(4.1);
Value v2a(3.2);
d1.id = edm::det_id_type(1);
d1.data.push_back(v1a);
d1.data.push_back(v2a);
c.insert(d1);
c.post_insert();
edm::TestHandle<dsv_type> pc2(&c, edm::ProductID(1, 1));
{
std::vector<edm::det_id_type> ids;
ids.push_back(1);
ids.push_back(3);
edm::DetSetRefVector<Value> refVector(pc2, ids);
CPPUNIT_ASSERT(refVector.size() == ids.size());
dsv_type::const_iterator dsvItr = c.begin();
for (edm::DetSetRefVector<Value>::const_iterator it = refVector.begin(), itEnd = refVector.end(); it != itEnd;
++it, ++dsvItr) {
CPPUNIT_ASSERT(it->id == dsvItr->id);
CPPUNIT_ASSERT(it->data.size() == dsvItr->data.size());
}
}
{
std::vector<edm::det_id_type> ids;
ids.push_back(3);
edm::DetSetRefVector<Value> refVector(pc2, ids);
CPPUNIT_ASSERT(refVector.size() == ids.size());
edm::DetSetRefVector<Value>::const_iterator itRef = refVector.begin();
for (std::vector<edm::det_id_type>::const_iterator itId = ids.begin(), itIdEnd = ids.end(); itId != itIdEnd;
++itRef, ++itId) {
CPPUNIT_ASSERT(itRef->id == *itId);
CPPUNIT_ASSERT(itRef->id == c.find(*itId)->id);
CPPUNIT_ASSERT(itRef->data.size() == c.find(*itId)->data.size());
}
}
}
void testDetSetRefVector::checkFind() {
dsv_type c;
detset d3;
Value v1(1.1);
Value v2(2.2);
d3.id = edm::det_id_type(3);
d3.data.push_back(v1);
d3.data.push_back(v2);
c.insert(d3);
detset d1;
Value v1a(4.1);
Value v2a(3.2);
d1.id = edm::det_id_type(1);
d1.data.push_back(v1a);
d1.data.push_back(v2a);
c.insert(d1);
c.post_insert();
edm::TestHandle<dsv_type> pc2(&c, edm::ProductID(1, 1));
{
std::vector<edm::det_id_type> ids;
ids.push_back(1);
ids.push_back(3);
edm::DetSetRefVector<Value> refVector(pc2, ids);
CPPUNIT_ASSERT(refVector.find(1)->id == c.find(1)->id);
CPPUNIT_ASSERT(refVector.find(3)->id == c.find(3)->id);
CPPUNIT_ASSERT(refVector.find(4) == refVector.end());
}
}
|