Got coverage working for templates.

This commit is contained in:
jgoppert
2015-11-04 12:11:32 -05:00
parent bf6de4b710
commit 18f80462b7
13 changed files with 243 additions and 201 deletions
-6
View File
@@ -1,9 +1,3 @@
add_library(instantiation
instantiation.cpp
)
link_libraries(instantiation)
set(tests
setIdentity
inverse
-21
View File
@@ -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
View File
@@ -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);
}
+2
View File
@@ -3,6 +3,8 @@
using namespace matrix;
template class Matrix<float, 3, 3>;
int main()
{
Matrix3f m;
+6 -1
View File
@@ -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);
+2
View File
@@ -3,6 +3,8 @@
using namespace matrix;
template class Matrix<float, 3, 3>;
int main()
{
Matrix3f A;
+5 -2
View File
@@ -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();
+2
View File
@@ -4,6 +4,8 @@
using namespace matrix;
template class Vector<float, 5>;
int main()
{
Vector<float, 5> v;
+2
View File
@@ -4,6 +4,8 @@
using namespace matrix;
template class Vector<float, 3>;
int main()
{
Vector3f a(1, 0, 0);
+2
View File
@@ -3,6 +3,8 @@
using namespace matrix;
template class Vector<float, 3>;
int main()
{
Vector3f v;