MCPcopy Create free account
hub / github.com/PX4/eigen / check_stdlist_quaternion

Function check_stdlist_quaternion

test/stdlist_overload.cpp:126–163  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

124
125template<typename QuaternionType>
126void check_stdlist_quaternion(const QuaternionType&)
127{
128 typedef typename QuaternionType::Coefficients Coefficients;
129 QuaternionType x(Coefficients::Random()), y(Coefficients::Random());
130 std::list<QuaternionType> v(10), w(20, y);
131 typename std::list<QuaternionType>::iterator itv = get(v, 5);
132 typename std::list<QuaternionType>::iterator itw = get(w, 6);
133 *itv = x;
134 *itw = *itv;
135 VERIFY_IS_APPROX(*itw, *itv);
136 v = w;
137 itv = v.begin();
138 itw = w.begin();
139 for(int i = 0; i < 20; i++)
140 {
141 VERIFY_IS_APPROX(*itw, *itv);
142 ++itv;
143 ++itw;
144 }
145
146 v.resize(21);
147 set(v, 20, x);
148 VERIFY_IS_APPROX(*get(v, 20), x);
149 v.resize(22,y);
150 VERIFY_IS_APPROX(*get(v, 21), y);
151 v.push_back(x);
152 VERIFY_IS_APPROX(*get(v, 22), x);
153
154 // do a lot of push_back such that the list gets internally resized
155 // (with memory reallocation)
156 QuaternionType* ref = &(*get(w, 0));
157 for(int i=0; i<30 || ((ref==&(*get(w, 0))) && i<300); ++i)
158 v.push_back(*get(w, i%w.size()));
159 for(unsigned int i=23; i<v.size(); ++i)
160 {
161 VERIFY(get(v, i)->coeffs()==get(w, (i-23)%w.size())->coeffs());
162 }
163}
164
165void test_stdlist_overload()
166{

Callers 1

test_stdlist_overloadFunction · 0.70

Calls 7

beginMethod · 0.80
coeffsMethod · 0.80
getFunction · 0.70
setFunction · 0.70
resizeMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by 1

test_stdlist_overloadFunction · 0.56