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
|
#include "Utilities/Testing/interface/CppUnit_testdriver.icpp"
#include "cppunit/extensions/HelperMacros.h"
#include "DataFormats/Common/interface/RefCore.h"
#include "DataFormats/Common/interface/RefCoreWithIndex.h"
#include "DataFormats/Common/interface/EDProductGetter.h"
#include "SimpleEDProductGetter.h"
class TestRefCore : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(TestRefCore);
CPPUNIT_TEST(default_ctor);
CPPUNIT_TEST(default_ctor_withindex);
CPPUNIT_TEST(nondefault_ctor);
CPPUNIT_TEST(nondefault_ctor_withindex);
CPPUNIT_TEST_SUITE_END();
public:
TestRefCore() {}
~TestRefCore() {}
void setUp() {}
void tearDown() {}
void default_ctor();
void nondefault_ctor();
void default_ctor_withindex();
void nondefault_ctor_withindex();
private:
};
CPPUNIT_TEST_SUITE_REGISTRATION(TestRefCore);
void TestRefCore::default_ctor() {
edm::RefCore default_refcore;
CPPUNIT_ASSERT(default_refcore.isNull());
CPPUNIT_ASSERT(default_refcore.isNonnull() == false);
CPPUNIT_ASSERT(!default_refcore);
CPPUNIT_ASSERT(default_refcore.productGetter() == 0);
CPPUNIT_ASSERT(default_refcore.id().isValid() == false);
}
void TestRefCore::nondefault_ctor() {
SimpleEDProductGetter getter;
edm::ProductID id(1, 201U);
CPPUNIT_ASSERT(id.isValid());
edm::RefCore refcore(id, 0, &getter, false);
CPPUNIT_ASSERT(refcore.isNull() == false);
CPPUNIT_ASSERT(refcore.isNonnull());
CPPUNIT_ASSERT(!!refcore);
CPPUNIT_ASSERT(refcore.productGetter() == &getter);
CPPUNIT_ASSERT(refcore.id().isValid());
}
void TestRefCore::default_ctor_withindex() {
edm::RefCoreWithIndex default_refcore;
CPPUNIT_ASSERT(default_refcore.isNull());
CPPUNIT_ASSERT(default_refcore.isNonnull() == false);
CPPUNIT_ASSERT(!default_refcore);
CPPUNIT_ASSERT(default_refcore.productGetter() == 0);
CPPUNIT_ASSERT(default_refcore.id().isValid() == false);
CPPUNIT_ASSERT(default_refcore.index() == edm::key_traits<unsigned int>::value);
edm::RefCore compareTo;
edm::RefCore const& converted = default_refcore.toRefCore();
CPPUNIT_ASSERT(compareTo.productGetter() == converted.productGetter());
CPPUNIT_ASSERT(compareTo.id() == converted.id());
}
void TestRefCore::nondefault_ctor_withindex() {
SimpleEDProductGetter getter;
edm::ProductID id(1, 201U);
CPPUNIT_ASSERT(id.isValid());
edm::RefCoreWithIndex refcore(id, 0, &getter, false, 1);
CPPUNIT_ASSERT(refcore.isNull() == false);
CPPUNIT_ASSERT(refcore.isNonnull());
CPPUNIT_ASSERT(!!refcore);
CPPUNIT_ASSERT(refcore.productGetter() == &getter);
CPPUNIT_ASSERT(refcore.id().isValid());
CPPUNIT_ASSERT(refcore.index() == 1);
edm::RefCore compareTo(id, 0, &getter, false);
edm::RefCore const& converted = refcore.toRefCore();
CPPUNIT_ASSERT(compareTo.productGetter() == converted.productGetter());
CPPUNIT_ASSERT(compareTo.id() == converted.id());
}
|