mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 06:23:34 +08:00
Got coverage working for templates.
This commit is contained in:
@@ -1,9 +1,3 @@
|
||||
add_library(instantiation
|
||||
instantiation.cpp
|
||||
)
|
||||
|
||||
link_libraries(instantiation)
|
||||
|
||||
set(tests
|
||||
setIdentity
|
||||
inverse
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
// dummy code to instantiate all templates for coverage
|
||||
|
||||
#include <Matrix.hpp>
|
||||
#include <Vector.hpp>
|
||||
#include <Vector3.hpp>
|
||||
#include <Euler.hpp>
|
||||
#include <Scalar.hpp>
|
||||
#include <Quaternion.hpp>
|
||||
|
||||
namespace matrix {
|
||||
|
||||
template class Vector<float, 2>;
|
||||
template class Vector<float, 3>;
|
||||
template class Vector<float, 4>;
|
||||
template class Euler<float>;
|
||||
template class Scalar<float>;
|
||||
template class Matrix<float, 3, 3>;
|
||||
template class Matrix<float, 1, 1>;
|
||||
template class Quaternion<float>;
|
||||
|
||||
};
|
||||
+12
-8
@@ -1,27 +1,31 @@
|
||||
#include "Matrix.hpp"
|
||||
#include "SquareMatrix.hpp"
|
||||
#include <assert.h>
|
||||
#include <stdio.h>
|
||||
|
||||
using namespace matrix;
|
||||
|
||||
static const size_t n_large = 50;
|
||||
|
||||
template class SquareMatrix<float, 3>;
|
||||
template class SquareMatrix<float, n_large>;
|
||||
|
||||
int main()
|
||||
{
|
||||
float data[9] = {1, 0, 0, 0, 1, 0, 1, 0, 1};
|
||||
Matrix3f A(data);
|
||||
Matrix3f A_I = A.inverse();
|
||||
SquareMatrix<float, 3> A(data);
|
||||
SquareMatrix<float, 3> A_I = A.inverse();
|
||||
float data_check[9] = {1, 0, 0, 0, 1, 0, -1, 0, 1};
|
||||
Matrix3f A_I_check(data_check);
|
||||
SquareMatrix<float, 3> A_I_check(data_check);
|
||||
(void)A_I;
|
||||
assert(A_I == A_I_check);
|
||||
|
||||
// stess test
|
||||
static const size_t n = 50;
|
||||
Matrix<float, n, n> A_large;
|
||||
SquareMatrix<float, n_large> A_large;
|
||||
A_large.setIdentity();
|
||||
Matrix<float, n, n> A_large_I;
|
||||
SquareMatrix<float, n_large> A_large_I;
|
||||
A_large_I.setZero();
|
||||
|
||||
for (size_t i = 0; i < 50; i++) {
|
||||
for (size_t i = 0; i < n_large; i++) {
|
||||
A_large_I = A_large.inverse();
|
||||
assert(A_large == A_large_I);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
using namespace matrix;
|
||||
|
||||
template class Matrix<float, 3, 3>;
|
||||
|
||||
int main()
|
||||
{
|
||||
Matrix3f m;
|
||||
|
||||
+6
-1
@@ -4,6 +4,11 @@
|
||||
|
||||
using namespace matrix;
|
||||
|
||||
// instantiate so coverage works
|
||||
template class Quaternion<float>;
|
||||
template class Euler<float>;
|
||||
template class Dcm<float>;
|
||||
|
||||
int main()
|
||||
{
|
||||
// test default ctor
|
||||
@@ -12,7 +17,7 @@ int main()
|
||||
assert(q(1) == 0);
|
||||
assert(q(2) == 0);
|
||||
assert(q(3) == 0);
|
||||
|
||||
|
||||
q = Quatf(0.1825742f, 0.3651484f, 0.5477226f, 0.7302967f);
|
||||
assert(q(0) == 0.1825742f);
|
||||
assert(q(1) == 0.3651484f);
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
using namespace matrix;
|
||||
|
||||
template class Matrix<float, 3, 3>;
|
||||
|
||||
int main()
|
||||
{
|
||||
Matrix3f A;
|
||||
|
||||
+5
-2
@@ -4,12 +4,15 @@
|
||||
|
||||
using namespace matrix;
|
||||
|
||||
template class Matrix<float, 2, 3>;
|
||||
template class Matrix<float, 3, 2>;
|
||||
|
||||
int main()
|
||||
{
|
||||
float data[9] = {1, 2, 3, 4, 5, 6};
|
||||
float data[6] = {1, 2, 3, 4, 5, 6};
|
||||
Matrix<float, 2, 3> A(data);
|
||||
Matrix<float, 3, 2> A_T = A.transpose();
|
||||
float data_check[9] = {1, 4, 2, 5, 3, 6};
|
||||
float data_check[6] = {1, 4, 2, 5, 3, 6};
|
||||
Matrix<float, 3, 2> A_T_check(data_check);
|
||||
A_T.print();
|
||||
A_T_check.print();
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
using namespace matrix;
|
||||
|
||||
template class Vector<float, 5>;
|
||||
|
||||
int main()
|
||||
{
|
||||
Vector<float, 5> v;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
using namespace matrix;
|
||||
|
||||
template class Vector<float, 3>;
|
||||
|
||||
int main()
|
||||
{
|
||||
Vector3f a(1, 0, 0);
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
using namespace matrix;
|
||||
|
||||
template class Vector<float, 3>;
|
||||
|
||||
int main()
|
||||
{
|
||||
Vector3f v;
|
||||
|
||||
Reference in New Issue
Block a user