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

Function check_stdvector_quaternion

test/stdvector_overload.cpp:100–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98
99template<typename QuaternionType>
100void check_stdvector_quaternion(const QuaternionType&)
101{
102 typedef typename QuaternionType::Coefficients Coefficients;
103 QuaternionType x(Coefficients::Random()), y(Coefficients::Random());
104 std::vector<QuaternionType> v(10), w(20, y);
105 v[5] = x;
106 w[6] = v[5];
107 VERIFY_IS_APPROX(w[6], v[5]);
108 v = w;
109 for(int i = 0; i < 20; i++)
110 {
111 VERIFY_IS_APPROX(w[i], v[i]);
112 }
113
114 v.resize(21);
115 v[20] = x;
116 VERIFY_IS_APPROX(v[20], x);
117 v.resize(22,y);
118 VERIFY_IS_APPROX(v[21], y);
119 v.push_back(x);
120 VERIFY_IS_APPROX(v[22], x);
121 VERIFY((internal::UIntPtr)&(v[22]) == (internal::UIntPtr)&(v[21]) + sizeof(QuaternionType));
122
123 // do a lot of push_back such that the vector gets internally resized
124 // (with memory reallocation)
125 QuaternionType* ref = &w[0];
126 for(int i=0; i<30 || ((ref==&w[0]) && i<300); ++i)
127 v.push_back(w[i%w.size()]);
128 for(unsigned int i=23; i<v.size(); ++i)
129 {
130 VERIFY(v[i].coeffs()==w[(i-23)%w.size()].coeffs());
131 }
132}
133
134void test_stdvector_overload()
135{

Callers 1

test_stdvector_overloadFunction · 0.70

Calls 4

coeffsMethod · 0.80
resizeMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45

Tested by 1

test_stdvector_overloadFunction · 0.56