Add coverage checks.
This commit is contained in:
parent
de4dd70407
commit
323ac318f8
|
@ -14,6 +14,8 @@ if(DEFINED ENV{CMAKE_GCOV})
|
|||
add_compile_options(-fprofile-arcs -ftest-coverage)
|
||||
# Need CMake 3.15+.
|
||||
add_link_options(-fprofile-arcs -ftest-coverage)
|
||||
add_custom_target(coverage COMMAND lcov -d . -t wrmath -o wrmath.info -c
|
||||
COMMAND genhtml -o coverage-report wrmath.info)
|
||||
endif()
|
||||
|
||||
|
||||
|
|
|
@ -29,12 +29,18 @@ public:
|
|||
* The default constructor creates a zero vector for a given
|
||||
* type and size.
|
||||
*/
|
||||
Vector() { wr::math::DefaultEpsilon(this->epsilon); }
|
||||
Vector()
|
||||
{
|
||||
wr::math::DefaultEpsilon(this->epsilon);
|
||||
for (size_t i = 0; i < N; i++) {
|
||||
this->arr[i] = 0.0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If given an initializer_list, the vector is created with
|
||||
* those values. There must be exactly N elements in the list.
|
||||
* @param ilstutil
|
||||
* @param ilst An intializer list with N elements of type T.
|
||||
*/
|
||||
Vector(std::initializer_list<T> ilst)
|
||||
{
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
#include <sstream>
|
||||
#include <gtest/gtest.h>
|
||||
#include <wrmath/geom/vector.h>
|
||||
|
||||
|
@ -5,6 +6,25 @@ using namespace std;
|
|||
using namespace wr;
|
||||
|
||||
|
||||
TEST(Vector3Miscellaneous, ExtractionOperator)
|
||||
{
|
||||
geom::Vector3d vec {1.0, 2.0, 3.0};
|
||||
stringstream vecBuffer;
|
||||
|
||||
vecBuffer << vec;
|
||||
EXPECT_EQ(vecBuffer.str(), "<1, 2, 3>");
|
||||
}
|
||||
|
||||
|
||||
TEST(Vector3Miscellaneous, SetEpsilon)
|
||||
{
|
||||
geom::Vector3f a {1.0, 1.0, 1.0};
|
||||
geom::Vector3f b;
|
||||
|
||||
a.setEpsilon(1.1);
|
||||
EXPECT_EQ(a, b);
|
||||
}
|
||||
|
||||
TEST(Vector3FloatTests, Magnitude)
|
||||
{
|
||||
geom::Vector3f v3f {1.0, -2.0, 3.0};
|
||||
|
@ -105,6 +125,7 @@ TEST(Vector3FloatTests, ParallelOrthogonalVectors)
|
|||
geom::Vector3f d {-1.821, 1.072, -2.94};
|
||||
geom::Vector3f e {-2.0, 1.0, 3.0};
|
||||
geom::Vector3f f {-6.0, 3.0, 9.0};
|
||||
geom::Vector3f zeroVector;
|
||||
|
||||
EXPECT_FALSE(a.isParallel(b));
|
||||
EXPECT_FALSE(a.isOrthogonal(b));
|
||||
|
@ -114,6 +135,10 @@ TEST(Vector3FloatTests, ParallelOrthogonalVectors)
|
|||
|
||||
EXPECT_TRUE(e.isParallel(f));
|
||||
EXPECT_FALSE(e.isOrthogonal(f));
|
||||
|
||||
EXPECT_TRUE(zeroVector.isZero());
|
||||
EXPECT_TRUE(c.isParallel(zeroVector));
|
||||
EXPECT_TRUE(c.isOrthogonal(zeroVector));
|
||||
}
|
||||
|
||||
|
||||
|
@ -230,6 +255,7 @@ TEST(Vector3DoubleTests, ParallelOrthogonalVectors)
|
|||
geom::Vector3d d {-1.821, 1.072, -2.94};
|
||||
geom::Vector3d e {-2.0, 1.0, 3.0};
|
||||
geom::Vector3d f {-6.0, 3.0, 9.0};
|
||||
geom::Vector3d zeroVector;
|
||||
|
||||
EXPECT_FALSE(a.isParallel(b));
|
||||
EXPECT_FALSE(a.isOrthogonal(b));
|
||||
|
@ -239,6 +265,10 @@ TEST(Vector3DoubleTests, ParallelOrthogonalVectors)
|
|||
|
||||
EXPECT_TRUE(e.isParallel(f));
|
||||
EXPECT_FALSE(e.isOrthogonal(f));
|
||||
|
||||
EXPECT_TRUE(zeroVector.isZero());
|
||||
EXPECT_TRUE(c.isParallel(zeroVector));
|
||||
EXPECT_TRUE(c.isOrthogonal(zeroVector));
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue