Nektar++
Functions
Nektar::ConsistentObjectAccessUnitTests Namespace Reference

Functions

 BOOST_AUTO_TEST_CASE (TestValueTypes)
 
 BOOST_AUTO_TEST_CASE (TestPointerTypes)
 
 BOOST_AUTO_TEST_CASE (TestSharedPointerTypes)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/3]

Nektar::ConsistentObjectAccessUnitTests::BOOST_AUTO_TEST_CASE ( TestPointerTypes  )

Definition at line 70 of file TestConsistentObjectAccess.cpp.

71{
73 double *d1 = new double(1.0);
74 const double *d2 = new double(2.0);
75
76 BOOST_CHECK_EQUAL(*d1, ConsistentObjectAccess<double *>::reference(d1));
77 BOOST_CHECK_EQUAL(d1, &ConsistentObjectAccess<double *>::reference(d1));
78 BOOST_CHECK_EQUAL(*d1,
80 BOOST_CHECK_EQUAL(d1,
82 BOOST_CHECK_EQUAL(d1, ConsistentObjectAccess<double *>::pointer(d1));
83 BOOST_CHECK_EQUAL(d1, ConsistentObjectAccess<double *>::const_pointer(d1));
86 static_cast<double *>(nullptr)));
87
88 BOOST_CHECK_EQUAL(*d2,
90 BOOST_CHECK_EQUAL(d2,
92 BOOST_CHECK_EQUAL(
94 BOOST_CHECK_EQUAL(
96 BOOST_CHECK_EQUAL(d2, ConsistentObjectAccess<const double *>::pointer(d2));
97 BOOST_CHECK_EQUAL(
101 static_cast<const double *>(nullptr)));
102
103#if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
105 static_cast<double *>(nullptr)),
108 static_cast<const double *>(nullptr)),
111 static_cast<double *>(nullptr)),
114 static_cast<const double *>(nullptr)),
116#endif
117}
void RedirectCerrIfNeeded()
Definition: util.cpp:41

References Nektar::UnitTests::RedirectCerrIfNeeded().

◆ BOOST_AUTO_TEST_CASE() [2/3]

Nektar::ConsistentObjectAccessUnitTests::BOOST_AUTO_TEST_CASE ( TestSharedPointerTypes  )

Definition at line 119 of file TestConsistentObjectAccess.cpp.

120{
121 double *d1 = new double(1.0);
122 const double *d2 = new double(2.0);
123
124 std::shared_ptr<double> sd1(d1);
125 std::shared_ptr<const double> sd2(d2);
126
127 BOOST_CHECK_EQUAL(
128 *d1, ConsistentObjectAccess<std::shared_ptr<double>>::reference(sd1));
129 BOOST_CHECK_EQUAL(
130 d1, &ConsistentObjectAccess<std::shared_ptr<double>>::reference(sd1));
131 BOOST_CHECK_EQUAL(
132 *d1,
133 ConsistentObjectAccess<std::shared_ptr<double>>::const_reference(sd1));
134 BOOST_CHECK_EQUAL(
135 d1,
136 &ConsistentObjectAccess<std::shared_ptr<double>>::const_reference(sd1));
137 BOOST_CHECK_EQUAL(
138 d1, ConsistentObjectAccess<std::shared_ptr<double>>::pointer(sd1));
139 BOOST_CHECK_EQUAL(
140 d1,
141 ConsistentObjectAccess<std::shared_ptr<double>>::const_pointer(sd1));
142 BOOST_CHECK(
143 ConsistentObjectAccess<std::shared_ptr<double>>::ReferencesObject(sd1));
144 BOOST_CHECK(
145 !ConsistentObjectAccess<std::shared_ptr<double>>::ReferencesObject(
146 std::shared_ptr<double>()));
147
148 BOOST_CHECK_EQUAL(
149 *d2,
150 ConsistentObjectAccess<std::shared_ptr<const double>>::reference(sd2));
151 BOOST_CHECK_EQUAL(
152 d2,
153 &ConsistentObjectAccess<std::shared_ptr<const double>>::reference(sd2));
154 BOOST_CHECK_EQUAL(
155 *d2,
156 ConsistentObjectAccess<std::shared_ptr<const double>>::const_reference(
157 sd2));
158 BOOST_CHECK_EQUAL(
159 d2,
160 &ConsistentObjectAccess<std::shared_ptr<const double>>::const_reference(
161 sd2));
162 BOOST_CHECK_EQUAL(
163 d2,
164 ConsistentObjectAccess<std::shared_ptr<const double>>::pointer(sd2));
165 BOOST_CHECK_EQUAL(
166 d2,
167 ConsistentObjectAccess<std::shared_ptr<const double>>::const_pointer(
168 sd2));
169 BOOST_CHECK(
170 ConsistentObjectAccess<std::shared_ptr<const double>>::ReferencesObject(
171 sd2));
172 BOOST_CHECK(!ConsistentObjectAccess<std::shared_ptr<const double>>::
173 ReferencesObject(std::shared_ptr<const double>()));
174
175#if defined(NEKTAR_DEBUG) || defined(NEKTAR_FULLDEBUG)
176 BOOST_CHECK_THROW(
177 ConsistentObjectAccess<std::shared_ptr<double>>::const_reference(
178 std::shared_ptr<double>()),
180 BOOST_CHECK_THROW(
181 ConsistentObjectAccess<std::shared_ptr<const double>>::const_reference(
182 std::shared_ptr<const double>()),
184 BOOST_CHECK_THROW(
185 ConsistentObjectAccess<std::shared_ptr<double>>::reference(
186 std::shared_ptr<double>()),
188 BOOST_CHECK_THROW(
189 ConsistentObjectAccess<std::shared_ptr<const double>>::reference(
190 std::shared_ptr<const double>()),
192#endif
193}

◆ BOOST_AUTO_TEST_CASE() [3/3]

Nektar::ConsistentObjectAccessUnitTests::BOOST_AUTO_TEST_CASE ( TestValueTypes  )

Definition at line 43 of file TestConsistentObjectAccess.cpp.

44{
45 double d1 = 1.0;
46 const double d2 = 2.0;
47
48 BOOST_CHECK_EQUAL(d1, ConsistentObjectAccess<double>::reference(d1));
49 BOOST_CHECK_EQUAL(&d1, &ConsistentObjectAccess<double>::reference(d1));
50 BOOST_CHECK_EQUAL(d1, ConsistentObjectAccess<double>::const_reference(d1));
51 BOOST_CHECK_EQUAL(&d1,
53 BOOST_CHECK_EQUAL(&d1, ConsistentObjectAccess<double>::pointer(d1));
54 BOOST_CHECK_EQUAL(&d1, ConsistentObjectAccess<double>::const_pointer(d1));
56
57 BOOST_CHECK_EQUAL(d2, ConsistentObjectAccess<const double>::reference(d2));
58 BOOST_CHECK_EQUAL(&d2,
60 BOOST_CHECK_EQUAL(
62 BOOST_CHECK_EQUAL(
64 BOOST_CHECK_EQUAL(&d2, ConsistentObjectAccess<const double>::pointer(d2));
65 BOOST_CHECK_EQUAL(&d2,
68}