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

Function check_qtvector_quaternion

test/qtvector.cpp:96–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

test_qtvectorFunction · 0.85

Calls 5

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

Tested by 1

test_qtvectorFunction · 0.68