7 #define BOOST_TEST_DYN_LINK
8 #define BOOST_TEST_MODULE "Test module for Map component"
12 #include <boost/test/unit_test.hpp>
13 #include <boost/lexical_cast.hpp>
14 #include <boost/shared_ptr.hpp>
15 #include <boost/weak_ptr.hpp>
34 typedef boost::weak_ptr<Uint>
WeakT;
40 static SharedT*
v = 0;
42 v =
new SharedT[vec_size];
50 v =
new WeakT[vec_size];
56 static HandleT*
v = 0;
58 v =
new HandleT[vec_size];
66 v =
new RawT[vec_size*2];
70 static const Uint vec_size = 1000000;
71 static const Uint deref_repeats = 100;
76 BOOST_FIXTURE_TEST_SUITE( BuildOptions,
PtrFixture )
82 std::cout <<
"size of boost::shared_ptr: " <<
sizeof(SharedT) << std::endl;
83 std::cout <<
"size of boost::weak_ptr: " <<
sizeof(WeakT) << std::endl;
84 std::cout <<
"size of raw pointer: " <<
sizeof(RawT) << std::endl;
86 SharedT* vec = shared_vec();
87 for(
Uint i = 0; i != vec_size; ++i)
88 vec[i] = boost::shared_ptr<Uint>(
new Uint(i));
93 SharedT* s_vec = shared_vec();
94 WeakT* w_vec = weak_vec();
95 for(
Uint i = 0; i != vec_size; ++i)
101 SharedT* s_vec = shared_vec();
102 HandleT* w_vec = handle_vec();
103 for(
Uint i = 0; i != vec_size; ++i)
104 w_vec[i] = HandleT(s_vec[i]);
109 RawT* vec = raw_vec();
110 for(
Uint i = 0; i != 2*vec_size; ++i)
111 vec[i] =
new Uint(i/2);
116 SharedT* new_vec =
new SharedT[vec_size];
117 SharedT* old_vec = shared_vec();
118 for(
Uint i = 0; i != vec_size; ++i)
119 new_vec[i] = old_vec[i];
124 WeakT* new_vec =
new WeakT[vec_size];
125 WeakT* old_vec = weak_vec();
126 for(
Uint i = 0; i != vec_size; ++i)
127 new_vec[i] = old_vec[i];
132 HandleT* new_vec =
new HandleT[vec_size];
133 HandleT* old_vec = handle_vec();
134 for(
Uint i = 0; i != vec_size; ++i)
135 new_vec[i] = old_vec[i];
140 RawT* new_vec =
new RawT[vec_size*2];
141 RawT* old_vec = raw_vec();
142 for(
Uint i = 0; i != vec_size; ++i)
143 new_vec[2*i] = old_vec[2*i];
148 SharedT* vec = shared_vec();
150 for(
Uint i = 0; i != vec_size; ++i)
152 BOOST_CHECK(vec_size == result);
157 WeakT* vec = weak_vec();
159 for(
Uint i = 0; i != vec_size; ++i)
160 result += !vec[i].expired();
161 BOOST_CHECK(vec_size == result);
166 HandleT* vec = handle_vec();
168 for(
Uint i = 0; i != vec_size; ++i)
170 BOOST_CHECK(vec_size == result);
175 RawT* vec = raw_vec();
177 for(
Uint i = 0; i != vec_size; ++i)
179 BOOST_CHECK(vec_size == result);
184 SharedT* vec = shared_vec();
186 for(
Uint r = 0; r != deref_repeats; ++r)
188 for(
Uint i = 0; i != vec_size; ++i)
198 WeakT* vec = weak_vec();
200 for(
Uint r = 0; r != deref_repeats; ++r)
202 for(
Uint i = 0; i != vec_size; ++i)
204 result += *vec[i].lock();
212 HandleT* vec = handle_vec();
214 for(
Uint r = 0; r != deref_repeats; ++r)
216 for(
Uint i = 0; i != vec_size; ++i)
226 RawT* vec = raw_vec();
228 for(
Uint r = 0; r != deref_repeats; ++r)
230 for(
Uint i = 0; i != vec_size; ++i)
238 BOOST_AUTO_TEST_SUITE_END()
boost::shared_ptr< Uint > SharedT
Safe pointer to an object. This is the supported method for referring to components.
Top-level namespace for coolfluid.
boost::weak_ptr< Uint > WeakT
unsigned int Uint
typedef for unsigned int
coolfluid3 header, included almost everywhere
BOOST_AUTO_TEST_CASE(FillShared)
Most basic kernel library.
bool is_not_null(T ptr)
predicate for comparison to nullptr